Skip to content

Instantly share code, notes, and snippets.

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