Download src/php/php-src/Zend/tests/attributes/001_placement.phpt from meddyrat/dis-bench: direct link, hf CLI and curl.
- Browser
- Download file 2.01 kB
-
https://huggingface.co/datasets/meddyrat/dis-bench/resolve/main/src/php/php-src/Zend/tests/attributes/001_placement.phpt
- Command line
-
hf download hf://datasets/meddyrat/dis-bench/src/php/php-src/Zend/tests/attributes/001_placement.phpt
-
curl -L -o 001_placement.phpt https://huggingface.co/datasets/meddyrat/dis-bench/resolve/main/src/php/php-src/Zend/tests/attributes/001_placement.phpt
2.01 kB
| --TEST-- | |
| Attributes can be placed on all supported elements. | |
| --FILE-- | |
| <?php | |
| class Foo | |
| { | |
| #[A1(2)] | |
| public const FOO = 'foo'; | |
| #[A1(3)] | |
| public $x; | |
| #[A1(4)] | |
| public function foo(#[A1(5)] $a, #[A1(6)] $b) { } | |
| } | |
| $object = new #[A1(7)] class () { }; | |
| #[A1(8)] | |
| function f1() { } | |
| $f2 = #[A1(9)] function () { }; | |
| $f3 = #[A1(10)] fn () => 1; | |
| #[A1(11)] | |
| const CT_CONSTANT = 'Demo'; | |
| $ref = new \ReflectionClass(Foo::class); | |
| $sources = [ | |
| $ref, | |
| $ref->getReflectionConstant('FOO'), | |
| $ref->getProperty('x'), | |
| $ref->getMethod('foo'), | |
| $ref->getMethod('foo')->getParameters()[0], | |
| $ref->getMethod('foo')->getParameters()[1], | |
| new \ReflectionObject($object), | |
| new \ReflectionFunction('f1'), | |
| new \ReflectionFunction($f2), | |
| new \ReflectionFunction($f3), | |
| new \ReflectionConstant('CT_CONSTANT'), | |
| ]; | |
| foreach ($sources as $r) { | |
| $attr = $r->getAttributes(); | |
| var_dump(get_class($r), count($attr)); | |
| foreach ($attr as $a) { | |
| var_dump($a->getName(), $a->getArguments()); | |
| } | |
| echo "\n"; | |
| } | |
| ?> | |
| --EXPECT-- | |
| string(15) "ReflectionClass" | |
| int(1) | |
| string(2) "A1" | |
| array(1) { | |
| [0]=> | |
| int(1) | |
| } | |
| string(23) "ReflectionClassConstant" | |
| int(1) | |
| string(2) "A1" | |
| array(1) { | |
| [0]=> | |
| int(2) | |
| } | |
| string(18) "ReflectionProperty" | |
| int(1) | |
| string(2) "A1" | |
| array(1) { | |
| [0]=> | |
| int(3) | |
| } | |
| string(16) "ReflectionMethod" | |
| int(1) | |
| string(2) "A1" | |
| array(1) { | |
| [0]=> | |
| int(4) | |
| } | |
| string(19) "ReflectionParameter" | |
| int(1) | |
| string(2) "A1" | |
| array(1) { | |
| [0]=> | |
| int(5) | |
| } | |
| string(19) "ReflectionParameter" | |
| int(1) | |
| string(2) "A1" | |
| array(1) { | |
| [0]=> | |
| int(6) | |
| } | |
| string(16) "ReflectionObject" | |
| int(1) | |
| string(2) "A1" | |
| array(1) { | |
| [0]=> | |
| int(7) | |
| } | |
| string(18) "ReflectionFunction" | |
| int(1) | |
| string(2) "A1" | |
| array(1) { | |
| [0]=> | |
| int(8) | |
| } | |
| string(18) "ReflectionFunction" | |
| int(1) | |
| string(2) "A1" | |
| array(1) { | |
| [0]=> | |
| int(9) | |
| } | |
| string(18) "ReflectionFunction" | |
| int(1) | |
| string(2) "A1" | |
| array(1) { | |
| [0]=> | |
| int(10) | |
| } | |
| string(18) "ReflectionConstant" | |
| int(1) | |
| string(2) "A1" | |
| array(1) { | |
| [0]=> | |
| int(11) | |
| } | |