1. Go to this page and download the library: Download welcomattic/has-attributes library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
#[\Attribute(\Attribute::TARGET_METHOD)]
class MethodAttribute {}
#[\Attribute(\Attribute::TARGET_PROPERTY)]
class PropertyAttribute {}
class Foo {
#[MethodAttribute]
public function bar() {}
#[PropertyAttribute]
public $baz;
}
method_has_attribute(Foo::class, MethodAttribute::class, 'bar'); // true
property_has_attribute(Foo::class, PropertyAttribute::class, 'baz'); // true
#[\Attribute(\Attribute::TARGET_CLASS)]
class ClassAttributeInterface {}
#[\Attribute(\Attribute::TARGET_CLASS)]
class ChildClassAttribute extends ClassAttributeInterface {}
#[ChildClassAttribute]
class Foo {}
class_has_attribute(Baz::class, [ClassAttributeInterface::class]); // true
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.