koriym/param-reader
最新稳定版本:1.1.0
Composer 安装命令:
composer require koriym/param-reader
包简介
An annotation/attribute reader for method parameter
README 文档
README
This is a meta data reader to get attributes or annotations from method parameters.
Although doctine/annotation cannot annotate method parameters, this reader treats annotations of properties with the same names as method parameters as method parameter metadata.
This is especially useful when you want to prepare metadata for injection.
Installation
composer require koriym/param-reader
Getting Started
$reader = new PramReader(); $user = $reader->getParametrAnnotation(new ReflectionParameter([Consumer::class, '__construct'], 'name'), User::class); assert($user instanceof User); $users = $reader->getParametrAnnotations(new ReflectionParameter([Consumer::class, '__construct'], 'name')); assert($users[0] instanceof User); assert($users[1] instanceof Foo);
The following two codes provide the same meta information.
class Consumer { private $name; public function __construct(#[User, Foo] string $name) { $this->name = $name; } }
class Consumer { /** * @User * @Foo */ private $name; public function __construct(string $name) { $this->name = $name; } }
Related
统计信息
- 总下载量: 1.17M
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 1
- 依赖项目数: 1
- 推荐数: 1
其他信息
- 授权协议: MIT
- 更新时间: 2022-03-07