flexic/attribute-reader

提供PHP属性的读取器。

1.2.0 2022-10-23 13:51 UTC

This package is auto-updated.

Last update: 2024-09-23 18:12:52 UTC


README

从类、方法或属性中获取属性的读取器。

安装

运行

composer require flexic/attribute-reader

以安装flexic/attribute-reader

获取属性

$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.

许可证

此软件包使用GNU许可证授权。

请查看LICENSE.md

Donate