Closed as not planned
Closed as not planned
Description
- Is this related to quality assurance?
When running static analysis against a simple userland controller like:
class MyController extends AbstractActionController
{
public function indexAction()
{
return ['posts' => ['foo', 'bar']];
}
}
That do NOT provide the return type, neither with PHP 7.1 return type nor via DocBlock, tools like PHPstan use inherited docs and report:
Method MyController::indexAction() should return Zend\View\Model\ViewModel but returns array.
Of course users should add return types, but it would result in requiring a massive code update without real benefits, since the default behavior of Zend\Mvc framework is to allow:
null
from\Zend\Mvc\View\Http\CreateViewModelListener::createViewModelFromNull
listenerarray
from\Zend\Mvc\View\Http\CreateViewModelListener::createViewModelFromArray
listenerViewModel
from\Zend\Mvc\View\Http\DefaultRenderingStrategy::render
listenerResponseInterface
from\Zend\Mvc\SendResponseListener::sendResponse
listener
This change only applies to indexAction
since I guess its usage is widespread: notFoundAction
is untouched as users that override it are, IMHO, already advanced ones.
Ping @Ocramius you type lover ❤️
Reference: https://github.com/Slamdunk/phpstan-zend-framework/issues/5
Originally posted by @Slamdunk at zendframework/zend-mvc#312