1 | <?php |
||
11 | class Route |
||
12 | { |
||
13 | /** |
||
14 | * @var string $name a name for this route. |
||
15 | * @var string $info description of route. |
||
16 | * @var array $method the method(s) to support |
||
17 | * @var string $methodMatched the matched method. |
||
18 | * @var string $mount where to mount the path |
||
19 | * @var string $path the path rule for this route |
||
20 | * @var callable $handler the callback to handle this route |
||
21 | * @var null|array $arguments arguments for the callback, extracted |
||
22 | * from path |
||
23 | */ |
||
24 | private $name; |
||
25 | private $info; |
||
26 | private $method; |
||
27 | private $methodMatched; |
||
28 | private $mount; |
||
29 | private $path; |
||
30 | private $handler; |
||
31 | private $arguments = []; |
||
32 | |||
33 | |||
34 | |||
35 | /** |
||
36 | * Set values for route. |
||
37 | * |
||
38 | * @param string|array $method as request method to support |
||
39 | * @param string $mount where to mount the path |
||
40 | * @param string $path for this route |
||
41 | * @param string|array|callable $handler for this path, callable or equal |
||
42 | * @param string $info description of the route |
||
43 | * |
||
44 | * @return $this |
||
45 | */ |
||
46 | 136 | public function set( |
|
68 | |||
69 | |||
70 | |||
71 | /** |
||
72 | * Check if the route matches a query and request method. |
||
73 | * |
||
74 | * @param string $query to match against |
||
75 | * @param string $method as request method |
||
76 | * |
||
77 | * @return boolean true if query matches the route |
||
78 | */ |
||
79 | 122 | public function match(string $query, string $method = null) |
|
96 | |||
97 | |||
98 | |||
99 | /** |
||
100 | * Handle the action for the route. |
||
101 | * |
||
102 | * @param string $path the matched path |
||
103 | * @param ContainerInjectableInterface $di container with services |
||
104 | * |
||
105 | * @return mixed |
||
106 | */ |
||
107 | 110 | public function handle( |
|
122 | |||
123 | |||
124 | |||
125 | /** |
||
126 | * Set the name of the route. |
||
127 | * |
||
128 | * @param string $name set a name for the route |
||
129 | * |
||
130 | * @return $this |
||
131 | */ |
||
132 | 1 | public function setName($name) |
|
137 | |||
138 | |||
139 | |||
140 | /** |
||
141 | * Get information of the route. |
||
142 | * |
||
143 | * @return null|string as route information. |
||
144 | */ |
||
145 | 2 | public function getInfo() |
|
149 | |||
150 | |||
151 | |||
152 | /** |
||
153 | * Get the path for the route. |
||
154 | * |
||
155 | * @return string |
||
156 | */ |
||
157 | 1 | public function getPath() |
|
161 | |||
162 | |||
163 | |||
164 | /** |
||
165 | * Get the absolute $path by adding $mount. |
||
166 | * |
||
167 | * @return string|null as absolute path for this route. |
||
168 | */ |
||
169 | 122 | public function getAbsolutePath() |
|
181 | |||
182 | |||
183 | |||
184 | /** |
||
185 | * Get the request method for the route. |
||
186 | * |
||
187 | * @return string representing the request method supported |
||
188 | */ |
||
189 | 1 | public function getRequestMethod() |
|
193 | } |
||
194 |
If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check:
If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue.