Cannot use object of type yii\web\Response as array

hello,

we recently updated to v 2.0.10 and are now getting the error


Cannot use object of type yii\web\Response as array

when using the response object to redirect from the main UrlRule class. The error points to yii2/web/Request.php and the resolve() method specifically,


public function resolve()

{

     $result = Yii::$app->getUrlManager()->parseRequest($this);

     if ($result !== false) {

         list ($route, $params) = $result;  // THIS LINE IS HIGHLIGHTED AS AN ERROR...

         if ($this->_queryParams === null) {

             $_GET = $params + $_GET; // preserve numeric keys

         } else {

             $this->_queryParams = $params + $this->_queryParams;

         }

         return [$route, $this->getQueryParams()];

     } else {

         throw new NotFoundHttpException(Yii::t('yii', 'Page not found.'));

     }

}

Reverting back to the older version of Yii2 and the code performs as expected.

the parseRequest method of UrlRule class looks something like the following…


public function parseRequest($manager, $request)

{

   // Logic logic logic...




   if ($some_condition) {

      return Yii::$app->getResponse()->redirect($some_url, 301);

   }


   return false; //this rule does not apply


}

does anyone have any insights or suggestions?

edited to add…

Tracing through the method Response::redirect() suggests that it completes successfully and calls setStatusCode().

2nd edit to add…

the redirect works fine, so just exit at the point; problem solved…

i suspect we were returning the result of the redirect to ensure the parseRequest method didn’t fall through and return false.