lee-to / fast-attributes
简化PHP属性管理
0.1.0
2024-03-19 15:57 UTC
Requires
- php: ^8.0|^8.1|^8.2
- psr/simple-cache: ^3.0
Requires (Dev)
- phpstan/phpstan: ^1.10
- phpunit/phpunit: ^10.0
- rector/rector: ^1.0
This package is auto-updated.
Last update: 2024-09-24 07:37:28 UTC
README
快速属性
用法
// All class attributes $classAttributes = Attributes::for(ClassWithAttributes::class)->get();
// Only SomeAttribute class attributes $someAttributes = Attributes::for(ClassWithAttributes::class) ->attribute(SomeAttribute::class) ->get();
// Only SomeAttribute instance $someAttribute = Attributes::for(ClassWithAttributes::class) ->attribute(SomeAttribute::class) ->first();
// SomeAttribute variable property $someAttribute = Attributes::for(ClassWithAttributes::class) ->attribute(SomeAttribute::class) ->first('variable');
// Method parameter attributes $someAttribute = Attributes::for(ClassWithAttributes::class) ->method('someMethod') ->parameter('variable') ->get();
$someAttribute = Attributes::for(ClassWithAttributes::class) ->constant('VARIABLE') ->property('variable') ->method('someMethod') ->parameter('variable') ->get();