Download src/php/php-src/ext/reflection/tests/ReflectionAttribute_newInstance_exception.phpt from meddyrat/dis-bench: direct link, hf CLI and curl.
- Browser
- Download file 683 Bytes
-
https://huggingface.co/datasets/meddyrat/dis-bench/resolve/main/src/php/php-src/ext/reflection/tests/ReflectionAttribute_newInstance_exception.phpt
- Command line
-
hf download hf://datasets/meddyrat/dis-bench/src/php/php-src/ext/reflection/tests/ReflectionAttribute_newInstance_exception.phpt
-
curl -L -o ReflectionAttribute_newInstance_exception.phpt https://huggingface.co/datasets/meddyrat/dis-bench/resolve/main/src/php/php-src/ext/reflection/tests/ReflectionAttribute_newInstance_exception.phpt
683 Bytes
| --TEST-- | |
| Exception handling in ReflectionAttribute::newInstance() | |
| --FILE-- | |
| class A { | |
| public function __construct() { | |
| throw new \Exception('Test'); | |
| } | |
| } | |
| class Foo { | |
| #[A] | |
| public function bar() {} | |
| } | |
| $rm = new ReflectionMethod(Foo::class, "bar"); | |
| $attribute = $rm->getAttributes()[0]; | |
| var_dump($attribute->newInstance()); | |
| --EXPECTF-- | |
| Fatal error: Uncaught Exception: Test in %s:6 | |
| Stack trace: | |
| #0 %sReflectionAttribute_newInstance_exception.php(11): A->__construct() | |
| #1 %sReflectionAttribute_newInstance_exception.php(18): ReflectionAttribute->newInstance() | |
| #2 {main} | |
| thrown in %sReflectionAttribute_newInstance_exception.php on line 6 | |