1 | <?php |
||
12 | class Rule |
||
13 | { |
||
14 | const COMPILED = 'compiled'; |
||
15 | const DIRTY = 'dirty'; |
||
16 | |||
17 | /** |
||
18 | * Rule status (compiled or dirty) |
||
19 | * @var string |
||
20 | */ |
||
21 | private $state; |
||
22 | |||
23 | /** |
||
24 | * Expression collection with allow / disallow segments |
||
25 | * @var array |
||
26 | */ |
||
27 | private $exp = [ |
||
28 | 'allow' => [], |
||
29 | 'disallow' => [] |
||
30 | ]; |
||
31 | |||
32 | /** |
||
33 | * Compiled regex pattern with allow / disallow segments |
||
34 | * @var array |
||
35 | */ |
||
36 | private $patterns = [ |
||
37 | 'allow' => '', |
||
38 | 'disallow' => '' |
||
39 | ]; |
||
40 | |||
41 | /** |
||
42 | * Add a pattern to match in the current rule by allowing |
||
43 | * @param string $pattern |
||
44 | * @return Rule |
||
45 | */ |
||
46 | 3 | public function allow($pattern) |
|
47 | { |
||
48 | 3 | return $this->addExpression(new Expression($pattern), 'allow'); |
|
49 | } |
||
50 | |||
51 | /** |
||
52 | * Add a pattern to match in the current rule by disallowing |
||
53 | * @param string $pattern |
||
54 | * @return Rule |
||
55 | */ |
||
56 | 3 | public function disallow($pattern) |
|
60 | |||
61 | /** |
||
62 | * Add an expression in the current rule |
||
63 | * @param string $pattern Expression raw pattern |
||
|
|||
64 | * @param string $mode Expression mode (allow / disallow) |
||
65 | * @return Expression |
||
66 | */ |
||
67 | 3 | private function addExpression(Expression $exp, $mode) |
|
73 | |||
74 | /** |
||
75 | * Compile expressions to a global pattern |
||
76 | * @return boolean |
||
77 | */ |
||
78 | 3 | public function compile() |
|
94 | |||
95 | /** |
||
96 | * Check if the URL is allowed or not |
||
97 | * @param string $url |
||
98 | * @return boolean |
||
99 | */ |
||
100 | 3 | public function match($url) |
|
116 | |||
117 | /** |
||
118 | * Retrieve the last filled index in a given array |
||
119 | * @param array $data |
||
120 | * @return integer |
||
121 | */ |
||
122 | 1 | private function lastFilledIndex(array $data) |
|
126 | } |
||
127 |
This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.
Consider the following example. The parameter
$italy
is not defined by the methodfinale(...)
.The most likely cause is that the parameter was removed, but the annotation was not.