diff --git a/src/app/code/core/Mage/Cms/Controller/Router.php b/src/app/code/core/Mage/Cms/Controller/Router.php index 0219515..d9fa6ab 100644 --- a/src/app/code/core/Mage/Cms/Controller/Router.php +++ b/src/app/code/core/Mage/Cms/Controller/Router.php @@ -39,6 +39,8 @@ public function initControllerRouters($observer) * * @param Zend_Controller_Request_Http $request * @return bool + * + * @SuppressWarnings(PHPMD.ExitExpression) */ public function match(Zend_Controller_Request_Http $request) { diff --git a/src/app/code/core/Mage/Cms/Helper/Page.php b/src/app/code/core/Mage/Cms/Helper/Page.php index c76a8a5..1106703 100644 --- a/src/app/code/core/Mage/Cms/Helper/Page.php +++ b/src/app/code/core/Mage/Cms/Helper/Page.php @@ -48,6 +48,10 @@ public function renderPage(Mage_Core_Controller_Front_Action $action, $pageId = * @param string $pageId * @param bool $renderLayout * @return bool + * + * @SuppressWarnings(PHPMD.BooleanArgumentFlag) + * @SuppressWarnings(PHPMD.CyclomaticComplexity) + * @SuppressWarnings(PHPMD.NPathComplexity) */ protected function _renderPage(Mage_Core_Controller_Varien_Action $action, $pageId = null, $renderLayout = true) { @@ -137,6 +141,8 @@ protected function _renderPage(Mage_Core_Controller_Varien_Action $action, $pag * @param string $pageId * @param bool $renderLayout * @return bool + * + * @SuppressWarnings(PHPMD.BooleanArgumentFlag) */ public function renderPageExtended(Mage_Core_Controller_Varien_Action $action, $pageId = null, $renderLayout = true) { diff --git a/src/app/code/core/Mage/Cms/Helper/Wysiwyg/Images.php b/src/app/code/core/Mage/Cms/Helper/Wysiwyg/Images.php index be198da..a157c25 100644 --- a/src/app/code/core/Mage/Cms/Helper/Wysiwyg/Images.php +++ b/src/app/code/core/Mage/Cms/Helper/Wysiwyg/Images.php @@ -115,12 +115,12 @@ public function convertPathToId($path) /** * Decode HTML element id * - * @param string $id + * @param string $elementId * @return string */ - public function convertIdToPath($id) + public function convertIdToPath($elementId) { - $path = $this->idDecode($id); + $path = $this->idDecode($elementId); $storageRoot = realpath($this->getStorageRoot()); if (!strstr($path, $storageRoot)) { $path = $storageRoot . DS . $path; @@ -134,6 +134,8 @@ public function convertIdToPath($id) * @param string $path Original path * @param bool $trim Trim slashes or not * @return string + * + * @SuppressWarnings(PHPMD.BooleanArgumentFlag) */ public function correctPath($path, $trim = true) { @@ -177,6 +179,8 @@ public function isUsingStaticUrlsAllowed() * @param string $filename Filename transferred via Ajax * @param bool $renderAsTag Leave image HTML as is or transform it to controller directive * @return string + * + * @SuppressWarnings(PHPMD.BooleanArgumentFlag) */ public function getImageHtmlDeclaration($filename, $renderAsTag = false) { @@ -214,11 +218,11 @@ public function getCurrentPath() $currentPath = $path; } } - $io = new Varien_Io_File(); - if (!$io->isWriteable($currentPath) && !$io->mkdir($currentPath)) { + $file = new Varien_Io_File(); + if (!$file->isWriteable($currentPath) && !$file->mkdir($currentPath)) { $message = Mage::helper('cms')->__( 'The directory %s is not writable by server.', - $io->getFilteredPath($currentPath) + $file->getFilteredPath($currentPath) ); Mage::throwException($message); } diff --git a/src/app/code/core/Mage/Cms/Model/Page.php b/src/app/code/core/Mage/Cms/Model/Page.php index a9e0b67..d84cf83 100644 --- a/src/app/code/core/Mage/Cms/Model/Page.php +++ b/src/app/code/core/Mage/Cms/Model/Page.php @@ -72,10 +72,10 @@ class Mage_Cms_Model_Page extends Mage_Core_Model_Abstract /** * Page's Statuses */ - public const STATUS_ENABLED = 1; + public const STATUS_ENABLED = 1; public const STATUS_DISABLED = 0; - public const CACHE_TAG = 'cms_page'; + public const CACHE_TAG = 'cms_page'; protected $_cacheTag = 'cms_page'; /** @@ -93,12 +93,12 @@ protected function _construct() /** * @inheritDoc */ - public function load($id, $field = null) + public function load($value, $field = null) { - if (is_null($id)) { + if (is_null($value)) { return $this->noRoutePage(); } - return parent::load($id, $field); + return parent::load($value, $field); } /** diff --git a/src/app/code/core/Mage/Cms/Model/Resource/Block.php b/src/app/code/core/Mage/Cms/Model/Resource/Block.php index f3ca4f8..5115c34 100644 --- a/src/app/code/core/Mage/Cms/Model/Resource/Block.php +++ b/src/app/code/core/Mage/Cms/Model/Resource/Block.php @@ -159,6 +159,8 @@ protected function _getLoadSelect($field, $value, $object) * * @param Mage_Core_Model_Abstract $object * @return bool + * + * @SuppressWarnings(PHPMD.BooleanGetMethodName) */ public function getIsUniqueBlockToStores(Mage_Core_Model_Abstract $object) { @@ -191,10 +193,10 @@ public function getIsUniqueBlockToStores(Mage_Core_Model_Abstract $object) /** * Get store ids to which specified item is assigned * - * @param int $id + * @param int $blockId * @return array */ - public function lookupStoreIds($id) + public function lookupStoreIds($blockId) { $adapter = $this->_getReadAdapter(); @@ -203,7 +205,7 @@ public function lookupStoreIds($id) ->where('block_id = :block_id'); $binds = [ - ':block_id' => (int) $id + ':block_id' => (int) $blockId ]; return $adapter->fetchCol($select, $binds); diff --git a/src/app/code/core/Mage/Cms/Model/Resource/Block/Collection.php b/src/app/code/core/Mage/Cms/Model/Resource/Block/Collection.php index 2cab27d..680369a 100644 --- a/src/app/code/core/Mage/Cms/Model/Resource/Block/Collection.php +++ b/src/app/code/core/Mage/Cms/Model/Resource/Block/Collection.php @@ -47,6 +47,8 @@ public function toOptionArray() * @param int|Mage_Core_Model_Store $store * @param bool $withAdmin * @return $this + * + * @SuppressWarnings(PHPMD.BooleanArgumentFlag) */ public function addStoreFilter($store, $withAdmin = true) { diff --git a/src/app/code/core/Mage/Cms/Model/Resource/Page.php b/src/app/code/core/Mage/Cms/Model/Resource/Page.php index 4bc973e..e651ff7 100644 --- a/src/app/code/core/Mage/Cms/Model/Resource/Page.php +++ b/src/app/code/core/Mage/Cms/Model/Resource/Page.php @@ -215,6 +215,8 @@ protected function _getLoadByIdentifierSelect($identifier, $store, $isActive = n * * @param Mage_Core_Model_Abstract|Mage_Cms_Model_Page $object * @return bool + * + * @SuppressWarnings(PHPMD.BooleanGetMethodName) */ public function getIsUniquePageToStores(Mage_Core_Model_Abstract $object) { @@ -306,10 +308,10 @@ public function getCmsPageTitleByIdentifier($identifier) /** * Retrieves cms page title from DB by passed id. * - * @param string $id + * @param string $pageId * @return string */ - public function getCmsPageTitleById($id) + public function getCmsPageTitleById($pageId) { $adapter = $this->_getReadAdapter(); @@ -318,7 +320,7 @@ public function getCmsPageTitleById($id) ->where('page_id = :page_id'); $binds = [ - 'page_id' => (int) $id + 'page_id' => (int) $pageId ]; return $adapter->fetchOne($select, $binds); @@ -327,10 +329,10 @@ public function getCmsPageTitleById($id) /** * Retrieves cms page identifier from DB by passed id. * - * @param string $id + * @param string $pageId * @return string|false */ - public function getCmsPageIdentifierById($id) + public function getCmsPageIdentifierById($pageId) { $adapter = $this->_getReadAdapter(); @@ -339,7 +341,7 @@ public function getCmsPageIdentifierById($id) ->where('page_id = :page_id'); $binds = [ - 'page_id' => (int) $id + 'page_id' => (int) $pageId ]; return $adapter->fetchOne($select, $binds); diff --git a/src/app/code/core/Mage/Cms/Model/Resource/Page/Collection.php b/src/app/code/core/Mage/Cms/Model/Resource/Page/Collection.php index d8a85cd..f4530a2 100644 --- a/src/app/code/core/Mage/Cms/Model/Resource/Page/Collection.php +++ b/src/app/code/core/Mage/Cms/Model/Resource/Page/Collection.php @@ -62,6 +62,7 @@ public function toOptionIdArray() foreach ($this as $item) { $identifier = $item->getData('identifier'); + $data = []; $data['value'] = $identifier; $data['label'] = $item->getData('title'); @@ -82,6 +83,8 @@ public function toOptionIdArray() * * @param bool $flag * @return $this + * + * @SuppressWarnings(PHPMD.BooleanArgumentFlag) */ public function setFirstStoreFlag($flag = false) { @@ -131,6 +134,8 @@ protected function _afterLoad() * @param int|Mage_Core_Model_Store $store * @param bool $withAdmin * @return $this + * + * @SuppressWarnings(PHPMD.BooleanArgumentFlag) */ public function addStoreFilter($store, $withAdmin = true) { diff --git a/src/app/code/core/Mage/Cms/Model/Wysiwyg/Images/Storage.php b/src/app/code/core/Mage/Cms/Model/Wysiwyg/Images/Storage.php index f4088e0..6c8b6ce 100644 --- a/src/app/code/core/Mage/Cms/Model/Wysiwyg/Images/Storage.php +++ b/src/app/code/core/Mage/Cms/Model/Wysiwyg/Images/Storage.php @@ -18,6 +18,8 @@ * * @category Mage * @package Mage_Cms + * + * @SuppressWarnings(PHPMD.ExcessiveClassComplexity) */ class Mage_Cms_Model_Wysiwyg_Images_Storage extends Varien_Object { @@ -44,6 +46,9 @@ class Mage_Cms_Model_Wysiwyg_Images_Storage extends Varien_Object * * @param string $path Parent directory path * @return Varien_Data_Collection_Filesystem + * + * @SuppressWarnings(PHPMD.CyclomaticComplexity) + * @SuppressWarnings(PHPMD.NPathComplexity) */ public function getDirsCollection($path) { @@ -190,8 +195,8 @@ public function createDirectory($name, $path) Mage::throwException(Mage::helper('cms')->__('A directory with the same name already exists. Please try another folder name.')); } - $io = new Varien_Io_File(); - if ($io->mkdir($newPath)) { + $file = new Varien_Io_File(); + if ($file->mkdir($newPath)) { if (Mage::helper('core/file_storage_database')->checkDbUsage()) { $relativePath = Mage::helper('core/file_storage_database')->getMediaRelativePath($newPath); Mage::getModel('core/file_storage_directory_database')->createRecursive($relativePath); @@ -218,12 +223,12 @@ public function deleteDirectory($path) $rootCmp = rtrim($this->getHelper()->getStorageRoot(), DS); $pathCmp = rtrim($path, DS); - $io = new Varien_Io_File(); + $file = new Varien_Io_File(); if ($rootCmp == $pathCmp) { Mage::throwException(Mage::helper('cms')->__( 'Cannot delete root directory %s.', - $io->getFilteredPath($path) + $file->getFilteredPath($path) )); } if (str_contains($pathCmp, chr(0)) @@ -235,12 +240,12 @@ public function deleteDirectory($path) if (Mage::helper('core/file_storage_database')->checkDbUsage()) { Mage::getModel('core/file_storage_directory_database')->deleteDirectory($path); } - if (!$io->rmdir($path, true)) { - Mage::throwException(Mage::helper('cms')->__('Cannot delete directory %s.', $io->getFilteredPath($path))); + if (!$file->rmdir($path, true)) { + Mage::throwException(Mage::helper('cms')->__('Cannot delete directory %s.', $file->getFilteredPath($path))); } if (str_starts_with($pathCmp, $rootCmp)) { - $io->rmdir($this->getThumbnailRoot() . DS . ltrim(substr($pathCmp, strlen($rootCmp)), '\\/'), true); + $file->rmdir($this->getThumbnailRoot() . DS . ltrim(substr($pathCmp, strlen($rootCmp)), '\\/'), true); } } @@ -252,13 +257,13 @@ public function deleteDirectory($path) */ public function deleteFile($target) { - $io = new Varien_Io_File(); - $io->rm($target); + $file = new Varien_Io_File(); + $file->rm($target); Mage::helper('core/file_storage_database')->deleteFile($target); $thumb = $this->getThumbnailPath($target, true); if ($thumb) { - $io->rm($thumb); + $file->rm($thumb); Mage::helper('core/file_storage_database')->deleteFile($thumb); } return $this; @@ -311,9 +316,11 @@ public function uploadFile($targetPath, $type = null) /** * Thumbnail path getter * - * @param string $filePath original file path + * @param string $filePath original file path * @param bool $checkFile OPTIONAL is it necessary to check file availability * @return string | false + * + * @SuppressWarnings(PHPMD.BooleanArgumentFlag) */ public function getThumbnailPath($filePath, $checkFile = false) { @@ -333,9 +340,11 @@ public function getThumbnailPath($filePath, $checkFile = false) /** * Thumbnail URL getter * - * @param string $filePath original file path + * @param string $filePath original file path * @param bool $checkFile OPTIONAL is it necessary to check file availability * @return string|false + * + * @SuppressWarnings(PHPMD.BooleanArgumentFlag) */ public function getThumbnailUrl($filePath, $checkFile = false) { @@ -358,6 +367,8 @@ public function getThumbnailUrl($filePath, $checkFile = false) * @param string $source Image path to be resized * @param bool $keepRation Keep aspect ratio or not * @return bool|string Resized filepath or false if errors were occurred + * + * @SuppressWarnings(PHPMD.BooleanArgumentFlag) */ public function resizeFile($source, $keepRation = true) { @@ -366,11 +377,11 @@ public function resizeFile($source, $keepRation = true) } $targetDir = $this->getThumbsPath($source); - $io = new Varien_Io_File(); - if (!$io->isWriteable($targetDir)) { - $io->mkdir($targetDir); + $file = new Varien_Io_File(); + if (!$file->isWriteable($targetDir)) { + $file->mkdir($targetDir); } - if (!$io->isWriteable($targetDir)) { + if (!$file->isWriteable($targetDir)) { return false; } $image = Varien_Image_Adapter::factory('GD2'); @@ -414,6 +425,8 @@ public function resizeOnTheFly($filename) * * @param false|string $filePath Path to the file * @return string + * + * @SuppressWarnings(PHPMD.BooleanArgumentFlag) */ public function getThumbsPath($filePath = false) { @@ -480,6 +493,8 @@ public function getConfigAsArray() * @param string $key * @param mixed $default * @return mixed + * + * @SuppressWarnings(PHPMD.BooleanArgumentFlag) */ public function getConfigData($key, $default = false) { diff --git a/src/app/code/core/Mage/Cms/controllers/IndexController.php b/src/app/code/core/Mage/Cms/controllers/IndexController.php index 2472c01..bda2994 100644 --- a/src/app/code/core/Mage/Cms/controllers/IndexController.php +++ b/src/app/code/core/Mage/Cms/controllers/IndexController.php @@ -25,6 +25,8 @@ class Mage_Cms_IndexController extends Mage_Core_Controller_Front_Action * Renders CMS Home page * * @param string $coreRoute + * + * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ public function indexAction($coreRoute = null) { @@ -52,6 +54,8 @@ public function defaultIndexAction() * Render CMS 404 Not found page * * @param string $coreRoute + * + * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ public function noRouteAction($coreRoute = null) {