glueapps / annotations
1.0.x-dev
2018-06-01 11:50 UTC
Requires
- php: >=7.1
Requires (Dev)
- phpunit/phpunit: ^7.1
This package is auto-updated.
Last update: 2025-03-01 00:18:21 UTC
README
$ composer require glueapps/annotations
Usage
<?php use GlueApps\Annotations\Parser; $text = ' @Annotation1 @Annotation2() @Annotation3(attr1="val1", attr2="val2") '; $annotations = (new Parser)->parse($text); $annotation1 = $annotations[0]; $annotation2 = $annotations[1]; $annotation3 = $annotations[2]; $annotation1->getName(); // Annotation1 $annotation1->getAttributes(); // [] $annotation2->getName(); // Annotation2 $annotation2->getAttributes(); // [] $annotation3->getName(); // Annotation3 $annotation3->getAttributes(); // ['attr1' => 'val1', 'attr2' => 'val2'] $annotation3->getAttribute('attr1'); // val1