9
9
namespace Zend \Router \Http ;
10
10
11
11
use ArrayObject ;
12
+ use Psr \Http \Message \ServerRequestInterface as Request ;
12
13
use Traversable ;
13
14
use Zend \Router \Exception ;
14
15
use Zend \Router \PriorityList ;
15
16
use Zend \Router \RoutePluginManager ;
16
17
use Zend \Stdlib \ArrayUtils ;
17
- use Zend \Stdlib \ RequestInterface as Request ;
18
+ use Zend \Router \ RouteMatch as BaseRouteMatch ;
18
19
19
20
/**
20
21
* Part route.
@@ -137,15 +138,19 @@ public static function factory($options = [])
137
138
* @param array $options
138
139
* @return RouteMatch|null
139
140
*/
140
- public function match (Request $ request , $ pathOffset = null , array $ options = [])
141
+ public function match (Request $ request , $ pathOffset = null , array $ options = []) : ? BaseRouteMatch
141
142
{
142
143
if ($ pathOffset === null ) {
143
144
$ pathOffset = 0 ;
144
145
}
145
146
147
+ /**
148
+ * @var RouteMatch $match
149
+ */
146
150
$ match = $ this ->route ->match ($ request , $ pathOffset , $ options );
151
+ // @TODO deal with RouteMatch that is not from TreeRouteStack. Exception?
147
152
148
- if ($ match !== null && method_exists ( $ request , ' getUri ' ) ) {
153
+ if ($ match !== null ) {
149
154
if ($ this ->childRoutes !== null ) {
150
155
$ this ->addRoutes ($ this ->childRoutes );
151
156
$ this ->childRoutes = null ;
@@ -170,13 +175,15 @@ public function match(Request $request, $pathOffset = null, array $options = [])
170
175
foreach ($ this ->routes as $ name => $ route ) {
171
176
if (($ subMatch = $ route ->match ($ request , $ nextOffset , $ options )) instanceof RouteMatch) {
172
177
if ($ match ->getLength () + $ subMatch ->getLength () + $ pathOffset === $ pathLength ) {
173
- return $ match ->merge ($ subMatch )->setMatchedRouteName ($ name );
178
+ $ match ->merge ($ subMatch );
179
+ $ match ->setMatchedRouteName ($ name );
180
+ return $ match ;
174
181
}
175
182
}
176
183
}
177
184
}
178
185
179
- return ;
186
+ return null ;
180
187
}
181
188
182
189
/**
0 commit comments