1
|
|
|
<?php |
2
|
|
|
namespace Kambo\Router\Route\Route; |
3
|
|
|
|
4
|
|
|
use Kambo\Router\Route\Route; |
5
|
|
|
|
6
|
|
|
/** |
7
|
|
|
* Parsed route from matcher class. |
8
|
|
|
* Class is implemented as a proxy for existing Route object. |
9
|
|
|
* |
10
|
|
|
* @package Kambo\Router\Route\Route |
11
|
|
|
* @author Bohuslav Simek <[email protected]> |
12
|
|
|
* @license MIT |
13
|
|
|
*/ |
14
|
|
|
class Parsed |
15
|
|
|
{ |
16
|
|
|
/** |
17
|
|
|
* Instance of original route |
18
|
|
|
* |
19
|
|
|
* @var \Kambo\Router\Route\Route |
20
|
|
|
*/ |
21
|
|
|
private $route; |
22
|
|
|
|
23
|
|
|
/** |
24
|
|
|
* Route placeholders from route. |
25
|
|
|
* |
26
|
|
|
* @var array |
27
|
|
|
*/ |
28
|
|
|
private $placeholders; |
29
|
|
|
|
30
|
|
|
/** |
31
|
|
|
* Route parameters from request |
32
|
|
|
* |
33
|
|
|
* @var array |
34
|
|
|
*/ |
35
|
|
|
private $parameters; |
36
|
|
|
|
37
|
|
|
/** |
38
|
|
|
* ParsedRoute constructor |
39
|
|
|
* |
40
|
|
|
* @param \Kambo\Router\Route\Route $route |
41
|
|
|
*/ |
42
|
|
|
public function __construct(/*Route*/ $route) |
43
|
|
|
{ |
44
|
|
|
$this->route = $route; |
45
|
|
|
} |
46
|
|
|
|
47
|
|
|
/** |
48
|
|
|
* Magic method for proxing methods call to parent object. |
49
|
|
|
* |
50
|
|
|
* @param string $name Method name |
51
|
|
|
* @param array $arguments The parameters to be passed to the method, |
52
|
|
|
* as an indexed array. |
53
|
|
|
*/ |
54
|
|
|
public function __call($name, array $arguments) |
55
|
|
|
{ |
56
|
|
|
return call_user_func_array([$this->route, $name], $arguments); |
57
|
|
|
} |
58
|
|
|
|
59
|
|
|
/** |
60
|
|
|
* Get route method |
61
|
|
|
* |
62
|
|
|
* @return string |
63
|
|
|
*/ |
64
|
|
|
public function getMethod() |
65
|
|
|
{ |
66
|
|
|
return $this->route->getMethod(); |
67
|
|
|
} |
68
|
|
|
|
69
|
|
|
/** |
70
|
|
|
* Get handler |
71
|
|
|
* |
72
|
|
|
* @return mixed |
73
|
|
|
*/ |
74
|
|
|
public function getHandler() |
75
|
|
|
{ |
76
|
|
|
return $this->route->getHandler(); |
77
|
|
|
} |
78
|
|
|
|
79
|
|
|
/** |
80
|
|
|
* Sets placeholders extracted from route. |
81
|
|
|
* |
82
|
|
|
* @param mixed $parameters |
|
|
|
|
83
|
|
|
* |
84
|
|
|
* @return self for fluent interface |
85
|
|
|
*/ |
86
|
|
|
public function setPlaceholders($placeholders) |
87
|
|
|
{ |
88
|
|
|
$this->placeholders = $placeholders; |
89
|
|
|
|
90
|
|
|
return $this; |
91
|
|
|
} |
92
|
|
|
|
93
|
|
|
/** |
94
|
|
|
* Get placeholders extracted from route. |
95
|
|
|
* |
96
|
|
|
* @return array |
97
|
|
|
*/ |
98
|
|
|
public function getPlaceholders() |
99
|
|
|
{ |
100
|
|
|
return $this->placeholders; |
101
|
|
|
} |
102
|
|
|
|
103
|
|
|
/** |
104
|
|
|
* Sets parameters for route from request. |
105
|
|
|
* |
106
|
|
|
* @param mixed $parameters |
107
|
|
|
* |
108
|
|
|
* @return self for fluent interface |
109
|
|
|
*/ |
110
|
|
|
public function setParameters($parameters) |
111
|
|
|
{ |
112
|
|
|
$this->parameters = $parameters; |
|
|
|
|
113
|
|
|
|
114
|
|
|
return $this; |
115
|
|
|
} |
116
|
|
|
|
117
|
|
|
/** |
118
|
|
|
* Get parameters of route from request. |
119
|
|
|
* |
120
|
|
|
* @return array |
121
|
|
|
*/ |
122
|
|
|
public function getParameters() |
123
|
|
|
{ |
124
|
|
|
return $this->parameters; |
125
|
|
|
} |
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.