From dfa021b924db25954447827c5632655e19f7fc1b Mon Sep 17 00:00:00 2001 From: Sven Reichel Date: Mon, 9 Dec 2024 06:29:59 +0100 Subject: [PATCH] Cleanup: removed broken `Mage_Core_Controller_Front_Router` (#4356) * Fix: Mage_Core_Controller_Front_Router::getUrl() * phpstan * removed method * Delete app/code/core/Mage/Core/Controller/Front/Router.php * baseline --------- Co-authored-by: Ng Kiat Siong --- .phpstan.dist.baseline.neon | 10 -- app/Mage.php | 2 +- .../Mage/Core/Controller/Front/Router.php | 102 ------------------ app/code/core/Mage/Core/Model/Store.php | 2 +- 4 files changed, 2 insertions(+), 114 deletions(-) delete mode 100644 app/code/core/Mage/Core/Controller/Front/Router.php diff --git a/.phpstan.dist.baseline.neon b/.phpstan.dist.baseline.neon index 52b6b6edb73..e8097bbbd26 100644 --- a/.phpstan.dist.baseline.neon +++ b/.phpstan.dist.baseline.neon @@ -2535,16 +2535,6 @@ parameters: count: 1 path: app/code/core/Mage/Core/Controller/Front/Action.php - - - message: "#^Call to an undefined method Zend_Controller_Router_Interface\\:\\:addRoute\\(\\)\\.$#" - count: 1 - path: app/code/core/Mage/Core/Controller/Front/Router.php - - - - message: "#^Parameter \\#1 \\$type of static method Mage\\:\\:getBaseUrl\\(\\) expects string, array given\\.$#" - count: 1 - path: app/code/core/Mage/Core/Controller/Front/Router.php - - message: "#^Constructor of class Mage_Core_Controller_Varien_Action has an unused parameter \\$invokeArgs\\.$#" count: 1 diff --git a/app/Mage.php b/app/Mage.php index af8e1224b38..45b394e19cc 100644 --- a/app/Mage.php +++ b/app/Mage.php @@ -444,7 +444,7 @@ public static function getStoreConfigFlag($path, $store = null) /** * Get base URL path by type * - * @param string $type + * @param Mage_Core_Model_Store::URL_TYPE_* $type * @param null|bool $secure * @return string */ diff --git a/app/code/core/Mage/Core/Controller/Front/Router.php b/app/code/core/Mage/Core/Controller/Front/Router.php deleted file mode 100644 index 658b1ea115e..00000000000 --- a/app/code/core/Mage/Core/Controller/Front/Router.php +++ /dev/null @@ -1,102 +0,0 @@ -_config = $config; - } - - /** - * @return Mage_Core_Model_Config_Element - */ - public function getConfig() - { - return $this->_config; - } - - /** - * @return $this - */ - public function addRoutes(Zend_Controller_Router_Interface $router) - { - $frontName = $this->_config->getName(); - $routeMatch = $frontName . '/:controller/:action/*'; - $moduleName = (string)$this->_config->module; - $routeParams = ['module' => $moduleName, 'controller' => 'index', 'action' => 'index', '_frontName' => $frontName]; - $route = new Zend_Controller_Router_Route($routeMatch, $routeParams); - $router->addRoute($moduleName, $route); - - return $this; - } - - /** - * @param array $params - * @return string - */ - public function getUrl($params = []) - { - static $reservedKeys = ['module' => 1, 'controller' => 1, 'action' => 1, 'array' => 1]; - - if (is_string($params)) { - $paramsArr = explode('/', $params); - $params = ['controller' => $paramsArr[0], 'action' => $paramsArr[1]]; - } - - $url = Mage::getBaseUrl($params); - - if (!empty($params['frontName'])) { - $url .= $params['frontName'] . '/'; - } else { - $url .= $this->_config->getName() . '/'; - } - - if (!empty($params)) { - $paramsStr = ''; - foreach ($params as $key => $value) { - if (!isset($reservedKeys[$key]) && $key[0] !== '_' && !empty($value)) { - $paramsStr .= $key . '/' . $value . '/'; - } - } - - if (empty($params['controller']) && !empty($paramsStr)) { - $params['controller'] = 'index'; - } - $url .= empty($params['controller']) ? '' : $params['controller'] . '/'; - - if (empty($params['action']) && !empty($paramsStr)) { - $params['action'] = 'index'; - } - $url .= empty($params['action']) ? '' : $params['action'] . '/'; - - $url .= $paramsStr; - - $url .= empty($params['array']) ? '' : '?' . http_build_query($params['array']); - } - - return $url; - } -} diff --git a/app/code/core/Mage/Core/Model/Store.php b/app/code/core/Mage/Core/Model/Store.php index a04bef08b39..943f41aeee3 100644 --- a/app/code/core/Mage/Core/Model/Store.php +++ b/app/code/core/Mage/Core/Model/Store.php @@ -572,7 +572,7 @@ public function getUrl($route = '', $params = []) /** * Retrieve base URL * - * @param string $type + * @param self::URL_TYPE_* $type * @param bool|null $secure * @return string */