grajewsky / annotations
PHP Annotations Reader OOP
Installs: 12
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 2
Forks: 0
Open Issues: 0
pkg:composer/grajewsky/annotations
Requires (Dev)
- phpstan/phpstan: ^0.11.16
 - phpunit/phpunit: 7
 
This package is auto-updated.
Last update: 2025-10-29 02:53:07 UTC
README
Quick Use
use \Annotations\Annotations; /** * @Sample value=1 * @SampleTest value=1, test=2 **/ class EntityTestClass { /** * @Test */ private $test = 1; } $annotations = Annotations::read(EntityTestClass::class); print_r($annotations->annotations(Annotations::ALL_ANNOTATIONS));
About structure
Statement $a = Annotations::read(EntityTestClass::class); return Annotations class where you can induce $a->annotations($accessor) method, where the parameter is the key is the character string, where the values are:
- pass const 
Annotations::ALL_ANNOTATINS- all the annotations(class and properties/methods) result isArray<Annotation> - pass const 
Annotations::CLASS_ANNOTATIONS- accessor return Array<String, Annotation> - annotations of class - pass property name or method to return annotations`
 
Output:
Array
(
    [class] => Array
        (
            [Sample] => Annotations\Domains\Annotation Object
                (
                    [fields:Annotations\Domains\Annotation:private] => Array
                        (
                            [value] => 1
                        )
                    [name:Annotations\Domains\Annotation:private] => Sample
                )
            [SampleTest] => Annotations\Domains\Annotation Object
                (
                    [fields:Annotations\Domains\Annotation:private] => Array
                        (
                            [value] => 1
                            [test] => 2
                        )
                    [name:Annotations\Domains\Annotation:private] => SampleTest
                )
        )
    [test] => Array
        (
            [ORM] => Annotations\Domains\Annotation Object
                (
                    [fields:Annotations\Domains\Annotation:private] => Array
                        (
                            [table] => entity
                        )
                    [name:Annotations\Domains\Annotation:private] => ORM
                )
            [Test] => Annotations\Domains\Annotation Object
                (
                    [fields:Annotations\Domains\Annotation:private] => Array
                        (
                        )
                    [name:Annotations\Domains\Annotation:private] => Test
                )
        )
)