Method Attributes
PHP Class with Class Attributes
<?php
declare(strict_types=1);
class Abc
{
#[TestAttribute11(["key1" => "key1 value"])]
#[TestAttribute12(10.13)]
#[TestAttribute13(123)]
#[TestAttribute14()]
#[TestAttribute15(["value1", "value2"])]
public function function1() {
// rest of the codes
}
// rest of the codes
}Initialize the Attributes Reader
<?php
declare(strict_types=1);
use \AntonDPerera\PHPAttributesReader\AttributesReader;
$class = Abc::class;
$attributes_reader = AttributesReader($class);Available functions for Method Attributes
If
$method_nameisnull, returnstrueorfalsebased on availability of Method attributes in the class.If
$method_nameis notnull, returnstrueorfalsebased on availability of Method attributes for the given$method_name.
If
$method_nameisnull, returns all the Method attributes in the class.If $method_name is not
null, returns all the Method attributes for the given method name. It will be an array of attributes. Each item on Array will be an instance of Attribute classRefer Attribute class Reference documentation for more details.
If given
$method_nameis not available within the list of Method attributes, this function will throwsAntonDPerera\PHPAttributesReader\Exceptions\MethodNotFoundException.
If given
$method_nameis not available within the list of Method attributes, this function will throwsAntonDPerera\PHPAttributesReader\Exceptions\MethodNotFoundException.If given
$method_nameis available within the list of Method attributes but the given$attribute_namedoesn't exists in the attributes list this function will throwsAntonDPerera\PHPAttributesReader\Exceptions\MethodAttributeNotFoundException.If given
$method_nameis available within the list of Method attributes and the given$attribute_nameexists too for that method, this function will return an instance of Attribute class. Refer Attribute class Reference documentation for more details.
Last updated