PHP code example of jworman / annotation-reader

1. Go to this page and download the library: Download jworman/annotation-reader 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/ */

    

jworman / annotation-reader example snippets


use JWorman\AnnotationReader\AbstractAnnotation;

class MyAnnotation extends AbstractAnnotation
{
}

use MyAnnotation;

class Example
{
    /**
     * @MyAnnotation("fizzbuzz")
     */
    private $id;
}

use JWorman\AnnotationReader\AnnotationReader;

$annotationReader = new AnnotationReader();
$reflectionProperty = new \ReflectionProperty('Example', 'id');
$annotation = $annotationReader->getPropertyAnnotation($reflectionProperty, 'MyAnnotation');
$value = $annotation->getValue(); // Returns "fizzbuzz"

/**
  * @MyAnnotation("fizzbuzz")
  * @AnotherOne({"isCool": true, "list": [null, false, {"nested": "object"}]})
  */

use JWorman\AnnotationReader\AbstractAnnotation;

class AnotherOne extends AbstractAnnotation
{
    private $isCool; // From above annotations will equal: true
    private $list;   // From above annotations will equal: [null, false, \stdObject()]
}