Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for reading annotations for method invocations #66
- Loading branch information
1 parent
c9a80c3
commit a35f257
Showing
4 changed files
with
67 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
<?php | ||
/** | ||
* Go! OOP&AOP PHP framework | ||
* | ||
* @copyright Copyright 2014, Lissachenko Alexander <lisachenko.it@gmail.com> | ||
* @license http://www.opensource.org/licenses/mit-license.php The MIT License | ||
*/ | ||
|
||
namespace Go\Aop\Support; | ||
|
||
use Doctrine\Common\Annotations\Reader; | ||
use ReflectionMethod; | ||
|
||
/** | ||
* Extended version of ReflectionMethod with annotation support | ||
*/ | ||
class AnnotatedReflectionMethod extends ReflectionMethod | ||
{ | ||
/** | ||
* Annotation reader | ||
* | ||
* @var Reader | ||
*/ | ||
private static $annotationReader = null; | ||
|
||
/** | ||
* Gets a method annotation. | ||
* | ||
* @param string $annotationName The name of the annotation. | ||
* @return mixed The Annotation or NULL, if the requested annotation does not exist. | ||
*/ | ||
public function getAnnotation($annotationName) | ||
{ | ||
return self::$annotationReader->getMethodAnnotation($this, $annotationName); | ||
} | ||
|
||
/** | ||
* Gets the annotations applied to a method. | ||
* | ||
* @return array An array of Annotations. | ||
*/ | ||
public function getAnnotations() | ||
{ | ||
return self::$annotationReader->getMethodAnnotations($this); | ||
} | ||
|
||
/** | ||
* Injects an annotation reader | ||
* | ||
* @param Reader $reader | ||
*/ | ||
public static function injectAnnotationReader(Reader $reader) | ||
{ | ||
self::$annotationReader = $reader; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters