1 | <?php |
||
22 | class AnnotationPointcut implements Pointcut |
||
23 | { |
||
24 | use PointcutClassFilterTrait; |
||
25 | /** |
||
26 | * Annotation class to match |
||
27 | * |
||
28 | * @var string |
||
29 | */ |
||
30 | protected $annotationName = ''; |
||
31 | |||
32 | /** |
||
33 | * Annotation reader |
||
34 | * |
||
35 | * @var null|Reader |
||
36 | */ |
||
37 | protected $annotationReader = null; |
||
38 | |||
39 | /** |
||
40 | * Kind of current filter, can be KIND_CLASS, KIND_METHOD, KIND_PROPERTY, KIND_TRAIT |
||
41 | * |
||
42 | * @var int |
||
43 | */ |
||
44 | protected $filterKind = 0; |
||
45 | |||
46 | /** |
||
47 | * Specifies name of the expected class to receive |
||
48 | * |
||
49 | * @var string |
||
50 | */ |
||
51 | protected $expectedClass = ''; |
||
52 | |||
53 | /** |
||
54 | * Method to call for annotation reader |
||
55 | * |
||
56 | * @var string |
||
57 | */ |
||
58 | protected $annotationMethod = ''; |
||
59 | |||
60 | /** |
||
61 | * Static mappings of kind to expected class and method name |
||
62 | * |
||
63 | * @var array |
||
64 | */ |
||
65 | protected static $mappings = array( |
||
66 | self::KIND_CLASS => array( |
||
67 | ReflectionClass::class, |
||
68 | 'getClassAnnotation' |
||
69 | ), |
||
70 | self::KIND_TRAIT => array( |
||
71 | ReflectionClass::class, |
||
72 | 'getClassAnnotation' |
||
73 | ), |
||
74 | self::KIND_METHOD => array( |
||
75 | ReflectionMethod::class, |
||
76 | 'getMethodAnnotation' |
||
77 | ), |
||
78 | self::KIND_PROPERTY => array( |
||
79 | ReflectionProperty::class, |
||
80 | 'getPropertyAnnotation' |
||
81 | ) |
||
82 | ); |
||
83 | |||
84 | /** |
||
85 | * Annotation matcher constructor |
||
86 | * |
||
87 | * @param integer $filterKind Kind of filter, e.g. KIND_CLASS |
||
88 | * @param Reader $reader Reader of annotations |
||
89 | * @param string $annotationName Annotation class name to match |
||
90 | */ |
||
91 | 3 | public function __construct($filterKind, Reader $reader, $annotationName) |
|
102 | |||
103 | /** |
||
104 | * @param ReflectionClass|ReflectionMethod|ReflectionProperty $point |
||
105 | * {@inheritdoc} |
||
106 | */ |
||
107 | public function matches($point) |
||
122 | |||
123 | /** |
||
124 | * Returns the kind of point filter |
||
125 | * |
||
126 | * @return integer |
||
127 | */ |
||
128 | public function getKind() |
||
132 | } |
||
133 |