rudra / annotation
Class & Method Annotation Reader
v2.0.0
2018-05-29 13:35 UTC
Requires
- php: >=7.1
- rudra/exception: v2.0.0
Requires (Dev)
- phpunit/phpunit: ^7
This package is auto-updated.
Last update: 2024-10-24 15:53:31 UTC
README
Annotations and attributes reader / Читатель аннотаций и атрибутов | API
Installation / Установка
composer require rudra/annotation
Using / Использование
$annotation = new Annotation();
An example of reading annotations / Пример чтения аннотаций
$annotation->getAnnotations(PageController::class); $annotation->getAnnotations(PageController::class, "indexAction");
/** * @Routing(url = '') * @Defaults(name = 'user1', lastname = 'sample', age='0', address = {country : 'Russia'; state : 'Tambov'}, phone = '000-00000000') * @assertResult(false) * @Validate(name = 'min:150', phone = 'max:9') * @Middleware('Middleware', params = {int1 : '123'}) */ class PageController { /** * @Routing(url = '') * @Defaults(name = 'user1', lastname = 'sample', age='0', address = {country : 'Russia'; state : 'Tambov'}, phone = '000-00000000') * @assertResult(false) * @Validate(name = 'min:150', phone = 'max:9') * @Middleware('Middleware', params = {int1 : '123'}) */ public function indexAction() { // Your code } }
An example of reading attributes / Пример чтения атрибутов
$annotation->getAttributes(PageController::class); $annotation->getAttributes(PageController::class, "indexAction");
#[Routing(url:'')] #[Defaults(name:'user1', lastname:'sample', age:'0', address:['country' => 'Russia', 'state' => 'Tambov'], phone:'000-00000000')] #[assertResult(false)] #[Validate(name:'min:150', phone:'max:9')] #[Middleware('Middleware', params:['int1' => '123'])] class PageController { #[Routing(url:'')] #[Defaults(name:'user1', lastname:'sample', age:'0', address:['country' => 'Russia', 'state' => 'Tambov'], phone:'000-00000000')] #[assertResult(false)] #[Validate(name:'min:150', phone:'max:9')] #[Middleware('Middleware', params:['int1' => '123'])] public function indexAction() { // Your code } }
Result in both cases / Результат чтения в обоих случаях:
[ 'Routing' => [['url' => ""]], 'Defaults' => [ [ 'name' => "user1", 'lastname' => "sample", 'age' => "0", 'address' => [ 'country' => "Russia", 'state' => "Tambov", ], 'phone' => "000-00000000", ], ], 'assertResult' => [["false"]], 'Validate' => [ [ 'name' => "min:150", 'phone' => "max:9", ], ], 'Middleware' => [ [ 0 => "'Middleware'", 'params' => [ 'int1' => '123', ], ], ], ];