Property Attributes
PHP Class with Class Attributes
<?php
declare(strict_types=1);
class Abc
{
#[TestAttribute2('testValue2')]
public ?string $test_property_1 = null;
public ?string $test_property_2 = null;
// 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 Property Attributes
If
$property_nameisnull, returnstrueorfalsebased on availability of Property attributes in the class.If
$property_nameis notnull, returnstrueorfalsebased on availability of Property attributes for the given$property_name.
If
$property_nameisnull, returns all the Property attributes in the class.If
$property_nameis notnull, returns all the Property 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
$property_nameis not available within the list of Property attributes, this function will throwsAntonDPerera\PHPAttributesReader\Exceptions\PropertyNotFoundException.
If given
$property_nameis not available within the list of Property attributes, this function will throwsAntonDPerera\PHPAttributesReader\Exceptions\PropertyNotFoundException.If given
$property_nameis available within the list of Property attributes but the given$attribute_namedoesn't exists in the attributes list this function will throwsAntonDPerera\PHPAttributesReader\Exceptions\PropertyAttributeNotFoundException.If given
$property_nameis available within the list of Property 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