1 | <?php |
||
23 | class Matcher |
||
24 | { |
||
25 | /** |
||
26 | * |
||
27 | * Logging information about which routes were attempted to match. |
||
28 | * |
||
29 | * @var array |
||
30 | * |
||
31 | */ |
||
32 | protected $logger; |
||
33 | |||
34 | /** |
||
35 | * |
||
36 | * The map of all routes. |
||
37 | * |
||
38 | * @var Map |
||
39 | * |
||
40 | */ |
||
41 | protected $map; |
||
42 | |||
43 | /** |
||
44 | * |
||
45 | * A collection of matching rules to iterate through. |
||
46 | * |
||
47 | * @var RuleIterator |
||
48 | * |
||
49 | */ |
||
50 | protected $ruleIterator; |
||
51 | |||
52 | /** |
||
53 | * |
||
54 | * The Route object matched by the router. |
||
55 | * |
||
56 | * @var Route|false |
||
57 | * |
||
58 | */ |
||
59 | protected $matchedRoute; |
||
60 | |||
61 | /** |
||
62 | * |
||
63 | * The first of the closest-matching failed routes. |
||
64 | * |
||
65 | * @var Route |
||
66 | * |
||
67 | */ |
||
68 | protected $failedRoute; |
||
69 | |||
70 | /** |
||
71 | * |
||
72 | * The score of the closest-matching failed route. |
||
73 | * |
||
74 | * @var int |
||
75 | * |
||
76 | */ |
||
77 | protected $failedScore = 0; |
||
78 | |||
79 | /** |
||
80 | * |
||
81 | * Constructor. |
||
82 | * |
||
83 | * @param Map $map A route collection object. |
||
84 | * |
||
85 | * @param LoggerInterface $logger A logger object. |
||
86 | * |
||
87 | * @param RuleIterator $ruleIterator A collection of matching rules. |
||
88 | * |
||
89 | */ |
||
90 | 5 | public function __construct( |
|
99 | |||
100 | /** |
||
101 | * |
||
102 | * Gets a route that matches the request. |
||
103 | * |
||
104 | * @param ServerRequestInterface $request The incoming request. |
||
105 | * |
||
106 | * @return Route|false Returns a route object when it finds a match, or |
||
107 | * boolean false if there is no match. |
||
108 | * |
||
109 | */ |
||
110 | 5 | public function match(ServerRequestInterface $request) |
|
126 | |||
127 | /** |
||
128 | * |
||
129 | * Match a request to a route. |
||
130 | * |
||
131 | * @param ServerRequestInterface $request The request to match against. |
||
132 | * |
||
133 | * @param Route $proto The proto-route to match against. |
||
134 | * |
||
135 | * @param string $name The route name. |
||
136 | * |
||
137 | * @param string $path The request path. |
||
138 | * |
||
139 | * @return mixed False on failure, or a Route on match. |
||
140 | * |
||
141 | */ |
||
142 | 5 | protected function requestRoute($request, $proto, $name, $path) |
|
150 | |||
151 | /** |
||
152 | * |
||
153 | * Does the request match a route per the matching rules? |
||
154 | * |
||
155 | * @param ServerRequestInterface $request The request to match against. |
||
156 | * |
||
157 | * @param Route $route The route to match against. |
||
158 | * |
||
159 | * @param string $name The route name. |
||
160 | * |
||
161 | * @param string $path The request path. |
||
162 | * |
||
163 | * @return mixed False on failure, or a Route on match. |
||
164 | * |
||
165 | */ |
||
166 | 5 | protected function applyRules($request, $route, $name, $path) |
|
177 | |||
178 | /** |
||
179 | * |
||
180 | * A matching rule failed. |
||
181 | * |
||
182 | * @param ServerRequestInterface $request The request to match against. |
||
183 | * |
||
184 | * @param Route $route The route to match against. |
||
185 | * |
||
186 | * @param string $name The route name. |
||
187 | * |
||
188 | * @param string $path The request path. |
||
189 | * |
||
190 | * @param mixed $rule The rule that failed. |
||
191 | * |
||
192 | * @param int $score The failure score. |
||
193 | * |
||
194 | * @return false |
||
195 | * |
||
196 | */ |
||
197 | 4 | protected function ruleFailed($request, $route, $name, $path, $rule, $score) |
|
215 | |||
216 | /** |
||
217 | * |
||
218 | * The route matched. |
||
219 | * |
||
220 | * @param Route $route The route to match against. |
||
221 | * |
||
222 | * @param string $name The route name. |
||
223 | * |
||
224 | * @param string $path The request path. |
||
225 | * |
||
226 | * @return Route |
||
227 | * |
||
228 | */ |
||
229 | 3 | protected function routeMatched($route, $name, $path) |
|
238 | |||
239 | /** |
||
240 | * |
||
241 | * Get the first of the closest-matching failed routes. |
||
242 | * |
||
243 | * @return Route |
||
244 | * |
||
245 | */ |
||
246 | 2 | public function getFailedRoute() |
|
250 | |||
251 | /** |
||
252 | * |
||
253 | * Returns the result of the call to match() again so you don't need to |
||
254 | * run the matching process again. |
||
255 | * |
||
256 | * @return Route|false|null Returns null if match() has not been called |
||
257 | * yet, false if it has and there was no match, or a Route object if there |
||
258 | * was a match. |
||
259 | * |
||
260 | */ |
||
261 | 3 | public function getMatchedRoute() |
|
265 | } |
||
266 |
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..