PHP code example of kenny1911 / doctrine-inherit-annotations
1. Go to this page and download the library: Download kenny1911/doctrine-inherit-annotations 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/ */
kenny1911 / doctrine-inherit-annotations example snippets
use Doctrine\Common\Annotations\AnnotationReader;
use Kenny1911\DoctrineInheritAnnotations\InheritAnnotationReader;
$reader = new AnnotationReader(); // Original annotation reader
$inheritReader = new InheritAnnotationReader($reader);
use Doctrine\Common\Annotations\AnnotationReader;
use Kenny1911\DoctrineInheritAnnotations\Annotation\Inherit;
use Kenny1911\DoctrineInheritAnnotations\InheritAnnotationReader;
/**
* @FooAnnotation()
*/
class ParentClass {}
/**
* @BarAnnotation()
*
* @Inherit()
*/
class ChildClass extends ParentClass {}
$reader = new AnnotationReader();
$reader->getClassAnnotations(new ReflectionClass(ChildClass::class)); // return [@BarAnnotation(), @Inherit()]
$inheritReader = new InheritAnnotationReader($reader);
$inheritReader->getClassAnnotations(new ReflectionClass(ChildClass::class)); // return [@BarAnnotation(), @Inherit(), @FooAnnotation()]