public function process(Zend_Controller_Request_Abstract $request)
{
$this->first_name = $this->sanitize($request->getPost('first_name'));
....
}
My question is $request is an instance of class zend_controller_request_abstract, but getpost is a function defined in class zend_controller_request_http which extends zend_controller_request_abstract, so why does $request invoke getPost() directly?
The type hint is just that, a hint. All it states is that
$requestmust extend fromZend_Controller_Request_Abstract. It does not mean that$requestis an instance ofZend_Controller_Request_Abstract.In this particular case,
$requestis an instance ofZend_Controller_Request_Httpwhich does implementgetPost()and so you can call$request->getPost()with no problems.$requestis also an instance of a class that extends fromZend_Controller_Request_Abstractand so PHP allowed it to be passed into theprocessmethod in the first place.