定制 rkr/attribute-provider 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

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

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-03-08