Last active
September 6, 2020 04:23
-
-
Save shin1x1/8c1b6451c27e6ae90294fa973e9e6254 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace Acme; | |
@@Attribute | |
final class Attr1 {} | |
@@Attr1 | |
final class Foo {} | |
$reflectionClass = new \ReflectionClass(Foo::class); | |
$attributes = $reflectionClass->getAttributes(); | |
var_dump($attributes[0]->newInstance()); | |
/* | |
Fatal error: Uncaught Error: Attempting to use non-attribute class "Acme\Attr1" as attribute in /app/attr.php:13 | |
Stack trace: | |
#0 /app/attr.php(13): ReflectionAttribute->newInstance() | |
#1 {main} | |
thrown in /app/attr.php on line 13 | |
*/ | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace Acme; | |
@@Attribute | |
final class Attr1 {} | |
@@Attr10 | |
final class Foo {} | |
$reflectionClass = new \ReflectionClass(Foo::class); | |
$attributes = $reflectionClass->getAttributes(); | |
var_dump($attributes[0]->newInstance()); | |
/* | |
Fatal error: Uncaught Error: Attribute class "Acme\Attr10" not found in /app/attr.php:13 | |
Stack trace: | |
#0 /app/attr.php(13): ReflectionAttribute->newInstance() | |
#1 {main} | |
thrown in /app/attr.php on line 13 | |
*/ | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment