99namespace Zend \Router \Http ;
1010
1111use ArrayObject ;
12+ use Psr \Http \Message \ServerRequestInterface as Request ;
1213use Traversable ;
1314use Zend \Router \Exception ;
1415use Zend \Router \PriorityList ;
1516use Zend \Router \RoutePluginManager ;
1617use Zend \Stdlib \ArrayUtils ;
17- use Zend \Stdlib \ RequestInterface as Request ;
18+ use Zend \Router \ RouteMatch as BaseRouteMatch ;
1819
1920/**
2021 * Part route.
@@ -137,15 +138,19 @@ public static function factory($options = [])
137138 * @param array $options
138139 * @return RouteMatch|null
139140 */
140- public function match (Request $ request , $ pathOffset = null , array $ options = [])
141+ public function match (Request $ request , $ pathOffset = null , array $ options = []) : ? BaseRouteMatch
141142 {
142143 if ($ pathOffset === null ) {
143144 $ pathOffset = 0 ;
144145 }
145146
147+ /**
148+ * @var RouteMatch $match
149+ */
146150 $ match = $ this ->route ->match ($ request , $ pathOffset , $ options );
151+ // @TODO deal with RouteMatch that is not from TreeRouteStack. Exception?
147152
148- if ($ match !== null && method_exists ( $ request , ' getUri ' ) ) {
153+ if ($ match !== null ) {
149154 if ($ this ->childRoutes !== null ) {
150155 $ this ->addRoutes ($ this ->childRoutes );
151156 $ this ->childRoutes = null ;
@@ -170,13 +175,15 @@ public function match(Request $request, $pathOffset = null, array $options = [])
170175 foreach ($ this ->routes as $ name => $ route ) {
171176 if (($ subMatch = $ route ->match ($ request , $ nextOffset , $ options )) instanceof RouteMatch) {
172177 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 ;
174181 }
175182 }
176183 }
177184 }
178185
179- return ;
186+ return null ;
180187 }
181188
182189 /**
0 commit comments