1--TEST-- 2Exception handling in ReflectionAttribute::newInstance() 3--FILE-- 4<?php 5 6#[\Attribute] 7class A { 8 public function __construct() { 9 throw new \Exception('Test'); 10 } 11} 12 13class Foo { 14 #[A] 15 public function bar() {} 16} 17 18$rm = new ReflectionMethod(Foo::class, "bar"); 19$attribute = $rm->getAttributes()[0]; 20 21var_dump($attribute->newInstance()); 22?> 23--EXPECTF-- 24Fatal error: Uncaught Exception: Test in %s:6 25Stack trace: 26#0 %sReflectionAttribute_newInstance_exception.php(11): A->__construct() 27#1 %sReflectionAttribute_newInstance_exception.php(18): ReflectionAttribute->newInstance() 28#2 {main} 29 thrown in %sReflectionAttribute_newInstance_exception.php on line 6 30