Skip to content

Instantly share code, notes, and snippets.

Created Apr 14, 2020
What would you like to do?
Attributes can be placed before and after docblocks
/** foo */
class Foo
public const FOO = 'foo', BAR = 'bar';
public $x, $y;
public function foo(<<A1(5)>> $a, <<A1(6)>> $b) { }
$ref = new \ReflectionClass(Foo::class);
$attributes = $ref->getAttributes();
foreach ($attributes as $attribute) {
var_dump($attribute->getName(), $attribute->getArguments());
string(10) "/** foo */"
string(2) "A1"
array(1) {
string(6) "before"
string(2) "A1"
array(1) {
string(5) "after"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment