flexic / attribute-reader
Provides an reader for php attributes.
1.2.0
2022-10-23 13:51 UTC
Requires
- php: ^8.1
Requires (Dev)
- ergebnis/php-cs-fixer-config: ^4.9.0
- phpstan/phpstan: ^1.8.7
- phpstan/phpstan-deprecation-rules: ^1.0.0
- phpstan/phpstan-strict-rules: ^1.4.4
README
Reader to get attributes from a class, method or property.
Installation
Run
composer require flexic/attribute-reader
to install flexic/attribute-reader
.
Get Attributes
$reflectionClass = new \ReflectionClass(MyClass::class); $attributeReader = new Flexic\Attributes\Reader(); $attributeReader->getAttributes($reflectionClass); // Returns list of given attributes $attributeReader->getAttribute($reflectionClass, MyAttribute::class); // Returns first attribute of given type $attributeReader->hasAttribute($reflectionClass, MyAttribute::class); // Checks if attribute is defined on class. $attributeReader->findClassesWithAttribute(MyAttribute::class); // Get all classes where Attribute is defined.
License
This package is licensed using the GNU License.
Please have a look at LICENSE.md.