Doctrine\Common\Annotations\AnnotationReader::__construct PHP Method

__construct() public method

Initializes a new AnnotationReader.
public __construct ( DocParser $parser = null )
$parser DocParser
    public function __construct(DocParser $parser = null)
    {
        if (extension_loaded('Zend Optimizer+') && (ini_get('zend_optimizerplus.save_comments') === "0" || ini_get('opcache.save_comments') === "0")) {
            throw AnnotationException::optimizerPlusSaveComments();
        }
        if (extension_loaded('Zend OPcache') && ini_get('opcache.save_comments') == 0) {
            throw AnnotationException::optimizerPlusSaveComments();
        }
        if (PHP_VERSION_ID < 70000) {
            if (extension_loaded('Zend Optimizer+') && (ini_get('zend_optimizerplus.load_comments') === "0" || ini_get('opcache.load_comments') === "0")) {
                throw AnnotationException::optimizerPlusLoadComments();
            }
            if (extension_loaded('Zend OPcache') && ini_get('opcache.load_comments') == 0) {
                throw AnnotationException::optimizerPlusLoadComments();
            }
        }
        AnnotationRegistry::registerFile(__DIR__ . '/Annotation/IgnoreAnnotation.php');
        $this->parser = $parser ?: new DocParser();
        $this->preParser = new DocParser();
        $this->preParser->setImports(self::$globalImports);
        $this->preParser->setIgnoreNotImportedAnnotations(true);
        $this->phpParser = new PhpParser();
    }

Usage Example

 public function __construct(Cache $cache = null, Parser $parser = null)
 {
     if (null === $parser) {
         $parser = new AnnotationParser();
     }
     parent::__construct($cache, $parser);
     $this->setAutoloadAnnotations(false);
     $this->setAnnotationNamespaceAlias('JMS\\SecurityExtraBundle\\Annotation\\', 'extra');
     $this->loadAnnotations();
 }
All Usage Examples Of Doctrine\Common\Annotations\AnnotationReader::__construct