rkr/attribute-provider
Composer 安装命令:
composer require rkr/attribute-provider
包简介
A lightweight PHP utility for simplifying the retrieval of attributes using reflection.
README 文档
README
A lightweight PHP utility for simplifying the retrieval of attributes using reflection.
Installation
composer require rkr/attribute-provider
Example Usage
use Kir\Attributes\ClassAttributeProviderFactory; use Kir\Attributes\Subjects\ClassAttribute; use Kir\Attributes\Subjects\MethodAttribute; use Kir\Attributes\Subjects\PropertyAttribute; use Kir\Attributes\Subjects\TestClass1; $factory = new ClassAttributeProviderFactory(); $provider = $factory->create(TestClass1::class); $reflectionAttributes = $provider->getAllReflectionAttributes(ClassAttribute::class); foreach ($reflectionAttributes as $reflectionAttribute) { $instance = $reflectionAttribute->newInstance(); printf("Attribute %s of %s -> %s: %s%s", $instance::class, TestClass1::class, $instance->key, $instance->value, PHP_EOL); } $reflectionAttributes = $provider->properties()->getFirstAttributesFromPropertiesWithPropertyNameAsKey(PropertyAttribute::class); foreach ($reflectionAttributes as $propertyName => $instance) { printf("Attribute %s of %s -> %s: %s%s", $instance::class, $propertyName, $instance->key, $instance->value, PHP_EOL); } $reflectionAttributes = $provider->methods()->getFirstAttributesFromMethodsWithMethodNameAsKey(MethodAttribute::class); foreach ($reflectionAttributes as $propertyName => $instance) { printf("Attribute %s of %s -> %s: %s%s", $instance::class, $propertyName, $instance->key, $instance->value, PHP_EOL); }
统计信息
- 总下载量: 0
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-03-08