1
|
|
|
<?php |
2
|
|
|
/* |
3
|
|
|
* Go! AOP framework |
4
|
|
|
* |
5
|
|
|
* @copyright Copyright 2013, Lisachenko Alexander <[email protected]> |
6
|
|
|
* |
7
|
|
|
* This source file is subject to the license that is bundled |
8
|
|
|
* with this source code in the file LICENSE. |
9
|
|
|
*/ |
10
|
|
|
|
11
|
|
|
namespace Go\Aop\Pointcut; |
12
|
|
|
|
13
|
|
|
use Go\Aop\Pointcut; |
14
|
|
|
use Go\Aop\PointFilter; |
15
|
|
|
use Go\Aop\Support\OrPointFilter; |
16
|
|
|
use TokenReflection\ReflectionClass; |
17
|
|
|
use TokenReflection\ReflectionMethod; |
18
|
|
|
use TokenReflection\ReflectionProperty; |
19
|
|
|
|
20
|
|
|
/** |
21
|
|
|
* Signature method pointcut checks method signature (modifiers and name) to match it |
22
|
|
|
*/ |
23
|
|
|
class OrPointcut extends AndPointcut |
24
|
|
|
{ |
25
|
|
|
|
26
|
|
|
/** |
27
|
|
|
* Signature method matcher constructor |
28
|
|
|
* |
29
|
|
|
* @param Pointcut $first First filter |
30
|
|
|
* @param Pointcut $second Second filter |
31
|
|
|
*/ |
32
|
2 |
|
public function __construct(Pointcut $first, Pointcut $second) |
33
|
|
|
{ |
34
|
2 |
|
$this->first = $first; |
35
|
2 |
|
$this->second = $second; |
36
|
2 |
|
$this->kind = $first->getKind() | $second->getKind(); |
37
|
|
|
|
38
|
2 |
|
$this->classFilter = new OrPointFilter($first->getClassFilter(), $second->getClassFilter()); |
39
|
2 |
|
} |
40
|
|
|
|
41
|
|
|
/** |
42
|
|
|
* Performs matching of point of code |
43
|
|
|
* |
44
|
|
|
* @param mixed $point Specific part of code, can be any Reflection class |
45
|
|
|
* @param null|mixed $context Related context, can be class or namespace |
46
|
|
|
* @param null|string|object $instance Invocation instance or string for static calls |
47
|
|
|
* @param null|array $arguments Dynamic arguments for method |
48
|
|
|
* |
49
|
|
|
* @return bool |
50
|
|
|
*/ |
51
|
|
|
public function matches($point, $context = null, $instance = null, array $arguments = null) |
52
|
|
|
{ |
53
|
|
|
return $this->matchPart($this->first, $point, $context, $instance, $arguments) |
54
|
|
|
|| $this->matchPart($this->second, $point, $context, $instance, $arguments); |
55
|
|
|
} |
56
|
|
|
|
57
|
|
|
/** |
58
|
|
|
* @inheritDoc |
59
|
|
|
*/ |
60
|
|
|
protected function matchPart(Pointcut $pointcut, $point, $context = null, $instance = null, array $arguments = null) |
61
|
|
|
{ |
62
|
|
|
$pointcutKind = $pointcut->getKind(); |
63
|
|
|
// We need to recheck filter kind one more time, because of OR syntax |
64
|
|
|
switch (true) { |
65
|
|
|
case ($point instanceof ReflectionMethod && ($pointcutKind & PointFilter::KIND_METHOD)): |
|
|
|
|
66
|
|
|
case ($point instanceof ReflectionProperty && ($pointcutKind & PointFilter::KIND_PROPERTY)): |
|
|
|
|
67
|
|
|
case ($point instanceof ReflectionClass && ($pointcutKind & PointFilter::KIND_CLASS)): |
|
|
|
|
68
|
|
|
return parent::matchPart($pointcut, $point, $context, $instance, $arguments); |
69
|
|
|
|
70
|
|
|
default: |
71
|
|
|
return false; |
72
|
|
|
} |
73
|
|
|
} |
74
|
|
|
} |
75
|
|
|
|
This error could be the result of:
1. Missing dependencies
PHP Analyzer uses your
composer.json
file (if available) to determine the dependencies of your project and to determine all the available classes and functions. It expects thecomposer.json
to be in the root folder of your repository.Are you sure this class is defined by one of your dependencies, or did you maybe not list a dependency in either the
require
orrequire-dev
section?2. Missing use statement
PHP does not complain about undefined classes in
ìnstanceof
checks. For example, the following PHP code will work perfectly fine:If you have not tested against this specific condition, such errors might go unnoticed.