zendframework / zend-stdlib

Stdlib component from Zend Framework
BSD 3-Clause "New" or "Revised" License
384 stars 76 forks source link

RequestInterface missing getPost #29

Closed boesing closed 9 years ago

boesing commented 9 years ago

As of zend-mvc Zend\Mvc\Controller\AbstractController, you'll get the RequestInterface as a response of AbstractController::getRequest().

Thus will lead to issues on resolving getPost() in Autocompletions. IMHO, getPost method should be required to any RequestInterface implementing class.

Example

class DummyController extends \Zend\Mvc\Controller\AbstractController 
{
    public function dummyAction() 
    {
        $request = $this->getRequest();
        $postValues = $request->getPost();
    }    
}

The getPost method will work, since \Zend\Http\Request implements it. But Autocompletion wont resolve this, since the return value is RequestInterface.

weierophinney commented 9 years ago

This is intentional. Zend\Stdlib\RequestInterface is a general purpose request abstraction, and is used as a base for both the HTTP variant as well as those used in zend-mail and zend-console.

If you want IDE autocompletion, you can always put typehints as comments above the variable:

/* @var \Zend\Http\PhpEnvironment\Request */
$request = $this->getRequest();