-
-
Save beberlei/6cf033a3d2cd1a8d991fcabdecce0626 to your computer and use it in GitHub Desktop.
This file contains 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
--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