Annotations and attributes reader / Читатель аннотаций и атрибутов | API
composer require rudra/annotation
$annotation = new Annotation();
$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
}
}
$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
}
}
[
'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',
],
],
],
];