Skip to content

Commit

Permalink
[#26] Matcher::setAnnotationReader($reader)
Browse files Browse the repository at this point in the history
set annotation reader statically for cached annotation reader.
  • Loading branch information
koriym committed Jul 16, 2014
1 parent 159edfa commit 95a6107
Showing 1 changed file with 22 additions and 3 deletions.
25 changes: 22 additions & 3 deletions src/Matcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
*/
namespace Ray\Aop;

use Doctrine\Common\Annotations\AnnotationReader;
use Doctrine\Common\Annotations\CachedReader;
use Doctrine\Common\Annotations\FileCacheReader;
use Doctrine\Common\Annotations\Reader;
use Ray\Aop\Exception\InvalidAnnotation;
use Ray\Aop\Exception\InvalidArgument as InvalidArgumentException;
Expand Down Expand Up @@ -46,14 +49,30 @@ class Matcher extends AbstractMatcher implements Matchable
*
* @var Reader
*/
private $reader;
static private $annotationReader;

/**
* @var Reader
*/
protected $reader;

/**
* @param Reader $reader
*/
public function __construct(Reader $reader = null)
{
if (is_null(self::$annotationReader)) {
self::$annotationReader = $reader ?: new AnnotationReader;
}
$this->reader = self::$annotationReader;
}

/**
* @param Reader $reader
*/
public function __construct(Reader $reader)
public static function setAnnotationReader(Reader $reader)
{
$this->reader = $reader;
self::$annotationReader = $reader;
}

/**
Expand Down

0 comments on commit 95a6107

Please sign in to comment.