PHP code example of ali-eltaweel / attr-action

1. Go to this page and download the library: Download ali-eltaweel/attr-action 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/ */

    

ali-eltaweel / attr-action example snippets


use Attraction\Annotation;

#[Attribute]
class Mark extends Annotation {}

#[Attribute(Attribute::TARGET_CLASS|Attribute::IS_REPEATABLE)]
class RepeatableMark extends Annotation {}

#[Mark]
class Target {}

#[RepeatableMark]
#[RepeatableMark]
class AnotherTarget {}

/** @var Mark */
$mark = Mark::annotatedOn(new ReflectionClass(Target::class));

/** @var RepeatableMark[] */
$marks = RepeatableMark::annotatedOn(new ReflectionClass(AnotherTarget::class));