lee-to / fast-attributes
Simplifying PHP Attribute Management
Installs: 25 410
Dependents: 1
Suggesters: 0
Security: 0
Stars: 1
Watchers: 2
Forks: 0
Open Issues: 0
Requires
- php: ^8.0|^8.1|^8.2|^8.3|^8.4
Requires (Dev)
- phpstan/phpstan: ^2.0
- phpunit/phpunit: ^12.0
- rector/rector: ^2.0
This package is auto-updated.
Last update: 2025-02-28 15:15:11 UTC
README
Fast Attributes
Usage
// 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();