diff --git a/library/Zend/Controller/Action.php b/library/Zend/Controller/Action.php index d8be954bce..93dda60d60 100644 --- a/library/Zend/Controller/Action.php +++ b/library/Zend/Controller/Action.php @@ -43,15 +43,15 @@ abstract class Zend_Controller_Action implements Zend_Controller_Action_Interface { /** - * @var array of existing class methods + * @var array|null array of existing class methods */ - protected $_classMethods; + protected $_classMethods = null; /** * Word delimiters (used for normalizing view script paths) - * @var array + * @var array|null */ - protected $_delimiters; + protected $_delimiters = null; /** * Array of arguments provided to the constructor, minus the @@ -93,9 +93,9 @@ abstract class Zend_Controller_Action implements Zend_Controller_Action_Interfac /** * Compatibility for php 8.2 to stop error Deprecated: Creation of dynamic property - * @var object + * @var object|null */ - public $contexts = null; + public $contexts = null; /** * Helper Broker to assist in routing help requests to the proper object @@ -166,7 +166,7 @@ public function init() * @return Zend_View_Interface * @throws Zend_Controller_Exception if base view directory does not exist */ - public function initView() + public function initView(): Zend_View_Interface { if (!$this->getInvokeArg('noViewRenderer') && $this->_helper->hasHelper('viewRenderer')) { return $this->view; @@ -206,16 +206,18 @@ public function initView() * By default, the rendered contents are appended to the response. You may * specify the named body content segment to set by specifying a $name. * - * @see Zend_Controller_Response_Abstract::appendBody() - * @param string|null $action Defaults to action registered in request object - * @param string|null $name Response object named path segment to use; defaults to null - * @param bool $noController Defaults to false; i.e. use controller name as subdir in which to search for view script + * @param string|null $action Defaults to action registered in request object + * @param string|null $name Response object named path segment to use; defaults to null + * @param bool $noController Defaults to false; i.e. use controller name as subdir in which to search for view script * @return void + * @throws Zend_Controller_Exception + * @see Zend_Controller_Response_Abstract::appendBody() */ - public function render($action = null, $name = null, $noController = false) + public function render(?string $action = null, ?string $name = null, bool $noController = false): void { if (!$this->getInvokeArg('noViewRenderer') && $this->_helper->hasHelper('viewRenderer')) { - return $this->_helper->viewRenderer->render($action, $name, $noController); + $this->_helper->viewRenderer->render($action, $name, $noController); + return; } $view = $this->initView(); @@ -239,14 +241,15 @@ public function render($action = null, $name = null, $noController = false) * By default, the rendered contents are appended to the response. You may * specify the named body content segment to set by specifying a $name. * - * @param string $script - * @param string $name + * @param string $script + * @param string|null $name * @return void + * @throws Zend_Controller_Exception */ - public function renderScript($script, $name = null) + public function renderScript(string $script, string $name = null): void { if (!$this->getInvokeArg('noViewRenderer') && $this->_helper->hasHelper('viewRenderer')) { - return $this->_helper->viewRenderer->renderScript($script, $name); + $this->_helper->viewRenderer->renderScript($script, $name); } $view = $this->initView(); @@ -261,12 +264,12 @@ public function renderScript($script, $name = null) * * Used by render() to determine the path to the view script. * - * @param string $action Defaults to action registered in request object - * @param bool $noController Defaults to false; i.e. use controller name as subdir in which to search for view script + * @param string|null $action Defaults to action registered in request object + * @param bool|null $noController Defaults to false; i.e. use controller name as subdir in which to search for view script * @return string * @throws Zend_Controller_Exception with bad $action */ - public function getViewScript($action = null, $noController = null) + public function getViewScript(?string $action = null, ?bool $noController = null): string { if (!$this->getInvokeArg('noViewRenderer') && $this->_helper->hasHelper('viewRenderer')) { $viewRenderer = $this->_helper->getHelper('viewRenderer'); @@ -279,6 +282,7 @@ public function getViewScript($action = null, $noController = null) $request = $this->getRequest(); if (null === $action) { $action = $request->getActionName(); + } elseif (!is_string($action)) { require_once 'Zend/Controller/Exception.php'; throw new Zend_Controller_Exception('Invalid action specifier for view render'); @@ -306,9 +310,9 @@ public function getViewScript($action = null, $noController = null) /** * Return the Request object * - * @return Zend_Controller_Request_Abstract + * @return Zend_Controller_Request_Abstract|null */ - public function getRequest() + public function getRequest(): ?Zend_Controller_Request_Abstract { return $this->_request; } @@ -319,7 +323,7 @@ public function getRequest() * @param Zend_Controller_Request_Abstract $request * @return $this */ - public function setRequest(Zend_Controller_Request_Abstract $request) + public function setRequest(Zend_Controller_Request_Abstract $request): Zend_Controller_Action { $this->_request = $request; return $this; @@ -328,9 +332,9 @@ public function setRequest(Zend_Controller_Request_Abstract $request) /** * Return the Response object * - * @return Zend_Controller_Response_Abstract + * @return Zend_Controller_Response_Abstract|null */ - public function getResponse() + public function getResponse(): ?Zend_Controller_Response_Abstract { return $this->_response; } @@ -341,7 +345,7 @@ public function getResponse() * @param Zend_Controller_Response_Abstract $response * @return $this */ - public function setResponse(Zend_Controller_Response_Abstract $response) + public function setResponse(Zend_Controller_Response_Abstract $response): Zend_Controller_Action { $this->_response = $response; return $this; @@ -353,7 +357,7 @@ public function setResponse(Zend_Controller_Response_Abstract $response) * @param array $args * @return $this */ - protected function _setInvokeArgs(array $args = []) + protected function _setInvokeArgs(array $args = []): Zend_Controller_Action { $this->_invokeArgs = $args; return $this; @@ -364,7 +368,7 @@ protected function _setInvokeArgs(array $args = []) * * @return array */ - public function getInvokeArgs() + public function getInvokeArgs(): array { return $this->_invokeArgs; } @@ -375,7 +379,7 @@ public function getInvokeArgs() * @param string $key * @return mixed */ - public function getInvokeArg($key) + public function getInvokeArg(string $key) { if (isset($this->_invokeArgs[$key])) { return $this->_invokeArgs[$key]; @@ -387,10 +391,10 @@ public function getInvokeArg($key) /** * Get a helper by name * - * @param string $helperName + * @param string $helperName * @return Zend_Controller_Action_Helper_Abstract */ - public function getHelper($helperName) + public function getHelper(string $helperName): Zend_Controller_Action_Helper_Abstract { return $this->_helper->{$helperName}; } @@ -398,10 +402,10 @@ public function getHelper($helperName) /** * Get a clone of a helper by name * - * @param string $helperName + * @param string $helperName * @return Zend_Controller_Action_Helper_Abstract */ - public function getHelperCopy($helperName) + public function getHelperCopy(string $helperName): Zend_Controller_Action_Helper_Abstract { return clone $this->_helper->{$helperName}; } @@ -412,7 +416,7 @@ public function getHelperCopy($helperName) * @param Zend_Controller_Front $front * @return $this */ - public function setFrontController(Zend_Controller_Front $front) + public function setFrontController(Zend_Controller_Front $front): Zend_Controller_Action { $this->_frontController = $front; return $this; @@ -422,8 +426,9 @@ public function setFrontController(Zend_Controller_Front $front) * Retrieve Front Controller * * @return Zend_Controller_Front + * @throws Zend_Controller_Exception */ - public function getFrontController() + public function getFrontController(): Zend_Controller_Front { // Used cache version if found if (null !== $this->_frontController) { @@ -478,12 +483,12 @@ public function postDispatch() * overridden to implement magic (dynamic) actions, or provide run-time * dispatching. * - * @param string $methodName - * @param array $args + * @param string $methodName + * @param array $args * @return void * @throws Zend_Controller_Action_Exception */ - public function __call($methodName, $args) + public function __call(string $methodName, array $args) { require_once 'Zend/Controller/Action/Exception.php'; if ('Action' == substr($methodName, -6)) { @@ -499,8 +504,9 @@ public function __call($methodName, $args) * * @param string $action Method name of action * @return void + * @throws Zend_Controller_Action_Exception */ - public function dispatch($action) + public function dispatch($action): void { // Notify helpers of action preDispatch state $this->_helper->notifyPreDispatch(); @@ -551,8 +557,9 @@ public function dispatch($action) * @param null|Zend_Controller_Response_Abstract $response Optional response * object to use * @return Zend_Controller_Response_Abstract + * @throws Zend_Controller_Action_Exception */ - public function run(Zend_Controller_Request_Abstract $request = null, Zend_Controller_Response_Abstract $response = null) + public function run(Zend_Controller_Request_Abstract $request = null, Zend_Controller_Response_Abstract $response = null): Zend_Controller_Response_Abstract { if (null !== $request) { $this->setRequest($request); @@ -587,7 +594,7 @@ public function run(Zend_Controller_Request_Abstract $request = null, Zend_Contr * @param mixed $default * @return mixed */ - protected function _getParam($paramName, $default = null) + protected function _getParam(string $paramName, $default = null) { return $this->getParam($paramName, $default); } @@ -603,7 +610,7 @@ protected function _getParam($paramName, $default = null) * @param mixed $default * @return mixed */ - public function getParam($paramName, $default = null) + public function getParam(string $paramName, $default = null) { $value = $this->getRequest()->getParam($paramName); if ((null === $value || '' === $value) && (null !== $default)) { @@ -622,7 +629,7 @@ public function getParam($paramName, $default = null) * @deprecated Deprecated as of Zend Framework 1.7. Use * setParam() instead. */ - protected function _setParam($paramName, $value) + protected function _setParam(string $paramName, $value): Zend_Controller_Action { return $this->setParam($paramName, $value); } @@ -634,7 +641,7 @@ protected function _setParam($paramName, $value) * @param mixed $value * @return $this */ - public function setParam($paramName, $value) + public function setParam(string $paramName, $value): Zend_Controller_Action { $this->getRequest()->setParam($paramName, $value); @@ -650,7 +657,7 @@ public function setParam($paramName, $value) * @deprecated Deprecated as of Zend Framework 1.7. Use * hasParam() instead. */ - protected function _hasParam($paramName) + protected function _hasParam(string $paramName): bool { return $this->hasParam($paramName); } @@ -662,7 +669,7 @@ protected function _hasParam($paramName) * @param string $paramName * @return boolean */ - public function hasParam($paramName) + public function hasParam(string $paramName): bool { return null !== $this->getRequest()->getParam($paramName); } @@ -675,7 +682,7 @@ public function hasParam($paramName) * @deprecated Deprecated as of Zend Framework 1.7. Use * getAllParams() instead. */ - protected function _getAllParams() + protected function _getAllParams(): array { return $this->getAllParams(); } @@ -686,7 +693,7 @@ protected function _getAllParams() * * @return array */ - public function getAllParams() + public function getAllParams(): array { return $this->getRequest()->getParams(); } @@ -713,14 +720,14 @@ public function getAllParams() * simply pass null values for them before specifying the parameters. * * @param string $action - * @param string $controller - * @param string $module - * @param array $params + * @param string|null $controller + * @param string|null $module + * @param array|null $params * @return void * @deprecated Deprecated as of Zend Framework 1.7. Use * forward() instead. */ - final protected function _forward($action, $controller = null, $module = null, array $params = null) + final protected function _forward(string $action, ?string $controller = null, ?string $module = null, array $params = null): void { $this->forward($action, $controller, $module, $params); } @@ -746,12 +753,12 @@ final protected function _forward($action, $controller = null, $module = null, a * simply pass null values for them before specifying the parameters. * * @param string $action - * @param string $controller - * @param string $module - * @param array $params + * @param string|null $controller + * @param string|null $module + * @param array|null $params * @return void */ - final public function forward($action, $controller = null, $module = null, array $params = null) + final public function forward(string $action, ?string $controller = null, ?string $module = null, array $params = null): void { $request = $this->getRequest(); @@ -783,7 +790,7 @@ final public function forward($action, $controller = null, $module = null, array * @deprecated Deprecated as of Zend Framework 1.7. Use * redirect() instead. */ - protected function _redirect($url, array $options = []) + protected function _redirect(string $url, array $options = []): void { $this->redirect($url, $options); } @@ -797,7 +804,7 @@ protected function _redirect($url, array $options = []) * @param array $options Options to be used when redirecting * @return void */ - public function redirect($url, array $options = []) + public function redirect(string $url, array $options = []): void { $this->_helper->redirector->gotoUrl($url, $options); } diff --git a/library/Zend/Session/SaveHandler/DbTable.php b/library/Zend/Session/SaveHandler/DbTable.php index 0efdbc08f4..437d021bd9 100644 --- a/library/Zend/Session/SaveHandler/DbTable.php +++ b/library/Zend/Session/SaveHandler/DbTable.php @@ -73,35 +73,35 @@ class Zend_Session_SaveHandler_DbTable /** * Session table primary key value assignment * - * @var array + * @var array|null */ protected $_primaryAssignment = null; /** * Session table last modification time column * - * @var string + * @var string|null */ protected $_modifiedColumn = null; /** * Session table lifetime column * - * @var string + * @var string|null */ protected $_lifetimeColumn = null; /** * Session table data column * - * @var string + * @var string|null */ protected $_dataColumn = null; /** * Session lifetime * - * @var int + * @var int|false */ protected $_lifetime = false; @@ -223,11 +223,11 @@ public function __destruct() * $lifetime === false resets lifetime to session.gc_maxlifetime * * @param int $lifetime - * @param boolean $overrideLifetime (optional) - * @return $this + * @param boolean|null $overrideLifetime (optional) + * @return Zend_Session_SaveHandler_DbTable * @throws Zend_Session_SaveHandler_Exception */ - public function setLifetime($lifetime, $overrideLifetime = null) + public function setLifetime(int $lifetime, ?bool $overrideLifetime = null): Zend_Session_SaveHandler_DbTable { if ($lifetime < 0) { /** @@ -240,7 +240,7 @@ public function setLifetime($lifetime, $overrideLifetime = null) if (empty($lifetime)) { $this->_lifetime = (int) ini_get('session.gc_maxlifetime'); } else { - $this->_lifetime = (int) $lifetime; + $this->_lifetime = $lifetime; } if ($overrideLifetime != null) { @@ -253,7 +253,7 @@ public function setLifetime($lifetime, $overrideLifetime = null) /** * Retrieve session lifetime * - * @return int + * @return bool|int */ public function getLifetime() { @@ -264,11 +264,11 @@ public function getLifetime() * Set whether or not the lifetime of an existing session should be overridden * * @param boolean $overrideLifetime - * @return $this + * @return Zend_Session_SaveHandler_DbTable */ - public function setOverrideLifetime($overrideLifetime) + public function setOverrideLifetime(bool $overrideLifetime): Zend_Session_SaveHandler_DbTable { - $this->_overrideLifetime = (boolean) $overrideLifetime; + $this->_overrideLifetime = $overrideLifetime; return $this; } @@ -278,7 +278,7 @@ public function setOverrideLifetime($overrideLifetime) * * @return boolean */ - public function getOverrideLifetime() + public function getOverrideLifetime(): bool { return $this->_overrideLifetime; } @@ -290,7 +290,7 @@ public function getOverrideLifetime() * @param string $name * @return boolean */ - public function open($save_path, $name) + public function open($save_path, $name): bool { $this->_sessionSavePath = $save_path; $this->_sessionName = $name; @@ -303,7 +303,7 @@ public function open($save_path, $name) * * @return boolean */ - public function close() + public function close(): bool { return true; } @@ -313,8 +313,9 @@ public function close() * * @param string $id * @return string + * @throws Zend_Db_Table_Exception */ - public function read($id) + public function read($id): string { $return = ''; @@ -337,8 +338,9 @@ public function read($id) * @param string $id * @param string $data * @return boolean + * @throws Zend_Db_Table_Exception */ - public function write($id, $data) + public function write($id, $data): bool { $data = [$this->_modifiedColumn => time(), $this->_dataColumn => (string) $data]; @@ -365,8 +367,9 @@ public function write($id, $data) * * @param string $id * @return boolean + * @throws Zend_Db_Table_Exception */ - public function destroy($id) + public function destroy($id): bool { $this->delete($this->_getPrimary($id, self::PRIMARY_TYPE_WHERECLAUSE)); return true; //always return true, since if nothing can be deleted, it is already deleted and thats OK. @@ -378,7 +381,7 @@ public function destroy($id) * @param int $maxlifetime * @return true */ - public function gc($maxlifetime) + public function gc($maxlifetime): bool { $this->delete($this->getAdapter()->quoteIdentifier($this->_modifiedColumn, true) . ' + ' . $this->getAdapter()->quoteIdentifier($this->_lifetimeColumn, true) . ' < ' @@ -391,8 +394,9 @@ public function gc($maxlifetime) * Calls other protected methods for individual setup tasks and requirement checks * * @return void + * @throws Zend_Session_SaveHandler_Exception */ - protected function _setup() + protected function _setup(): void { parent::_setup(); @@ -408,7 +412,7 @@ protected function _setup() * @return void * @throws Zend_Session_SaveHandler_Exception */ - protected function _setupTableName() + protected function _setupTableName(): void { if (empty($this->_name) && basename(($this->_name = session_save_path())) != $this->_name) { /** @@ -420,7 +424,7 @@ protected function _setupTableName() } if (strpos($this->_name, '.')) { - list($this->_schema, $this->_name) = explode('.', $this->_name); + [$this->_schema, $this->_name] = explode('.', $this->_name); } } @@ -430,7 +434,7 @@ protected function _setupTableName() * @return void * @throws Zend_Session_SaveHandler_Exception */ - protected function _setupPrimaryAssignment() + protected function _setupPrimaryAssignment(): void { if ($this->_primaryAssignment === null) { $this->_primaryAssignment = [1 => self::PRIMARY_ASSIGNMENT_SESSION_ID]; @@ -469,7 +473,7 @@ protected function _setupPrimaryAssignment() * @return void * @throws Zend_Session_SaveHandler_Exception */ - protected function _checkRequiredColumns() + protected function _checkRequiredColumns(): void { if ($this->_modifiedColumn === null) { /** @@ -505,10 +509,11 @@ protected function _checkRequiredColumns() * Retrieve session table primary key values * * @param string $id - * @param string $type (optional; default: self::PRIMARY_TYPE_NUM) + * @param string|null $type (optional; default: self::PRIMARY_TYPE_NUM) * @return array + * @throws Zend_Db_Table_Exception */ - protected function _getPrimary($id, $type = null) + protected function _getPrimary(string $id, ?string $type = null): array { $this->_setupPrimaryKey(); @@ -527,7 +532,7 @@ protected function _getPrimary($id, $type = null) $value = $this->_sessionName; break; case self::PRIMARY_ASSIGNMENT_SESSION_ID: - $value = (string) $id; + $value = $id; break; default: $value = (string) $this->_primaryAssignment[$index]; @@ -561,7 +566,7 @@ protected function _getPrimary($id, $type = null) * @param Zend_Db_Table_Row_Abstract $row * @return int */ - protected function _getLifetime(Zend_Db_Table_Row_Abstract $row) + protected function _getLifetime(Zend_Db_Table_Row_Abstract $row): int { $return = $this->_lifetime; @@ -578,7 +583,7 @@ protected function _getLifetime(Zend_Db_Table_Row_Abstract $row) * @param Zend_Db_Table_Row_Abstract $row * @return int */ - protected function _getExpirationTime(Zend_Db_Table_Row_Abstract $row) + protected function _getExpirationTime(Zend_Db_Table_Row_Abstract $row): int { return (int) $row->{$this->_modifiedColumn} + $this->_getLifetime($row); }