rudra / annotation
Class & Method Annotation Reader
Installs: 494
Dependents: 2
Suggesters: 0
Security: 0
Stars: 1
Watchers: 2
Forks: 0
Open Issues: 0
pkg:composer/rudra/annotation
Requires
- php: >=8.3
- rudra/docs: v25.10
- rudra/exception: v25.10
This package is auto-updated.
Last update: 2025-10-17 08:23:44 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'}) * @Annotation(param1, param2 = 'param2', param3={param1;param2:'param2'}) */ 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'}) * @Annotation(param1, param2 = 'param2', param3={param1;param2:'param2'}) */ 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'])] #[Annotation("param1", param2:'param2', param3:['param1', 'param2' => 'param2'])] 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'])] #[Annotation("param1", param2:'param2', param3:['param1', 'param2' => 'param2'])] 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' => [
[
"'Middleware'",
'params' => [
'int1' => '123',
],
],
],
"Annotation" => [
[
"param1",
"param2" => "param2",
"param3" => [
"param1",
"param2" => "param2",
],
],
],
];