From 250eb1f623b862338d171e4aeedc78088b8ff69f Mon Sep 17 00:00:00 2001
From: sv3n 
Date: Tue, 2 Aug 2022 15:29:07 +0200
Subject: [PATCH 01/38] Merge PR #2342
---
 .github/phpstan-baseline.neon                 | 35 -----------
 .../Adminhtml/Block/Notification/Window.php   |  4 +-
 .../core/Mage/Adminhtml/Controller/Action.php | 15 ++++-
 .../Adminhtml/Controller/Sales/Creditmemo.php | 17 ++---
 .../Adminhtml/Controller/Sales/Invoice.php    | 19 +++---
 .../Adminhtml/Controller/Sales/Shipment.php   | 19 +++---
 .../Adminhtml/controllers/AjaxController.php  |  2 +-
 .../controllers/Api/RoleController.php        | 14 ++---
 .../controllers/Api/UserController.php        | 17 +++--
 .../Adminhtml/controllers/CacheController.php | 16 ++---
 .../Catalog/Category/WidgetController.php     | 16 ++---
 .../Catalog/CategoryController.php            | 18 +++---
 .../Product/Action/AttributeController.php    | 12 ++--
 .../Catalog/Product/AttributeController.php   | 11 ++--
 .../Catalog/Product/DatafeedsController.php   |  5 +-
 .../Catalog/Product/GalleryController.php     | 11 ++--
 .../Catalog/Product/GroupController.php       | 11 ++--
 .../Catalog/Product/ReviewController.php      |  7 ++-
 .../Catalog/Product/SetController.php         | 14 ++---
 .../Catalog/Product/WidgetController.php      | 16 ++---
 .../controllers/Catalog/ProductController.php | 22 +++----
 .../controllers/Catalog/SearchController.php  | 14 ++---
 .../controllers/CatalogController.php         | 11 ++--
 .../Checkout/AgreementController.php          | 13 ++--
 .../Cms/Block/WidgetController.php            | 16 ++---
 .../controllers/Cms/BlockController.php       | 18 +++---
 .../controllers/Cms/Page/WidgetController.php | 18 ++----
 .../controllers/Cms/PageController.php        |  9 +--
 .../Cms/Wysiwyg/ImagesController.php          | 21 +++----
 .../controllers/Cms/WysiwygController.php     | 16 ++---
 .../Cart/Product/Composite/CartController.php | 16 ++---
 .../controllers/Customer/ConfigController.php | 11 ++--
 .../controllers/Customer/GroupController.php  | 15 ++---
 .../controllers/Customer/OnlineController.php | 11 ++--
 .../System/Config/ValidatevatController.php   | 16 ++---
 .../Product/Composite/WishlistController.php  | 16 ++---
 .../controllers/CustomerController.php        | 13 ++--
 .../controllers/DashboardController.php       | 14 ++---
 .../Adminhtml/controllers/IndexController.php |  2 +-
 .../Adminhtml/controllers/JsonController.php  |  4 +-
 .../controllers/Media/EditorController.php    | 12 ++--
 .../controllers/Media/UploaderController.php  | 10 +--
 .../Newsletter/ProblemController.php          | 11 ++--
 .../Newsletter/QueueController.php            | 11 ++--
 .../Newsletter/SubscriberController.php       | 10 +--
 .../Newsletter/TemplateController.php         |  2 +-
 .../controllers/NotificationController.php    | 13 ++--
 .../Permissions/BlockController.php           | 18 +++---
 .../Permissions/RoleController.php            | 17 ++---
 .../Permissions/UserController.php            | 17 +++--
 .../Permissions/VariableController.php        | 21 +++----
 .../controllers/Poll/AnswerController.php     | 12 ++--
 .../Adminhtml/controllers/PollController.php  | 11 ++--
 .../controllers/Promo/CatalogController.php   | 13 ++--
 .../controllers/Promo/QuoteController.php     | 19 +++---
 .../controllers/Promo/WidgetController.php    | 12 ++--
 .../Adminhtml/controllers/PromoController.php | 11 ++--
 .../controllers/RatingController.php          | 13 ++--
 .../controllers/Report/CustomerController.php |  7 +--
 .../controllers/Report/ProductController.php  | 20 +-----
 .../controllers/Report/ReviewController.php   |  6 +-
 .../controllers/Report/SalesController.php    | 11 +---
 .../controllers/Report/ShopcartController.php |  7 +--
 .../Report/StatisticsController.php           | 15 ++---
 .../controllers/Report/TagController.php      | 11 ++--
 .../controllers/ReportController.php          | 62 +------------------
 .../controllers/Rss/CatalogController.php     |  4 +-
 .../controllers/Rss/OrderController.php       | 15 ++---
 .../Sales/Billing/AgreementController.php     | 11 +---
 .../Sales/Order/CreateController.php          |  4 +-
 .../Sales/Order/EditController.php            | 16 ++---
 .../Sales/Order/StatusController.php          | 17 ++---
 .../Order/View/GiftmessageController.php      | 18 ++----
 .../controllers/Sales/OrderController.php     |  6 +-
 .../Sales/Recurring/ProfileController.php     | 20 +++---
 .../Sales/TransactionsController.php          |  5 +-
 .../Adminhtml/controllers/SalesController.php | 11 ++--
 .../controllers/SitemapController.php         | 18 +++---
 .../controllers/System/AccountController.php  | 11 ++--
 .../controllers/System/BackupController.php   |  6 +-
 .../controllers/System/CacheController.php    | 11 ++--
 .../Config/System/StorageController.php       | 16 ++---
 .../controllers/System/ConfigController.php   | 18 +++---
 .../System/Convert/GuiController.php          | 11 ++--
 .../System/Convert/ProfileController.php      | 15 ++---
 .../controllers/System/CurrencyController.php | 11 ++--
 .../controllers/System/DesignController.php   | 14 ++---
 .../System/Email/TemplateController.php       | 18 +++---
 .../controllers/System/StoreController.php    | 19 +++---
 .../controllers/System/VariableController.php | 22 ++-----
 .../controllers/SystemController.php          | 11 ++--
 .../Adminhtml/controllers/TagController.php   |  6 +-
 .../Tax/Class/CustomerController.php          | 20 ++----
 .../Tax/Class/ProductController.php           | 23 +++----
 .../controllers/Tax/ClassController.php       |  4 +-
 .../controllers/Tax/RateController.php        |  7 +--
 .../controllers/Tax/RuleController.php        | 18 +++---
 .../Adminhtml/controllers/TaxController.php   |  2 +-
 .../controllers/UrlrewriteController.php      | 16 ++---
 .../Adminhtml/Api2/AttributeController.php    | 18 +++---
 .../Adminhtml/Api2/RoleController.php         |  6 +-
 .../Adminhtml/Bundle/SelectionController.php  | 15 ++---
 .../Adminhtml/RefreshController.php           |  2 -
 .../Adminhtml/Centinel/IndexController.php    | 18 +++---
 .../System/CurrencysymbolController.php       | 16 ++---
 .../Adminhtml/Downloadable/FileController.php | 15 ++---
 .../controllers/FileController.php            |  2 +-
 .../controllers/Product/EditController.php    |  2 +-
 .../Adminhtml/ExportController.php            | 16 ++---
 .../Adminhtml/ImportController.php            | 16 ++---
 .../Adminhtml/ProcessController.php           | 16 ++---
 .../Adminhtml/Oauth/Admin/TokenController.php |  4 +-
 .../Adminhtml/Oauth/AuthorizeController.php   |  2 +-
 .../Oauth/AuthorizedTokensController.php      |  4 +-
 .../Adminhtml/Oauth/ConsumerController.php    |  4 +-
 .../Authorizenet/PaymentController.php        | 15 ++---
 .../Adminhtml/Paypal/ReportsController.php    |  6 +-
 .../Rss/controllers/CatalogController.php     |  2 +-
 .../Mage/Rss/controllers/OrderController.php  |  2 +-
 .../Adminhtml/Widget/InstanceController.php   | 18 +++---
 .../Adminhtml/WidgetController.php            | 16 ++---
 121 files changed, 612 insertions(+), 954 deletions(-)
diff --git a/.github/phpstan-baseline.neon b/.github/phpstan-baseline.neon
index 62f99763d63..ee1e5c6e6f2 100644
--- a/.github/phpstan-baseline.neon
+++ b/.github/phpstan-baseline.neon
@@ -510,11 +510,6 @@ parameters:
 			count: 1
 			path: ../app/code/core/Mage/Adminhtml/Block/Notification/Window.php
 
-		-
-			message: "#^PHPDoc tag @param references unknown parameter\\: \\$resourcePath$#"
-			count: 1
-			path: ../app/code/core/Mage/Adminhtml/Block/Notification/Window.php
-
 		-
 			message: "#^Method Mage_Adminhtml_Block_Page\\:\\:getLang\\(\\) has invalid return type unknown\\.$#"
 			count: 1
@@ -1660,26 +1655,6 @@ parameters:
 			count: 1
 			path: ../app/code/core/Mage/Adminhtml/controllers/Cms/PageController.php
 
-		-
-			message: "#^Call to method _saveSessionCurrentPath\\(\\) on an unknown class Mage_Adminhtml_Cms_Page_Wysiwyg_ImagesController\\.$#"
-			count: 1
-			path: ../app/code/core/Mage/Adminhtml/controllers/Cms/Wysiwyg/ImagesController.php
-
-		-
-			message: "#^Call to method loadLayout\\(\\) on an unknown class Mage_Adminhtml_Cms_Page_Wysiwyg_ImagesController\\.$#"
-			count: 1
-			path: ../app/code/core/Mage/Adminhtml/controllers/Cms/Wysiwyg/ImagesController.php
-
-		-
-			message: "#^Method Mage_Adminhtml_Cms_Wysiwyg_ImagesController\\:\\:_initAction\\(\\) has invalid return type Mage_Adminhtml_Cms_Page_Wysiwyg_ImagesController\\.$#"
-			count: 1
-			path: ../app/code/core/Mage/Adminhtml/controllers/Cms/Wysiwyg/ImagesController.php
-
-		-
-			message: "#^Method Mage_Adminhtml_Cms_Wysiwyg_ImagesController\\:\\:_saveSessionCurrentPath\\(\\) has invalid return type Mage_Adminhtml_Cms_Page_Wysiwyg_ImagesController\\.$#"
-			count: 1
-			path: ../app/code/core/Mage/Adminhtml/controllers/Cms/Wysiwyg/ImagesController.php
-
 		-
 			message: "#^Method Mage_Adminhtml_CustomerController\\:\\:cartAction\\(\\) should return string but return statement is missing\\.$#"
 			count: 1
@@ -1695,11 +1670,6 @@ parameters:
 			count: 1
 			path: ../app/code/core/Mage/Adminhtml/controllers/IndexController.php
 
-		-
-			message: "#^Method Mage_Adminhtml_JsonController\\:\\:countryRegionAction\\(\\) should return string but return statement is missing\\.$#"
-			count: 1
-			path: ../app/code/core/Mage/Adminhtml/controllers/JsonController.php
-
 		-
 			message: "#^Variable \\$id in isset\\(\\) always exists and is not nullable\\.$#"
 			count: 1
@@ -2490,11 +2460,6 @@ parameters:
 			count: 1
 			path: ../app/code/core/Mage/Captcha/controllers/Adminhtml/RefreshController.php
 
-		-
-			message: "#^Method Mage_Captcha_Adminhtml_RefreshController\\:\\:refreshAction\\(\\) should return null but return statement is missing\\.$#"
-			count: 1
-			path: ../app/code/core/Mage/Captcha/controllers/Adminhtml/RefreshController.php
-
 		-
 			message: "#^Call to an undefined method Mage_Captcha_Model_Interface\\:\\:getImgSrc\\(\\)\\.$#"
 			count: 1
diff --git a/app/code/core/Mage/Adminhtml/Block/Notification/Window.php b/app/code/core/Mage/Adminhtml/Block/Notification/Window.php
index 7bfa2cd2115..7fe7fc5f24e 100644
--- a/app/code/core/Mage/Adminhtml/Block/Notification/Window.php
+++ b/app/code/core/Mage/Adminhtml/Block/Notification/Window.php
@@ -168,7 +168,6 @@ public function getSeverityText()
     /**
      * Check if current block allowed in ACL
      *
-     * @param string $resourcePath
      * @return bool
      */
     protected function _isAllowed()
@@ -176,8 +175,7 @@ protected function _isAllowed()
         if (!is_null($this->_aclResourcePath)) {
             return Mage::getSingleton('admin/session')
                 ->isAllowed('admin/system/adminnotification/show_toolbar');
-        }
-        else {
+        } else {
             return true;
         }
     }
diff --git a/app/code/core/Mage/Adminhtml/Controller/Action.php b/app/code/core/Mage/Adminhtml/Controller/Action.php
index c208b79c175..80a4658e7aa 100644
--- a/app/code/core/Mage/Adminhtml/Controller/Action.php
+++ b/app/code/core/Mage/Adminhtml/Controller/Action.php
@@ -43,6 +43,12 @@ class Mage_Adminhtml_Controller_Action extends Mage_Core_Controller_Varien_Actio
      */
     const SESSION_NAMESPACE = 'adminhtml';
 
+    /**
+     * ACL resource
+     * @see Mage_Adminhtml_Controller_Action::_isAllowed()
+     */
+    const ADMIN_RESOURCE = 'admin';
+
     /**
      * Array of actions which can be processed without secret key validation
      *
@@ -76,9 +82,14 @@ class Mage_Adminhtml_Controller_Action extends Mage_Core_Controller_Varien_Actio
      */
     protected $_sessionNamespace = self::SESSION_NAMESPACE;
 
+    /**
+     * Check current user permission on resource and privilege
+     *
+     * @return bool
+     */
     protected function _isAllowed()
     {
-        return Mage::getSingleton('admin/session')->isAllowed('admin');
+        return Mage::getSingleton('admin/session')->isAllowed(static::ADMIN_RESOURCE);
     }
 
     /**
@@ -143,7 +154,7 @@ protected function _addJs(Mage_Core_Block_Abstract $block)
     }
 
     /**
-     * Controller predispatch method
+     * Controller pre-dispatch method
      *
      * @return $this
      */
diff --git a/app/code/core/Mage/Adminhtml/Controller/Sales/Creditmemo.php b/app/code/core/Mage/Adminhtml/Controller/Sales/Creditmemo.php
index 41715a19837..0186185b60e 100644
--- a/app/code/core/Mage/Adminhtml/Controller/Sales/Creditmemo.php
+++ b/app/code/core/Mage/Adminhtml/Controller/Sales/Creditmemo.php
@@ -31,6 +31,12 @@
  */
 class Mage_Adminhtml_Controller_Sales_Creditmemo extends Mage_Adminhtml_Controller_Action
 {
+    /**
+     * ACL resource
+     * @see Mage_Adminhtml_Controller_Action::_isAllowed()
+     */
+    const ADMIN_RESOURCE = 'sales/creditmemo';
+
     /**
      * Additional initialization
      *
@@ -99,7 +105,8 @@ public function emailAction()
         }
     }
 
-    public function pdfcreditmemosAction(){
+    public function pdfcreditmemosAction()
+    {
         $creditmemosIds = $this->getRequest()->getPost('creditmemo_ids');
         if (!empty($creditmemosIds)) {
             $invoices = Mage::getResourceModel('sales/order_creditmemo_collection')
@@ -123,14 +130,8 @@ public function printAction()
                 $this->_prepareDownloadResponse('creditmemo'.Mage::getSingleton('core/date')->date('Y-m-d_H-i-s').
                     '.pdf', $pdf->render(), 'application/pdf');
             }
-        }
-        else {
+        } else {
             $this->_forward('noRoute');
         }
     }
-
-    protected function _isAllowed()
-    {
-        return Mage::getSingleton('admin/session')->isAllowed('sales/creditmemo');
-    }
 }
diff --git a/app/code/core/Mage/Adminhtml/Controller/Sales/Invoice.php b/app/code/core/Mage/Adminhtml/Controller/Sales/Invoice.php
index 080af164fa3..4cb131f90dd 100644
--- a/app/code/core/Mage/Adminhtml/Controller/Sales/Invoice.php
+++ b/app/code/core/Mage/Adminhtml/Controller/Sales/Invoice.php
@@ -31,9 +31,14 @@
  */
 class Mage_Adminhtml_Controller_Sales_Invoice extends Mage_Adminhtml_Controller_Action
 {
+    /**
+     * ACL resource
+     * @see Mage_Adminhtml_Controller_Action::_isAllowed()
+     */
+    const ADMIN_RESOURCE = 'sales/invoice';
+
     /**
      * Additional initialization
-     *
      */
     protected function _construct()
     {
@@ -120,13 +125,13 @@ public function printAction()
                 $this->_prepareDownloadResponse('invoice'.Mage::getSingleton('core/date')->date('Y-m-d_H-i-s').
                     '.pdf', $pdf->render(), 'application/pdf');
             }
-        }
-        else {
+        } else {
             $this->_forward('noRoute');
         }
     }
 
-    public function pdfinvoicesAction(){
+    public function pdfinvoicesAction()
+    {
         $invoicesIds = $this->getRequest()->getPost('invoice_ids');
         if (!empty($invoicesIds)) {
             $invoices = Mage::getResourceModel('sales/order_invoice_collection')
@@ -140,10 +145,4 @@ public function pdfinvoicesAction(){
         }
         $this->_redirect('*/*/');
     }
-
-    protected function _isAllowed()
-    {
-        return Mage::getSingleton('admin/session')->isAllowed('sales/invoice');
-    }
-
 }
diff --git a/app/code/core/Mage/Adminhtml/Controller/Sales/Shipment.php b/app/code/core/Mage/Adminhtml/Controller/Sales/Shipment.php
index a0b2708ec5d..f07d22e0549 100644
--- a/app/code/core/Mage/Adminhtml/Controller/Sales/Shipment.php
+++ b/app/code/core/Mage/Adminhtml/Controller/Sales/Shipment.php
@@ -31,9 +31,14 @@
  */
 class Mage_Adminhtml_Controller_Sales_Shipment extends Mage_Adminhtml_Controller_Action
 {
+    /**
+     * ACL resource
+     * @see Mage_Adminhtml_Controller_Action::_isAllowed()
+     */
+    const ADMIN_RESOURCE = 'sales/shipment';
+
     /**
      * Additional initialization
-     *
      */
     protected function _construct()
     {
@@ -78,7 +83,8 @@ public function viewAction()
         }
     }
 
-    public function pdfshipmentsAction(){
+    public function pdfshipmentsAction()
+    {
         $shipmentIds = $this->getRequest()->getPost('shipment_ids');
         if (!empty($shipmentIds)) {
             $shipments = Mage::getResourceModel('sales/order_shipment_collection')
@@ -92,7 +98,6 @@ public function pdfshipmentsAction(){
         $this->_redirect('*/*/');
     }
 
-
     public function printAction()
     {
         /** @see Mage_Adminhtml_Sales_Order_InvoiceController */
@@ -101,14 +106,8 @@ public function printAction()
                 $pdf = Mage::getModel('sales/order_pdf_shipment')->getPdf(array($shipment));
                 $this->_prepareDownloadResponse('packingslip'.Mage::getSingleton('core/date')->date('Y-m-d_H-i-s').'.pdf', $pdf->render(), 'application/pdf');
             }
-        }
-        else {
+        } else {
             $this->_forward('noRoute');
         }
     }
-
-    protected function _isAllowed()
-    {
-        return Mage::getSingleton('admin/session')->isAllowed('sales/shipment');
-    }
 }
diff --git a/app/code/core/Mage/Adminhtml/controllers/AjaxController.php b/app/code/core/Mage/Adminhtml/controllers/AjaxController.php
index 5068942a1de..a01ee7ff59d 100644
--- a/app/code/core/Mage/Adminhtml/controllers/AjaxController.php
+++ b/app/code/core/Mage/Adminhtml/controllers/AjaxController.php
@@ -56,7 +56,7 @@ public function translateAction()
     /**
      * Check is allowed access to action
      *
-     * @return bool
+     * @return true
      */
     protected function _isAllowed()
     {
diff --git a/app/code/core/Mage/Adminhtml/controllers/Api/RoleController.php b/app/code/core/Mage/Adminhtml/controllers/Api/RoleController.php
index d257be97ff2..e5fca47a3e5 100644
--- a/app/code/core/Mage/Adminhtml/controllers/Api/RoleController.php
+++ b/app/code/core/Mage/Adminhtml/controllers/Api/RoleController.php
@@ -34,7 +34,13 @@
 class Mage_Adminhtml_Api_RoleController extends Mage_Adminhtml_Controller_Action
 {
     /**
-     * Controller predispatch method
+     * ACL resource
+     * @see Mage_Adminhtml_Controller_Action::_isAllowed()
+     */
+    const ADMIN_RESOURCE = 'system/api/roles';
+
+    /**
+     * Controller pre-dispatch method
      *
      * @return Mage_Adminhtml_Controller_Action
      */
@@ -205,7 +211,6 @@ public function saveRoleAction()
             Mage::getSingleton('adminhtml/session')->addError($this->__('An error occurred while saving this role.'));
         }
 
-        //$this->getResponse()->setRedirect($this->getUrl("*/*/editrole/rid/$rid"));
         $this->_redirect('*/*/editrole', array('rid' => $rid));
         return;
     }
@@ -241,9 +246,4 @@ protected function _addUserToRole($userId, $roleId)
             return true;
         }
     }
-
-    protected function _isAllowed()
-    {
-        return Mage::getSingleton('admin/session')->isAllowed('system/api/roles');
-    }
 }
diff --git a/app/code/core/Mage/Adminhtml/controllers/Api/UserController.php b/app/code/core/Mage/Adminhtml/controllers/Api/UserController.php
index a6c14f412e6..b2c74c98f10 100644
--- a/app/code/core/Mage/Adminhtml/controllers/Api/UserController.php
+++ b/app/code/core/Mage/Adminhtml/controllers/Api/UserController.php
@@ -26,7 +26,13 @@
 class Mage_Adminhtml_Api_UserController extends Mage_Adminhtml_Controller_Action
 {
     /**
-     * Controller predispatch method
+     * ACL resource
+     * @see Mage_Adminhtml_Controller_Action::_isAllowed()
+     */
+    const ADMIN_RESOURCE = 'system/api/users';
+
+    /**
+     * Controller pre-dispatch method
      *
      * @return Mage_Adminhtml_Controller_Action
      */
@@ -233,13 +239,6 @@ public function roleGridAction()
         $this->getResponse()
             ->setBody($this->getLayout()
             ->createBlock('adminhtml/api_user_grid')
-            ->toHtml()
-        );
+            ->toHtml());
     }
-
-    protected function _isAllowed()
-    {
-        return Mage::getSingleton('admin/session')->isAllowed('system/api/users');
-    }
-
 }
diff --git a/app/code/core/Mage/Adminhtml/controllers/CacheController.php b/app/code/core/Mage/Adminhtml/controllers/CacheController.php
index 68426f70355..92fd301c575 100644
--- a/app/code/core/Mage/Adminhtml/controllers/CacheController.php
+++ b/app/code/core/Mage/Adminhtml/controllers/CacheController.php
@@ -26,6 +26,12 @@
 
 class Mage_Adminhtml_CacheController extends Mage_Adminhtml_Controller_Action
 {
+    /**
+     * ACL resource
+     * @see Mage_Adminhtml_Controller_Action::_isAllowed()
+     */
+    const ADMIN_RESOURCE = 'system/cache';
+
     /**
      * Retrieve session model
      *
@@ -206,14 +212,4 @@ public function cleanSwatchesAction()
         }
         $this->_redirect('*/*');
     }
-
-    /**
-     * Check if cache management is allowed
-     *
-     * @return bool
-     */
-    protected function _isAllowed()
-    {
-        return Mage::getSingleton('admin/session')->isAllowed('system/cache');
-    }
 }
diff --git a/app/code/core/Mage/Adminhtml/controllers/Catalog/Category/WidgetController.php b/app/code/core/Mage/Adminhtml/controllers/Catalog/Category/WidgetController.php
index 68a861d8ac7..bb82ecdc607 100644
--- a/app/code/core/Mage/Adminhtml/controllers/Catalog/Category/WidgetController.php
+++ b/app/code/core/Mage/Adminhtml/controllers/Catalog/Category/WidgetController.php
@@ -34,6 +34,12 @@
  */
 class Mage_Adminhtml_Catalog_Category_WidgetController extends Mage_Adminhtml_Controller_Action
 {
+    /**
+     * ACL resource
+     * @see Mage_Adminhtml_Controller_Action::_isAllowed()
+     */
+    const ADMIN_RESOURCE = 'cms/widget_instance';
+
     /**
      * Chooser Source action
      */
@@ -69,14 +75,4 @@ protected function _getCategoryTreeBlock()
             'use_massaction' => $this->getRequest()->getParam('use_massaction', false)
         ));
     }
-
-    /**
-     * Check is allowed access to action
-     *
-     * @return bool
-     */
-    protected function _isAllowed()
-    {
-        return Mage::getSingleton('admin/session')->isAllowed('cms/widget_instance');
-    }
 }
diff --git a/app/code/core/Mage/Adminhtml/controllers/Catalog/CategoryController.php b/app/code/core/Mage/Adminhtml/controllers/Catalog/CategoryController.php
index 28e21ba0bd9..13568a23b95 100644
--- a/app/code/core/Mage/Adminhtml/controllers/Catalog/CategoryController.php
+++ b/app/code/core/Mage/Adminhtml/controllers/Catalog/CategoryController.php
@@ -33,6 +33,12 @@
  */
 class Mage_Adminhtml_Catalog_CategoryController extends Mage_Adminhtml_Controller_Action
 {
+    /**
+     * ACL resource
+     * @see Mage_Adminhtml_Controller_Action::_isAllowed()
+     */
+    const ADMIN_RESOURCE = 'catalog/categories';
+
     /**
      * Initialize requested category and put it into registry.
      * Root category can be returned, if inappropriate store/category is specified
@@ -500,17 +506,7 @@ public function refreshPathAction()
     }
 
     /**
-     * Check if admin has permissions to visit related pages
-     *
-     * @return boolean
-     */
-    protected function _isAllowed()
-    {
-        return Mage::getSingleton('admin/session')->isAllowed('catalog/categories');
-    }
-
-    /**
-     * Controller predispatch method
+     * Controller pre-dispatch method
      *
      * @return Mage_Adminhtml_Controller_Action
      */
diff --git a/app/code/core/Mage/Adminhtml/controllers/Catalog/Product/Action/AttributeController.php b/app/code/core/Mage/Adminhtml/controllers/Catalog/Product/Action/AttributeController.php
index f438bee523e..5a418c81491 100644
--- a/app/code/core/Mage/Adminhtml/controllers/Catalog/Product/Action/AttributeController.php
+++ b/app/code/core/Mage/Adminhtml/controllers/Catalog/Product/Action/AttributeController.php
@@ -34,6 +34,11 @@
  */
 class Mage_Adminhtml_Catalog_Product_Action_AttributeController extends Mage_Adminhtml_Controller_Action
 {
+    /**
+     * ACL resource
+     * @see Mage_Adminhtml_Controller_Action::_isAllowed()
+     */
+    const ADMIN_RESOURCE = 'catalog/update_attributes';
 
     protected function _construct()
     {
@@ -222,7 +227,7 @@ protected function _validateProducts()
     }
 
     /**
-     * Rertive data manipulation helper
+     * Retrieve data manipulation helper
      *
      * @return Mage_Adminhtml_Helper_Catalog_Product_Edit_Action_Attribute
      */
@@ -231,11 +236,6 @@ protected function _getHelper()
         return Mage::helper('adminhtml/catalog_product_edit_action_attribute');
     }
 
-    protected function _isAllowed()
-    {
-        return Mage::getSingleton('admin/session')->isAllowed('catalog/update_attributes');
-    }
-
     /**
      * Attributes validation action
      *
diff --git a/app/code/core/Mage/Adminhtml/controllers/Catalog/Product/AttributeController.php b/app/code/core/Mage/Adminhtml/controllers/Catalog/Product/AttributeController.php
index 984e4c75705..73ffe381b2a 100644
--- a/app/code/core/Mage/Adminhtml/controllers/Catalog/Product/AttributeController.php
+++ b/app/code/core/Mage/Adminhtml/controllers/Catalog/Product/AttributeController.php
@@ -38,6 +38,12 @@ class Mage_Adminhtml_Catalog_Product_AttributeController extends Mage_Adminhtml_
     protected $_entityTypeId;
 
     /**
+     * ACL resource
+     * @see Mage_Adminhtml_Controller_Action::_isAllowed()
+     */
+    const ADMIN_RESOURCE = 'catalog/attributes/attributes';
+
+/**
      * List of tags from setting
      */
     const XML_PATH_ALLOWED_TAGS = 'system/catalog/frontend/allowed_html_tags_list';
@@ -371,9 +377,4 @@ public function deleteAction()
             Mage::helper('catalog')->__('Unable to find an attribute to delete.'));
         $this->_redirect('*/*/');
     }
-
-    protected function _isAllowed()
-    {
-        return Mage::getSingleton('admin/session')->isAllowed('catalog/attributes/attributes');
-    }
 }
diff --git a/app/code/core/Mage/Adminhtml/controllers/Catalog/Product/DatafeedsController.php b/app/code/core/Mage/Adminhtml/controllers/Catalog/Product/DatafeedsController.php
index 2cfa5e6e996..6dfd1711eba 100644
--- a/app/code/core/Mage/Adminhtml/controllers/Catalog/Product/DatafeedsController.php
+++ b/app/code/core/Mage/Adminhtml/controllers/Catalog/Product/DatafeedsController.php
@@ -24,19 +24,16 @@
  * @license    http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
 
-
 class Mage_Adminhtml_Catalog_DatafeedsController extends Mage_Adminhtml_Controller_Action
 {
-
     public function indexAction()
     {
-
     }
 
     /**
      * Check is allowed access to action
      *
-     * @return bool
+     * @return true
      */
     protected function _isAllowed()
     {
diff --git a/app/code/core/Mage/Adminhtml/controllers/Catalog/Product/GalleryController.php b/app/code/core/Mage/Adminhtml/controllers/Catalog/Product/GalleryController.php
index 289b5add5e9..2138fe1892d 100644
--- a/app/code/core/Mage/Adminhtml/controllers/Catalog/Product/GalleryController.php
+++ b/app/code/core/Mage/Adminhtml/controllers/Catalog/Product/GalleryController.php
@@ -33,6 +33,12 @@
  */
 class Mage_Adminhtml_Catalog_Product_GalleryController extends Mage_Adminhtml_Controller_Action
 {
+    /**
+     * ACL resource
+     * @see Mage_Adminhtml_Controller_Action::_isAllowed()
+     */
+    const ADMIN_RESOURCE = 'catalog/products';
+
     public function uploadAction()
     {
         try {
@@ -80,9 +86,4 @@ public function uploadAction()
 
         $this->getResponse()->setBody(Mage::helper('core')->jsonEncode($result));
     }
-
-    protected function _isAllowed()
-    {
-        return Mage::getSingleton('admin/session')->isAllowed('catalog/products');
-    }
 }
diff --git a/app/code/core/Mage/Adminhtml/controllers/Catalog/Product/GroupController.php b/app/code/core/Mage/Adminhtml/controllers/Catalog/Product/GroupController.php
index 4122ff5b0c2..02d378f060f 100644
--- a/app/code/core/Mage/Adminhtml/controllers/Catalog/Product/GroupController.php
+++ b/app/code/core/Mage/Adminhtml/controllers/Catalog/Product/GroupController.php
@@ -29,6 +29,12 @@
  */
 class Mage_Adminhtml_Catalog_Product_GroupController extends Mage_Adminhtml_Controller_Action
 {
+    /**
+     * ACL resource
+     * @see Mage_Adminhtml_Controller_Action::_isAllowed()
+     */
+    const ADMIN_RESOURCE = 'catalog/products';
+
     public function saveAction()
     {
         $model = Mage::getModel('eav/entity_attribute_group');
@@ -46,9 +52,4 @@ public function saveAction()
             }
         }
     }
-
-    protected function _isAllowed()
-    {
-        return Mage::getSingleton('admin/session')->isAllowed('catalog/products');
-    }
 }
diff --git a/app/code/core/Mage/Adminhtml/controllers/Catalog/Product/ReviewController.php b/app/code/core/Mage/Adminhtml/controllers/Catalog/Product/ReviewController.php
index d23b72b0113..862b8058a9e 100644
--- a/app/code/core/Mage/Adminhtml/controllers/Catalog/Product/ReviewController.php
+++ b/app/code/core/Mage/Adminhtml/controllers/Catalog/Product/ReviewController.php
@@ -42,7 +42,7 @@ class Mage_Adminhtml_Catalog_Product_ReviewController extends Mage_Adminhtml_Con
     protected $_publicActions = array('edit');
 
     /**
-     * Controller predispatch method
+     * Controller pre-dispatch method
      *
      * @return Mage_Adminhtml_Controller_Action
      */
@@ -376,16 +376,17 @@ public function ratingItemsAction()
         );
     }
 
+    /**
+     * @inheritDoc
+     */
     protected function _isAllowed()
     {
         $action = strtolower($this->getRequest()->getActionName());
         switch ($action) {
             case 'pending':
                 return Mage::getSingleton('admin/session')->isAllowed('catalog/reviews_ratings/reviews/pending');
-                break;
             default:
                 return Mage::getSingleton('admin/session')->isAllowed('catalog/reviews_ratings/reviews/all');
-                break;
         }
     }
 }
diff --git a/app/code/core/Mage/Adminhtml/controllers/Catalog/Product/SetController.php b/app/code/core/Mage/Adminhtml/controllers/Catalog/Product/SetController.php
index bac04cafd07..42ed739d1c6 100644
--- a/app/code/core/Mage/Adminhtml/controllers/Catalog/Product/SetController.php
+++ b/app/code/core/Mage/Adminhtml/controllers/Catalog/Product/SetController.php
@@ -31,9 +31,14 @@
  * @package    Mage_Adminhtml
  * @author      Magento Core Team 
  */
-
 class Mage_Adminhtml_Catalog_Product_SetController extends Mage_Adminhtml_Controller_Action
 {
+    /**
+     * ACL resource
+     * @see Mage_Adminhtml_Controller_Action::_isAllowed()
+     */
+    const ADMIN_RESOURCE = 'catalog/attributes/sets';
+
     public function indexAction()
     {
         $this->_title($this->__('Catalog'))
@@ -209,7 +214,7 @@ public function deleteAction()
     }
 
     /**
-     * Controller predispatch method
+     * Controller pre-dispatch method
      *
      * @return Mage_Adminhtml_Controller_Action
      */
@@ -229,11 +234,6 @@ protected function _setTypeId()
             Mage::getModel('catalog/product')->getResource()->getTypeId());
     }
 
-    protected function _isAllowed()
-    {
-        return Mage::getSingleton('admin/session')->isAllowed('catalog/attributes/sets');
-    }
-
     /**
      * Retrieve catalog product entity type id
      *
diff --git a/app/code/core/Mage/Adminhtml/controllers/Catalog/Product/WidgetController.php b/app/code/core/Mage/Adminhtml/controllers/Catalog/Product/WidgetController.php
index e062d15a089..14d52e6aaed 100644
--- a/app/code/core/Mage/Adminhtml/controllers/Catalog/Product/WidgetController.php
+++ b/app/code/core/Mage/Adminhtml/controllers/Catalog/Product/WidgetController.php
@@ -34,6 +34,12 @@
  */
 class Mage_Adminhtml_Catalog_Product_WidgetController extends Mage_Adminhtml_Controller_Action
 {
+    /**
+     * ACL resource
+     * @see Mage_Adminhtml_Controller_Action::_isAllowed()
+     */
+    const ADMIN_RESOURCE = 'cms/widget_instance';
+
     /**
      * Chooser Source action
      *
@@ -74,14 +80,4 @@ public function chooserAction()
 
         $this->getResponse()->setBody($html);
     }
-
-    /**
-     * Check is allowed access to action
-     *
-     * @return bool
-     */
-    protected function _isAllowed()
-    {
-        return Mage::getSingleton('admin/session')->isAllowed('cms/widget_instance');
-    }
 }
diff --git a/app/code/core/Mage/Adminhtml/controllers/Catalog/ProductController.php b/app/code/core/Mage/Adminhtml/controllers/Catalog/ProductController.php
index c95bd7cec43..ee46128ffbd 100644
--- a/app/code/core/Mage/Adminhtml/controllers/Catalog/ProductController.php
+++ b/app/code/core/Mage/Adminhtml/controllers/Catalog/ProductController.php
@@ -33,6 +33,12 @@
  */
 class Mage_Adminhtml_Catalog_ProductController extends Mage_Adminhtml_Controller_Action
 {
+    /**
+     * ACL resource
+     * @see Mage_Adminhtml_Controller_Action::_isAllowed()
+     */
+    const ADMIN_RESOURCE = 'catalog/products';
+
     /**
      * The greatest value which could be stored in CatalogInventory Qty field
      */
@@ -46,7 +52,7 @@ class Mage_Adminhtml_Catalog_ProductController extends Mage_Adminhtml_Controller
     protected $_publicActions = array('edit');
 
     /**
-     * Controller predispatch method
+     * Controller pre-dispatch method
      *
      * @return Mage_Adminhtml_Controller_Action
      */
@@ -588,9 +594,7 @@ protected function _initProductSave()
         /**
          * Create Permanent Redirect for old URL key
          */
-        if ($product->getId() && isset($productData['url_key_create_redirect']))
-        // && $product->getOrigData('url_key') != $product->getData('url_key')
-        {
+        if ($product->getId() && isset($productData['url_key_create_redirect'])) {
             $product->setData('save_rewrites_history', (bool)$productData['url_key_create_redirect']);
         }
 
@@ -1103,16 +1107,6 @@ public function quickCreateAction()
         $this->getResponse()->setBody(Mage::helper('core')->jsonEncode($result));
     }
 
-    /**
-     * Check for is allowed
-     *
-     * @return boolean
-     */
-    protected function _isAllowed()
-    {
-        return Mage::getSingleton('admin/session')->isAllowed('catalog/products');
-    }
-
     /**
      * Show item update result from updateAction
      * in Wishlist and Cart controllers.
diff --git a/app/code/core/Mage/Adminhtml/controllers/Catalog/SearchController.php b/app/code/core/Mage/Adminhtml/controllers/Catalog/SearchController.php
index 759aad5555f..37159a50948 100644
--- a/app/code/core/Mage/Adminhtml/controllers/Catalog/SearchController.php
+++ b/app/code/core/Mage/Adminhtml/controllers/Catalog/SearchController.php
@@ -24,9 +24,14 @@
  * @license    http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
 
-
 class Mage_Adminhtml_Catalog_SearchController extends Mage_Adminhtml_Controller_Action
 {
+    /**
+     * ACL resource
+     * @see Mage_Adminhtml_Controller_Action::_isAllowed()
+     */
+    const ADMIN_RESOURCE = 'catalog/search';
+
     protected function _initAction()
     {
         $this->loadLayout()
@@ -192,7 +197,7 @@ public function massDeleteAction()
     }
 
     /**
-     * Controller predispatch method
+     * Controller pre-dispatch method
      *
      * @return Mage_Adminhtml_Controller_Action
      */
@@ -201,9 +206,4 @@ public function preDispatch()
         $this->_setForcedFormKeyActions('delete', 'massDelete');
         return parent::preDispatch();
     }
-
-    protected function _isAllowed()
-    {
-        return Mage::getSingleton('admin/session')->isAllowed('catalog/search');
-    }
 }
diff --git a/app/code/core/Mage/Adminhtml/controllers/CatalogController.php b/app/code/core/Mage/Adminhtml/controllers/CatalogController.php
index a1f6ab5adc9..9f0bf2e0157 100644
--- a/app/code/core/Mage/Adminhtml/controllers/CatalogController.php
+++ b/app/code/core/Mage/Adminhtml/controllers/CatalogController.php
@@ -33,6 +33,12 @@
  */
 class Mage_Adminhtml_CatalogController extends Mage_Adminhtml_Controller_Action
 {
+    /**
+     * ACL resource
+     * @see Mage_Adminhtml_Controller_Action::_isAllowed()
+     */
+    const ADMIN_RESOURCE = 'catalog';
+
     public function indexAction()
     {
         $this->loadLayout();
@@ -42,9 +48,4 @@ public function indexAction()
         $this->_addContent($this->getLayout()->createBlock('adminhtml/catalog'));
         $this->renderLayout();
     }
-
-    protected function _isAllowed()
-    {
-        return Mage::getSingleton('admin/session')->isAllowed('catalog');
-    }
 }
diff --git a/app/code/core/Mage/Adminhtml/controllers/Checkout/AgreementController.php b/app/code/core/Mage/Adminhtml/controllers/Checkout/AgreementController.php
index c9cee4e7bbd..7bf345cad43 100644
--- a/app/code/core/Mage/Adminhtml/controllers/Checkout/AgreementController.php
+++ b/app/code/core/Mage/Adminhtml/controllers/Checkout/AgreementController.php
@@ -34,7 +34,13 @@
 class Mage_Adminhtml_Checkout_AgreementController extends Mage_Adminhtml_Controller_Action
 {
     /**
-     * Controller predispatch method
+     * ACL resource
+     * @see Mage_Adminhtml_Controller_Action::_isAllowed()
+     */
+    const ADMIN_RESOURCE = 'sales/checkoutagreement';
+
+    /**
+     * Controller pre-dispatch method
      *
      * @return Mage_Adminhtml_Controller_Action
      */
@@ -161,9 +167,4 @@ protected function _initAction()
         ;
         return $this;
     }
-
-    protected function _isAllowed()
-    {
-        return Mage::getSingleton('admin/session')->isAllowed('sales/checkoutagreement');
-    }
 }
diff --git a/app/code/core/Mage/Adminhtml/controllers/Cms/Block/WidgetController.php b/app/code/core/Mage/Adminhtml/controllers/Cms/Block/WidgetController.php
index 66328f6bf60..3a3d75a60a7 100644
--- a/app/code/core/Mage/Adminhtml/controllers/Cms/Block/WidgetController.php
+++ b/app/code/core/Mage/Adminhtml/controllers/Cms/Block/WidgetController.php
@@ -34,6 +34,12 @@
  */
 class Mage_Adminhtml_Cms_Block_WidgetController extends Mage_Adminhtml_Controller_Action
 {
+    /**
+     * ACL resource
+     * @see Mage_Adminhtml_Controller_Action::_isAllowed()
+     */
+    const ADMIN_RESOURCE = 'cms/widget_instance';
+
     /**
      * Chooser Source action
      */
@@ -45,14 +51,4 @@ public function chooserAction()
         ));
         $this->getResponse()->setBody($pagesGrid->toHtml());
     }
-
-    /**
-     * Check is allowed access to action
-     *
-     * @return bool
-     */
-    protected function _isAllowed()
-    {
-        return Mage::getSingleton('admin/session')->isAllowed('cms/widget_instance');
-    }
 }
diff --git a/app/code/core/Mage/Adminhtml/controllers/Cms/BlockController.php b/app/code/core/Mage/Adminhtml/controllers/Cms/BlockController.php
index 3a9343b605c..639b98121f1 100644
--- a/app/code/core/Mage/Adminhtml/controllers/Cms/BlockController.php
+++ b/app/code/core/Mage/Adminhtml/controllers/Cms/BlockController.php
@@ -35,7 +35,13 @@
 class Mage_Adminhtml_Cms_BlockController extends Mage_Adminhtml_Controller_Action
 {
     /**
-     * Controller predispatch method
+     * ACL resource
+     * @see Mage_Adminhtml_Controller_Action::_isAllowed()
+     */
+    const ADMIN_RESOURCE = 'cms/block';
+
+    /**
+     * Controller pre-dispatch method
      *
      * @return Mage_Adminhtml_Controller_Action
      */
@@ -203,14 +209,4 @@ public function deleteAction()
         // go to grid
         $this->_redirect('*/*/');
     }
-
-    /**
-     * Check the permission to run it
-     *
-     * @return boolean
-     */
-    protected function _isAllowed()
-    {
-        return Mage::getSingleton('admin/session')->isAllowed('cms/block');
-    }
 }
diff --git a/app/code/core/Mage/Adminhtml/controllers/Cms/Page/WidgetController.php b/app/code/core/Mage/Adminhtml/controllers/Cms/Page/WidgetController.php
index 06cd6afc098..e3fcc4a1a68 100644
--- a/app/code/core/Mage/Adminhtml/controllers/Cms/Page/WidgetController.php
+++ b/app/code/core/Mage/Adminhtml/controllers/Cms/Page/WidgetController.php
@@ -24,7 +24,6 @@
  * @license    http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
 
-
 /**
  * Controller for CMS Page Link Widget plugin
  *
@@ -34,6 +33,12 @@
  */
 class Mage_Adminhtml_Cms_Page_WidgetController extends Mage_Adminhtml_Controller_Action
 {
+    /**
+     * ACL resource
+     * @see Mage_Adminhtml_Controller_Action::_isAllowed()
+     */
+    const ADMIN_RESOURCE = 'cms/widget_instance';
+
     /**
      * Chooser Source action
      */
@@ -45,15 +50,4 @@ public function chooserAction()
         ));
         $this->getResponse()->setBody($pagesGrid->toHtml());
     }
-
-    /**
-     * Check is allowed access to action
-     *
-     * @return bool
-     */
-    protected function _isAllowed()
-    {
-        return Mage::getSingleton('admin/session')->isAllowed('cms/widget_instance');
-    }
-
 }
diff --git a/app/code/core/Mage/Adminhtml/controllers/Cms/PageController.php b/app/code/core/Mage/Adminhtml/controllers/Cms/PageController.php
index 7aa9dea0db8..ae35cecdcde 100644
--- a/app/code/core/Mage/Adminhtml/controllers/Cms/PageController.php
+++ b/app/code/core/Mage/Adminhtml/controllers/Cms/PageController.php
@@ -217,7 +217,7 @@ public function deleteAction()
     }
 
     /**
-     * Controller predispatch method
+     * Controller pre-dispatch method
      *
      * @return Mage_Adminhtml_Controller_Action
      */
@@ -228,9 +228,7 @@ public function preDispatch()
     }
 
     /**
-     * Check the permission to run it
-     *
-     * @return boolean
+     * @inheritDoc
      */
     protected function _isAllowed()
     {
@@ -239,13 +237,10 @@ protected function _isAllowed()
             case 'new':
             case 'save':
                 return Mage::getSingleton('admin/session')->isAllowed('cms/page/save');
-                break;
             case 'delete':
                 return Mage::getSingleton('admin/session')->isAllowed('cms/page/delete');
-                break;
             default:
                 return Mage::getSingleton('admin/session')->isAllowed('cms/page');
-                break;
         }
     }
 
diff --git a/app/code/core/Mage/Adminhtml/controllers/Cms/Wysiwyg/ImagesController.php b/app/code/core/Mage/Adminhtml/controllers/Cms/Wysiwyg/ImagesController.php
index 5f47078ba62..08941a3e58c 100644
--- a/app/code/core/Mage/Adminhtml/controllers/Cms/Wysiwyg/ImagesController.php
+++ b/app/code/core/Mage/Adminhtml/controllers/Cms/Wysiwyg/ImagesController.php
@@ -33,10 +33,16 @@
  */
 class Mage_Adminhtml_Cms_Wysiwyg_ImagesController extends Mage_Adminhtml_Controller_Action
 {
+    /**
+     * ACL resource
+     * @see Mage_Adminhtml_Controller_Action::_isAllowed()
+     */
+    const ADMIN_RESOURCE = 'cms/media_gallery';
+
     /**
      * Init storage
      *
-     * @return Mage_Adminhtml_Cms_Page_Wysiwyg_ImagesController
+     * @return $this
      */
     protected function _initAction()
     {
@@ -155,7 +161,6 @@ public function uploadAction()
             $result = array('error' => $e->getMessage(), 'errorcode' => $e->getCode());
         }
         $this->getResponse()->setBody(Mage::helper('core')->jsonEncode($result));
-
     }
 
     /**
@@ -215,7 +220,7 @@ public function getStorage()
     /**
      * Save current path in session
      *
-     * @return Mage_Adminhtml_Cms_Page_Wysiwyg_ImagesController
+     * @return $this
      */
     protected function _saveSessionCurrentPath()
     {
@@ -226,14 +231,4 @@ protected function _saveSessionCurrentPath()
         }
         return $this;
     }
-
-    /**
-     * Check current user permission on resource and privilege
-     *
-     * @return bool
-     */
-    protected function _isAllowed()
-    {
-        return Mage::getSingleton('admin/session')->isAllowed('cms/media_gallery');
-    }
 }
diff --git a/app/code/core/Mage/Adminhtml/controllers/Cms/WysiwygController.php b/app/code/core/Mage/Adminhtml/controllers/Cms/WysiwygController.php
index 81a9761acf8..743ee323100 100644
--- a/app/code/core/Mage/Adminhtml/controllers/Cms/WysiwygController.php
+++ b/app/code/core/Mage/Adminhtml/controllers/Cms/WysiwygController.php
@@ -33,6 +33,12 @@
  */
 class Mage_Adminhtml_Cms_WysiwygController extends Mage_Adminhtml_Controller_Action
 {
+    /**
+     * ACL resource
+     * @see Mage_Adminhtml_Controller_Action::_isAllowed()
+     */
+    const ADMIN_RESOURCE = 'cms';
+
     /**
      * Template directives callback
      *
@@ -60,14 +66,4 @@ public function directiveAction()
         $this->getResponse()->setBody(ob_get_contents());
         ob_end_clean();
     }
-
-    /**
-     * Check the permission to run it
-     *
-     * @return boolean
-     */
-    protected function _isAllowed()
-    {
-        return Mage::getSingleton('admin/session')->isAllowed('cms');
-    }
 }
diff --git a/app/code/core/Mage/Adminhtml/controllers/Customer/Cart/Product/Composite/CartController.php b/app/code/core/Mage/Adminhtml/controllers/Customer/Cart/Product/Composite/CartController.php
index 5dfd0db8d61..acc8b2ea44f 100644
--- a/app/code/core/Mage/Adminhtml/controllers/Customer/Cart/Product/Composite/CartController.php
+++ b/app/code/core/Mage/Adminhtml/controllers/Customer/Cart/Product/Composite/CartController.php
@@ -33,6 +33,12 @@
  */
 class Mage_Adminhtml_Customer_Cart_Product_Composite_CartController extends Mage_Adminhtml_Controller_Action
 {
+    /**
+     * ACL resource
+     * @see Mage_Adminhtml_Controller_Action::_isAllowed()
+     */
+    const ADMIN_RESOURCE = 'customer/manage';
+
     /**
      * Customer we're working with
      *
@@ -149,14 +155,4 @@ public function updateAction()
 
         return $this;
     }
-
-    /**
-     * Check the permission to Manage Customers
-     *
-     * @return bool
-     */
-    protected function _isAllowed()
-    {
-        return Mage::getSingleton('admin/session')->isAllowed('customer/manage');
-    }
 }
diff --git a/app/code/core/Mage/Adminhtml/controllers/Customer/ConfigController.php b/app/code/core/Mage/Adminhtml/controllers/Customer/ConfigController.php
index 36224d5000f..911f238f97b 100644
--- a/app/code/core/Mage/Adminhtml/controllers/Customer/ConfigController.php
+++ b/app/code/core/Mage/Adminhtml/controllers/Customer/ConfigController.php
@@ -33,6 +33,12 @@
  */
 class Mage_Adminhtml_Customer_ConfigController extends Mage_Adminhtml_Controller_Action
 {
+    /**
+     * ACL resource
+     * @see Mage_Adminhtml_Controller_Action::_isAllowed()
+     */
+    const ADMIN_RESOURCE = 'customer/config';
+
     public function indexAction()
     {
         $this->loadLayout();
@@ -47,9 +53,4 @@ public function indexAction()
 
         $this->renderLayout();
     }
-
-    protected function _isAllowed()
-    {
-        return Mage::getSingleton('admin/session')->isAllowed('customer/config');
-    }
 }
diff --git a/app/code/core/Mage/Adminhtml/controllers/Customer/GroupController.php b/app/code/core/Mage/Adminhtml/controllers/Customer/GroupController.php
index 13a1f7a5959..0d83139b63d 100644
--- a/app/code/core/Mage/Adminhtml/controllers/Customer/GroupController.php
+++ b/app/code/core/Mage/Adminhtml/controllers/Customer/GroupController.php
@@ -34,7 +34,13 @@
 class Mage_Adminhtml_Customer_GroupController extends Mage_Adminhtml_Controller_Action
 {
     /**
-     * Controller predispatch method
+     * ACL resource
+     * @see Mage_Adminhtml_Controller_Action::_isAllowed()
+     */
+    const ADMIN_RESOURCE = 'customer/group';
+
+    /**
+     * Controller pre-dispatch method
      *
      * @return Mage_Adminhtml_Controller_Action
      */
@@ -53,8 +59,8 @@ protected function _initGroup()
         if (!is_null($groupId)) {
             Mage::registry('current_group')->load($groupId);
         }
-
     }
+
     /**
      * Customer groups list.
      */
@@ -163,9 +169,4 @@ public function deleteAction()
 
         $this->_redirect('*/customer_group');
     }
-
-    protected function _isAllowed()
-    {
-        return Mage::getSingleton('admin/session')->isAllowed('customer/group');
-    }
 }
diff --git a/app/code/core/Mage/Adminhtml/controllers/Customer/OnlineController.php b/app/code/core/Mage/Adminhtml/controllers/Customer/OnlineController.php
index 26557d7371c..a290bc3b784 100644
--- a/app/code/core/Mage/Adminhtml/controllers/Customer/OnlineController.php
+++ b/app/code/core/Mage/Adminhtml/controllers/Customer/OnlineController.php
@@ -23,8 +23,14 @@
  * @copyright  Copyright (c) 2006-2020 Magento, Inc. (http://www.magento.com)
  * @license    http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
+
 class Mage_Adminhtml_Customer_OnlineController extends Mage_Adminhtml_Controller_Action
 {
+    /**
+     * ACL resource
+     * @see Mage_Adminhtml_Controller_Action::_isAllowed()
+     */
+    const ADMIN_RESOURCE = 'customer/online';
 
     public function indexAction()
     {
@@ -46,9 +52,4 @@ public function indexAction()
 
         $this->renderLayout();
     }
-
-    protected function _isAllowed()
-    {
-        return Mage::getSingleton('admin/session')->isAllowed('customer/online');
-    }
 }
diff --git a/app/code/core/Mage/Adminhtml/controllers/Customer/System/Config/ValidatevatController.php b/app/code/core/Mage/Adminhtml/controllers/Customer/System/Config/ValidatevatController.php
index 9d573d7cd0b..5ad9c53e616 100644
--- a/app/code/core/Mage/Adminhtml/controllers/Customer/System/Config/ValidatevatController.php
+++ b/app/code/core/Mage/Adminhtml/controllers/Customer/System/Config/ValidatevatController.php
@@ -33,6 +33,12 @@
  */
 class Mage_Adminhtml_Customer_System_Config_ValidatevatController extends Mage_Adminhtml_Controller_Action
 {
+    /**
+     * ACL resource
+     * @see Mage_Adminhtml_Controller_Action::_isAllowed()
+     */
+    const ADMIN_RESOURCE = 'system/config';
+
     /**
      * Perform customer VAT ID validation
      *
@@ -88,14 +94,4 @@ public function validateAdvancedAction()
         ));
         $this->getResponse()->setBody($body);
     }
-
-    /**
-     * Check is allowed access to action
-     *
-     * @return bool
-     */
-    protected function _isAllowed()
-    {
-        return Mage::getSingleton('admin/session')->isAllowed('system/config');
-    }
 }
diff --git a/app/code/core/Mage/Adminhtml/controllers/Customer/Wishlist/Product/Composite/WishlistController.php b/app/code/core/Mage/Adminhtml/controllers/Customer/Wishlist/Product/Composite/WishlistController.php
index bdcfc18bdcd..b32f85ba638 100644
--- a/app/code/core/Mage/Adminhtml/controllers/Customer/Wishlist/Product/Composite/WishlistController.php
+++ b/app/code/core/Mage/Adminhtml/controllers/Customer/Wishlist/Product/Composite/WishlistController.php
@@ -34,6 +34,12 @@
 class Mage_Adminhtml_Customer_Wishlist_Product_Composite_WishlistController
     extends Mage_Adminhtml_Controller_Action
 {
+    /**
+     * ACL resource
+     * @see Mage_Adminhtml_Controller_Action::_isAllowed()
+     */
+    const ADMIN_RESOURCE = 'customer/manage';
+
      /**
      * Wishlist we're working with
      *
@@ -135,14 +141,4 @@ public function updateAction()
 
         return false;
     }
-
-    /**
-     * Check the permission to Manage Customers
-     *
-     * @return bool
-     */
-    protected function _isAllowed()
-    {
-        return Mage::getSingleton('admin/session')->isAllowed('customer/manage');
-    }
 }
diff --git a/app/code/core/Mage/Adminhtml/controllers/CustomerController.php b/app/code/core/Mage/Adminhtml/controllers/CustomerController.php
index 710d09c0e68..a3cf234ffb8 100644
--- a/app/code/core/Mage/Adminhtml/controllers/CustomerController.php
+++ b/app/code/core/Mage/Adminhtml/controllers/CustomerController.php
@@ -34,7 +34,13 @@
 class Mage_Adminhtml_CustomerController extends Mage_Adminhtml_Controller_Action
 {
     /**
-     * Controller predispatch method
+     * ACL resource
+     * @see Mage_Adminhtml_Controller_Action::_isAllowed()
+     */
+    const ADMIN_RESOURCE = 'customer/manage';
+
+    /**
+     * Controller pre-dispatch method
      *
      * @return Mage_Adminhtml_Controller_Action
      */
@@ -855,11 +861,6 @@ public function viewfileAction()
         exit();
     }
 
-    protected function _isAllowed()
-    {
-        return Mage::getSingleton('admin/session')->isAllowed('customer/manage');
-    }
-
     /**
      * Filtering posted data. Converting localized data if needed
      *
diff --git a/app/code/core/Mage/Adminhtml/controllers/DashboardController.php b/app/code/core/Mage/Adminhtml/controllers/DashboardController.php
index c070f1fe9ac..02dfccecf5c 100644
--- a/app/code/core/Mage/Adminhtml/controllers/DashboardController.php
+++ b/app/code/core/Mage/Adminhtml/controllers/DashboardController.php
@@ -33,6 +33,12 @@
  */
 class Mage_Adminhtml_DashboardController extends Mage_Adminhtml_Controller_Action
 {
+    /**
+     * ACL resource
+     * @see Mage_Adminhtml_Controller_Action::_isAllowed()
+     */
+    const ADMIN_RESOURCE = 'dashboard';
+
     public function indexAction()
     {
         $this->_title($this->__('Dashboard'));
@@ -45,7 +51,6 @@ public function indexAction()
 
     /**
      * Gets most viewed products list
-     *
      */
     public function productsViewedAction()
     {
@@ -55,7 +60,6 @@ public function productsViewedAction()
 
     /**
      * Gets latest customers list
-     *
      */
     public function customersNewestAction()
     {
@@ -65,7 +69,6 @@ public function customersNewestAction()
 
     /**
      * Gets the list of most active customers
-     *
      */
     public function customersMostAction()
     {
@@ -108,9 +111,4 @@ public function tunnelAction()
             }
         }
     }
-
-    protected function _isAllowed()
-    {
-        return Mage::getSingleton('admin/session')->isAllowed('dashboard');
-    }
 }
diff --git a/app/code/core/Mage/Adminhtml/controllers/IndexController.php b/app/code/core/Mage/Adminhtml/controllers/IndexController.php
index 5bf707f8ce4..87ee9d665e8 100644
--- a/app/code/core/Mage/Adminhtml/controllers/IndexController.php
+++ b/app/code/core/Mage/Adminhtml/controllers/IndexController.php
@@ -402,7 +402,7 @@ protected function _validateResetPasswordLinkToken($userId, $resetPasswordLinkTo
     /**
      * Check if user has permissions to access this controller
      *
-     * @return boolean
+     * @return true
      */
     protected function _isAllowed()
     {
diff --git a/app/code/core/Mage/Adminhtml/controllers/JsonController.php b/app/code/core/Mage/Adminhtml/controllers/JsonController.php
index 633031c4d23..86d8816a06b 100644
--- a/app/code/core/Mage/Adminhtml/controllers/JsonController.php
+++ b/app/code/core/Mage/Adminhtml/controllers/JsonController.php
@@ -35,8 +35,6 @@ class Mage_Adminhtml_JsonController extends Mage_Adminhtml_Controller_Action
 {
     /**
      * Return JSON-encoded array of country regions
-     *
-     * @return string
      */
     public function countryRegionAction()
     {
@@ -60,7 +58,7 @@ public function countryRegionAction()
     /**
      * Check is allowed access to action
      *
-     * @return bool
+     * @return true
      */
     protected function _isAllowed()
     {
diff --git a/app/code/core/Mage/Adminhtml/controllers/Media/EditorController.php b/app/code/core/Mage/Adminhtml/controllers/Media/EditorController.php
index 75f85a07ba9..fdeaa2b8fe2 100644
--- a/app/code/core/Mage/Adminhtml/controllers/Media/EditorController.php
+++ b/app/code/core/Mage/Adminhtml/controllers/Media/EditorController.php
@@ -24,7 +24,6 @@
  * @license    http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
 
-
 /**
  * Media library editor controller
  *
@@ -34,6 +33,12 @@
  */
 class Mage_Adminhtml_Media_EditorController extends Mage_Adminhtml_Controller_Action
 {
+    /**
+     * ACL resource
+     * @see Mage_Adminhtml_Controller_Action::_isAllowed()
+     */
+    const ADMIN_RESOURCE = 'media';
+
     public function indexAction()
     {
         $this->loadLayout();
@@ -42,9 +47,4 @@ public function indexAction()
         );
         $this->renderLayout();
     }
-
-    protected function _isAllowed()
-    {
-        return Mage::getSingleton('admin/session')->isAllowed('media');
-    }
 }
diff --git a/app/code/core/Mage/Adminhtml/controllers/Media/UploaderController.php b/app/code/core/Mage/Adminhtml/controllers/Media/UploaderController.php
index 6cc2507dd7b..086ef500e38 100644
--- a/app/code/core/Mage/Adminhtml/controllers/Media/UploaderController.php
+++ b/app/code/core/Mage/Adminhtml/controllers/Media/UploaderController.php
@@ -33,6 +33,11 @@
  */
 class Mage_Adminhtml_Media_UploaderController extends Mage_Adminhtml_Controller_Action
 {
+    /**
+     * ACL resource
+     * @see Mage_Adminhtml_Controller_Action::_isAllowed()
+     */
+    const ADMIN_RESOURCE = 'media';
 
     public function uploadAction()
     {
@@ -47,9 +52,4 @@ public function indexAction()
         );
         $this->renderLayout();
     }
-
-    protected function _isAllowed()
-    {
-        return Mage::getSingleton('admin/session')->isAllowed('media');
-    }
 }
diff --git a/app/code/core/Mage/Adminhtml/controllers/Newsletter/ProblemController.php b/app/code/core/Mage/Adminhtml/controllers/Newsletter/ProblemController.php
index 306b3ccc5c1..840dac02189 100644
--- a/app/code/core/Mage/Adminhtml/controllers/Newsletter/ProblemController.php
+++ b/app/code/core/Mage/Adminhtml/controllers/Newsletter/ProblemController.php
@@ -33,6 +33,12 @@
  */
 class Mage_Adminhtml_Newsletter_ProblemController extends Mage_Adminhtml_Controller_Action
 {
+    /**
+     * ACL resource
+     * @see Mage_Adminhtml_Controller_Action::_isAllowed()
+     */
+    const ADMIN_RESOURCE = 'newsletter/problem';
+
     public function indexAction()
     {
         $this->_title($this->__('Newsletter'))->_title($this->__('Newsletter Problems'));
@@ -96,9 +102,4 @@ public function gridAction()
         $grid = $this->getLayout()->createBlock('adminhtml/newsletter_problem_grid');
         $this->getResponse()->setBody($grid->toHtml());
     }
-
-    protected function _isAllowed()
-    {
-        return Mage::getSingleton('admin/session')->isAllowed('newsletter/problem');
-    }
 }
diff --git a/app/code/core/Mage/Adminhtml/controllers/Newsletter/QueueController.php b/app/code/core/Mage/Adminhtml/controllers/Newsletter/QueueController.php
index 1c46751c141..ef5b6193324 100644
--- a/app/code/core/Mage/Adminhtml/controllers/Newsletter/QueueController.php
+++ b/app/code/core/Mage/Adminhtml/controllers/Newsletter/QueueController.php
@@ -33,6 +33,12 @@
  */
 class Mage_Adminhtml_Newsletter_QueueController extends Mage_Adminhtml_Controller_Action
 {
+    /**
+     * ACL resource
+     * @see Mage_Adminhtml_Controller_Action::_isAllowed()
+     */
+    const ADMIN_RESOURCE = 'newsletter/queue';
+
     /**
      * Queue list action
      */
@@ -274,9 +280,4 @@ public function saveAction()
             }
         }
     }
-
-    protected function _isAllowed()
-    {
-        return Mage::getSingleton('admin/session')->isAllowed('newsletter/queue');
-    }
 }
diff --git a/app/code/core/Mage/Adminhtml/controllers/Newsletter/SubscriberController.php b/app/code/core/Mage/Adminhtml/controllers/Newsletter/SubscriberController.php
index 8fc4e744a60..605cf225995 100644
--- a/app/code/core/Mage/Adminhtml/controllers/Newsletter/SubscriberController.php
+++ b/app/code/core/Mage/Adminhtml/controllers/Newsletter/SubscriberController.php
@@ -33,6 +33,11 @@
  */
 class Mage_Adminhtml_Newsletter_SubscriberController extends Mage_Adminhtml_Controller_Action
 {
+    /**
+     * ACL resource
+     * @see Mage_Adminhtml_Controller_Action::_isAllowed()
+     */
+    const ADMIN_RESOURCE = 'newsletter/subscriber';
 
     public function indexAction()
     {
@@ -149,9 +154,4 @@ public function massDeleteAction()
 
         $this->_redirect('*/*/index');
     }
-
-    protected function _isAllowed()
-    {
-        return Mage::getSingleton('admin/session')->isAllowed('newsletter/subscriber');
-    }
 }
diff --git a/app/code/core/Mage/Adminhtml/controllers/Newsletter/TemplateController.php b/app/code/core/Mage/Adminhtml/controllers/Newsletter/TemplateController.php
index 5e555f2fb73..56c5c602149 100644
--- a/app/code/core/Mage/Adminhtml/controllers/Newsletter/TemplateController.php
+++ b/app/code/core/Mage/Adminhtml/controllers/Newsletter/TemplateController.php
@@ -251,7 +251,7 @@ public function previewAction ()
     }
 
     /**
-     * Controller predispatch method
+     * Controller pre-dispatch method
      *
      * @return Mage_Adminhtml_Controller_Action
      */
diff --git a/app/code/core/Mage/Adminhtml/controllers/NotificationController.php b/app/code/core/Mage/Adminhtml/controllers/NotificationController.php
index 43a2f370493..46cac04d34b 100644
--- a/app/code/core/Mage/Adminhtml/controllers/NotificationController.php
+++ b/app/code/core/Mage/Adminhtml/controllers/NotificationController.php
@@ -158,23 +158,20 @@ public function massRemoveAction()
         $this->_redirectReferer();
     }
 
+    /**
+     * @inheritDoc
+     */
     protected function _isAllowed()
     {
         $action = strtolower($this->getRequest()->getActionName());
         switch ($action) {
-            case 'markasread':
-                $acl = 'system/adminnotification/mark_as_read';
-                break;
-
             case 'massmarkasread':
+            case 'markasread':
                 $acl = 'system/adminnotification/mark_as_read';
                 break;
 
-            case 'remove':
-                $acl = 'system/adminnotification/remove';
-                break;
-
             case 'massremove':
+            case 'remove':
                 $acl = 'system/adminnotification/remove';
                 break;
 
diff --git a/app/code/core/Mage/Adminhtml/controllers/Permissions/BlockController.php b/app/code/core/Mage/Adminhtml/controllers/Permissions/BlockController.php
index 7d8352c55dd..63f042016cf 100644
--- a/app/code/core/Mage/Adminhtml/controllers/Permissions/BlockController.php
+++ b/app/code/core/Mage/Adminhtml/controllers/Permissions/BlockController.php
@@ -33,6 +33,12 @@
  */
 class Mage_Adminhtml_Permissions_BlockController extends Mage_Adminhtml_Controller_Action
 {
+    /**
+     * ACL resource
+     * @see Mage_Adminhtml_Controller_Action::_isAllowed()
+     */
+    const ADMIN_RESOURCE = 'system/acl/blocks';
+
     /**
      * @return $this
      */
@@ -205,7 +211,7 @@ public function blockGridAction()
     }
 
     /**
-     * Controller predispatch method
+     * Controller pre-dispatch method
      *
      * @return Mage_Adminhtml_Controller_Action
      */
@@ -214,14 +220,4 @@ public function preDispatch()
         $this->_setForcedFormKeyActions('delete');
         return parent::preDispatch();
     }
-
-    /**
-     * Check permissions before allow edit list of blocks
-     *
-     * @return bool
-     */
-    protected function _isAllowed()
-    {
-        return Mage::getSingleton('admin/session')->isAllowed('system/acl/blocks');
-    }
 }
diff --git a/app/code/core/Mage/Adminhtml/controllers/Permissions/RoleController.php b/app/code/core/Mage/Adminhtml/controllers/Permissions/RoleController.php
index 2b3fcd1ad89..b203b4a3684 100644
--- a/app/code/core/Mage/Adminhtml/controllers/Permissions/RoleController.php
+++ b/app/code/core/Mage/Adminhtml/controllers/Permissions/RoleController.php
@@ -33,9 +33,14 @@
  */
 class Mage_Adminhtml_Permissions_RoleController extends Mage_Adminhtml_Controller_Action
 {
+    /**
+     * ACL resource
+     * @see Mage_Adminhtml_Controller_Action::_isAllowed()
+     */
+    const ADMIN_RESOURCE = 'system/acl/roles';
 
     /**
-     * Controller predispatch method
+     * Controller pre-dispatch method
      *
      * @return Mage_Adminhtml_Controller_Action
      */
@@ -316,16 +321,6 @@ protected function _addUserToRole($userId, $roleId)
         }
     }
 
-    /**
-     * Acl checking
-     *
-     * @return bool
-     */
-    protected function _isAllowed()
-    {
-        return Mage::getSingleton('admin/session')->isAllowed('system/acl/roles');
-    }
-
     /**
      * Action to refresh role-rule relations.
      * This method will make sure the rendered ACL resource tree checkboxes match the actual ACL permissions.
diff --git a/app/code/core/Mage/Adminhtml/controllers/Permissions/UserController.php b/app/code/core/Mage/Adminhtml/controllers/Permissions/UserController.php
index a60740138a2..ec75f597c58 100644
--- a/app/code/core/Mage/Adminhtml/controllers/Permissions/UserController.php
+++ b/app/code/core/Mage/Adminhtml/controllers/Permissions/UserController.php
@@ -26,7 +26,13 @@
 class Mage_Adminhtml_Permissions_UserController extends Mage_Adminhtml_Controller_Action
 {
     /**
-     * Controller predispatch method
+     * ACL resource
+     * @see Mage_Adminhtml_Controller_Action::_isAllowed()
+     */
+    const ADMIN_RESOURCE = 'system/acl/users';
+
+    /**
+     * Controller pre-dispatch method
      *
      * @return Mage_Adminhtml_Controller_Action
      */
@@ -247,13 +253,6 @@ public function roleGridAction()
         $this->getResponse()
             ->setBody($this->getLayout()
             ->createBlock('adminhtml/permissions_user_grid')
-            ->toHtml()
-        );
+            ->toHtml());
     }
-
-    protected function _isAllowed()
-    {
-        return Mage::getSingleton('admin/session')->isAllowed('system/acl/users');
-    }
-
 }
diff --git a/app/code/core/Mage/Adminhtml/controllers/Permissions/VariableController.php b/app/code/core/Mage/Adminhtml/controllers/Permissions/VariableController.php
index 0849a27a646..f383516b17f 100644
--- a/app/code/core/Mage/Adminhtml/controllers/Permissions/VariableController.php
+++ b/app/code/core/Mage/Adminhtml/controllers/Permissions/VariableController.php
@@ -33,6 +33,12 @@
  */
 class Mage_Adminhtml_Permissions_VariableController extends Mage_Adminhtml_Controller_Action
 {
+    /**
+     * ACL resource
+     * @see Mage_Adminhtml_Controller_Action::_isAllowed()
+     */
+    const ADMIN_RESOURCE = 'system/acl/variables';
+
     /**
      * @return $this
      */
@@ -198,18 +204,7 @@ public function variableGridAction()
     {
         $this->getResponse()
             ->setBody($this->getLayout()
-                ->createBlock('adminhtml/permissions_variable_grid')
-                ->toHtml()
-            );
-    }
-
-    /**
-     * Check permissions before allow edit list of config variables
-     *
-     * @return bool
-     */
-    protected function _isAllowed()
-    {
-        return Mage::getSingleton('admin/session')->isAllowed('system/acl/variables');
+            ->createBlock('adminhtml/permissions_variable_grid')
+            ->toHtml());
     }
 }
diff --git a/app/code/core/Mage/Adminhtml/controllers/Poll/AnswerController.php b/app/code/core/Mage/Adminhtml/controllers/Poll/AnswerController.php
index dd590386855..50b8397eb0b 100644
--- a/app/code/core/Mage/Adminhtml/controllers/Poll/AnswerController.php
+++ b/app/code/core/Mage/Adminhtml/controllers/Poll/AnswerController.php
@@ -34,6 +34,12 @@
 
 class Mage_Adminhtml_Poll_AnswerController extends Mage_Adminhtml_Controller_Action
 {
+    /**
+     * ACL resource
+     * @see Mage_Adminhtml_Controller_Action::_isAllowed()
+     */
+    const ADMIN_RESOURCE = 'cms/poll';
+
     public function editAction()
     {
         $this->loadLayout();
@@ -122,10 +128,4 @@ public function jsonDeleteAction()
         }
         $this->getResponse()->setBody( $response->toJson() );
     }
-
-    protected function _isAllowed()
-    {
-        return Mage::getSingleton('admin/session')->isAllowed('cms/poll');
-    }
-
 }
diff --git a/app/code/core/Mage/Adminhtml/controllers/PollController.php b/app/code/core/Mage/Adminhtml/controllers/PollController.php
index f64711402e4..0a61f164899 100644
--- a/app/code/core/Mage/Adminhtml/controllers/PollController.php
+++ b/app/code/core/Mage/Adminhtml/controllers/PollController.php
@@ -33,6 +33,11 @@
  */
 class Mage_Adminhtml_PollController extends Mage_Adminhtml_Controller_Action
 {
+    /**
+     * ACL resource
+     * @see Mage_Adminhtml_Controller_Action::_isAllowed()
+     */
+    const ADMIN_RESOURCE = 'cms/poll';
 
     public function indexAction()
     {
@@ -208,10 +213,4 @@ public function validateAction()
         }
         $this->getResponse()->setBody($response->toJson());
     }
-
-    protected function _isAllowed()
-    {
-        return Mage::getSingleton('admin/session')->isAllowed('cms/poll');
-    }
-
 }
diff --git a/app/code/core/Mage/Adminhtml/controllers/Promo/CatalogController.php b/app/code/core/Mage/Adminhtml/controllers/Promo/CatalogController.php
index fa5e94a3a6a..eafb77c9588 100644
--- a/app/code/core/Mage/Adminhtml/controllers/Promo/CatalogController.php
+++ b/app/code/core/Mage/Adminhtml/controllers/Promo/CatalogController.php
@@ -33,6 +33,12 @@
  */
 class Mage_Adminhtml_Promo_CatalogController extends Mage_Adminhtml_Controller_Action
 {
+    /**
+     * ACL resource
+     * @see Mage_Adminhtml_Controller_Action::_isAllowed()
+     */
+    const ADMIN_RESOURCE = 'promo/catalog';
+
     /**
      * Dirty rules notice message
      *
@@ -41,7 +47,7 @@ class Mage_Adminhtml_Promo_CatalogController extends Mage_Adminhtml_Controller_A
     protected $_dirtyRulesNoticeMessage;
 
     /**
-     * Controller predispatch method
+     * Controller pre-dispatch method
      *
      * @return Mage_Adminhtml_Controller_Action
      */
@@ -336,11 +342,6 @@ public function addToAlersAction()
     {
     }
 
-    protected function _isAllowed()
-    {
-        return Mage::getSingleton('admin/session')->isAllowed('promo/catalog');
-    }
-
     /**
      * Set dirty rules notice message
      *
diff --git a/app/code/core/Mage/Adminhtml/controllers/Promo/QuoteController.php b/app/code/core/Mage/Adminhtml/controllers/Promo/QuoteController.php
index 68b50b1ca38..15201cb6559 100644
--- a/app/code/core/Mage/Adminhtml/controllers/Promo/QuoteController.php
+++ b/app/code/core/Mage/Adminhtml/controllers/Promo/QuoteController.php
@@ -24,15 +24,19 @@
  * @license    http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
 
-
 class Mage_Adminhtml_Promo_QuoteController extends Mage_Adminhtml_Controller_Action
 {
     /**
-    * Controller predispatch method
+     * ACL resource
+     * @see Mage_Adminhtml_Controller_Action::_isAllowed()
+     */
+    const ADMIN_RESOURCE = 'promo/quote';
+
+    /**
+    * Controller pre-dispatch method
     *
     * @return Mage_Adminhtml_Controller_Action
     */
-
     public function preDispatch()
     {
         $this->_setForcedFormKeyActions('delete');
@@ -446,13 +450,4 @@ public function chooserAction()
         ));
         $this->getResponse()->setBody($chooserBlock->toHtml());
     }
-
-    /**
-     * Returns result of current user permission check on resource and privilege
-     * @return boolean
-     */
-    protected function _isAllowed()
-    {
-        return Mage::getSingleton('admin/session')->isAllowed('promo/quote');
-    }
 }
diff --git a/app/code/core/Mage/Adminhtml/controllers/Promo/WidgetController.php b/app/code/core/Mage/Adminhtml/controllers/Promo/WidgetController.php
index e8ddeb7ea14..9c38dfc9c49 100644
--- a/app/code/core/Mage/Adminhtml/controllers/Promo/WidgetController.php
+++ b/app/code/core/Mage/Adminhtml/controllers/Promo/WidgetController.php
@@ -24,9 +24,14 @@
  * @license    http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
 
-
 class Mage_Adminhtml_Promo_WidgetController extends Mage_Adminhtml_Controller_Action
 {
+    /**
+     * ACL resource
+     * @see Mage_Adminhtml_Controller_Action::_isAllowed()
+     */
+    const ADMIN_RESOURCE = 'promo/catalog';
+
     /**
      * Prepare block for chooser
      *
@@ -78,11 +83,6 @@ public function chooserAction()
         }
     }
 
-    protected function _isAllowed()
-    {
-        return Mage::getSingleton('admin/session')->isAllowed('promo/catalog');
-    }
-
     /**
      * Get tree node (Ajax version)
      */
diff --git a/app/code/core/Mage/Adminhtml/controllers/PromoController.php b/app/code/core/Mage/Adminhtml/controllers/PromoController.php
index 5081f15c46d..6307bc63d38 100644
--- a/app/code/core/Mage/Adminhtml/controllers/PromoController.php
+++ b/app/code/core/Mage/Adminhtml/controllers/PromoController.php
@@ -33,6 +33,11 @@
  */
 class Mage_Adminhtml_PromoController extends Mage_Adminhtml_Controller_Action
 {
+    /**
+     * ACL resource
+     * @see Mage_Adminhtml_Controller_Action::_isAllowed()
+     */
+    const ADMIN_RESOURCE = 'promo';
 
     public function indexAction()
     {
@@ -41,10 +46,4 @@ public function indexAction()
         $this->_addBreadcrumb(Mage::helper('adminhtml')->__('Promotions'), Mage::helper('adminhtml')->__('Promo'));
         $this->renderLayout();
     }
-
-    protected function _isAllowed()
-    {
-        return Mage::getSingleton('admin/session')->isAllowed('promo');
-    }
-
 }
diff --git a/app/code/core/Mage/Adminhtml/controllers/RatingController.php b/app/code/core/Mage/Adminhtml/controllers/RatingController.php
index 388b1340fcf..b7e1f1c09d5 100644
--- a/app/code/core/Mage/Adminhtml/controllers/RatingController.php
+++ b/app/code/core/Mage/Adminhtml/controllers/RatingController.php
@@ -31,9 +31,14 @@
  * @package    Mage_Adminhtml
  * @author      Magento Core Team 
  */
-
 class Mage_Adminhtml_RatingController extends Mage_Adminhtml_Controller_Action
 {
+    /**
+     * ACL resource
+     * @see Mage_Adminhtml_Controller_Action::_isAllowed()
+     */
+    const ADMIN_RESOURCE = 'catalog/reviews_ratings/ratings';
+
     public function indexAction()
     {
         $this->_initEnityId();
@@ -153,10 +158,4 @@ protected function _initEnityId()
 
         Mage::register('entityId', Mage::getModel('rating/rating_entity')->getIdByCode('product'));
     }
-
-    protected function _isAllowed()
-    {
-        return Mage::getSingleton('admin/session')->isAllowed('catalog/reviews_ratings/ratings');
-    }
-
 }
diff --git a/app/code/core/Mage/Adminhtml/controllers/Report/CustomerController.php b/app/code/core/Mage/Adminhtml/controllers/Report/CustomerController.php
index 04e4b80bacc..aedd00b4b64 100644
--- a/app/code/core/Mage/Adminhtml/controllers/Report/CustomerController.php
+++ b/app/code/core/Mage/Adminhtml/controllers/Report/CustomerController.php
@@ -159,22 +159,21 @@ public function exportTotalsExcelAction()
         $this->_prepareDownloadResponse($fileName, $content);
     }
 
+    /**
+     * @inheritDoc
+     */
     protected function _isAllowed()
     {
         $action = strtolower($this->getRequest()->getActionName());
         switch ($action) {
             case 'accounts':
                 return Mage::getSingleton('admin/session')->isAllowed('report/customers/accounts');
-                break;
             case 'orders':
                 return Mage::getSingleton('admin/session')->isAllowed('report/customers/orders');
-                break;
             case 'totals':
                 return Mage::getSingleton('admin/session')->isAllowed('report/customers/totals');
-                break;
             default:
                 return Mage::getSingleton('admin/session')->isAllowed('report/customers');
-                break;
         }
     }
 }
diff --git a/app/code/core/Mage/Adminhtml/controllers/Report/ProductController.php b/app/code/core/Mage/Adminhtml/controllers/Report/ProductController.php
index f853e423659..f4406f740b1 100644
--- a/app/code/core/Mage/Adminhtml/controllers/Report/ProductController.php
+++ b/app/code/core/Mage/Adminhtml/controllers/Report/ProductController.php
@@ -78,7 +78,6 @@ public function exportOrderedExcelAction()
 
     /**
      * Sold Products Report Action
-     *
      */
     public function soldAction()
     {
@@ -95,7 +94,6 @@ public function soldAction()
 
     /**
      * Export Sold Products report to CSV format action
-     *
      */
     public function exportSoldCsvAction()
     {
@@ -109,7 +107,6 @@ public function exportSoldCsvAction()
 
     /**
      * Export Sold Products report to XML format action
-     *
      */
     public function exportSoldExcelAction()
     {
@@ -123,7 +120,6 @@ public function exportSoldExcelAction()
 
     /**
      * Most viewed products
-     *
      */
     public function viewedAction()
     {
@@ -148,7 +144,6 @@ public function viewedAction()
 
     /**
      * Export products most viewed report to CSV format
-     *
      */
     public function exportViewedCsvAction()
     {
@@ -160,7 +155,6 @@ public function exportViewedCsvAction()
 
     /**
      * Export products most viewed report to XML format
-     *
      */
     public function exportViewedExcelAction()
     {
@@ -172,7 +166,6 @@ public function exportViewedExcelAction()
 
     /**
      * Low stock action
-     *
      */
     public function lowstockAction()
     {
@@ -189,7 +182,6 @@ public function lowstockAction()
 
     /**
      * Export low stock products report to CSV format
-     *
      */
     public function exportLowstockCsvAction()
     {
@@ -203,7 +195,6 @@ public function exportLowstockCsvAction()
 
     /**
      * Export low stock products report to XML format
-     *
      */
     public function exportLowstockExcelAction()
     {
@@ -217,7 +208,6 @@ public function exportLowstockExcelAction()
 
     /**
      * Downloads action
-     *
      */
     public function downloadsAction()
     {
@@ -234,7 +224,6 @@ public function downloadsAction()
 
     /**
      * Export products downloads report to CSV format
-     *
      */
     public function exportDownloadsCsvAction()
     {
@@ -248,7 +237,6 @@ public function exportDownloadsCsvAction()
 
     /**
      * Export products downloads report to XLS format
-     *
      */
     public function exportDownloadsExcelAction()
     {
@@ -261,9 +249,7 @@ public function exportDownloadsExcelAction()
     }
 
     /**
-     * Check is allowed for report
-     *
-     * @return bool
+     * @inheritDoc
      */
     protected function _isAllowed()
     {
@@ -271,16 +257,12 @@ protected function _isAllowed()
         switch ($action) {
             case 'viewed':
                 return Mage::getSingleton('admin/session')->isAllowed('report/products/viewed');
-                break;
             case 'sold':
                 return Mage::getSingleton('admin/session')->isAllowed('report/products/sold');
-                break;
             case 'lowstock':
                 return Mage::getSingleton('admin/session')->isAllowed('report/products/lowstock');
-                break;
             default:
                 return Mage::getSingleton('admin/session')->isAllowed('report/products');
-                break;
         }
     }
 }
diff --git a/app/code/core/Mage/Adminhtml/controllers/Report/ReviewController.php b/app/code/core/Mage/Adminhtml/controllers/Report/ReviewController.php
index f6338e1af12..82978e8a46c 100644
--- a/app/code/core/Mage/Adminhtml/controllers/Report/ReviewController.php
+++ b/app/code/core/Mage/Adminhtml/controllers/Report/ReviewController.php
@@ -158,19 +158,19 @@ public function exportProductDetailExcelAction()
         $this->_prepareDownloadResponse($fileName, $content);
     }
 
+    /**
+     * @inheritDoc
+     */
     protected function _isAllowed()
     {
         $action = strtolower($this->getRequest()->getActionName());
         switch ($action) {
             case 'customer':
                 return Mage::getSingleton('admin/session')->isAllowed('report/review/customer');
-                break;
             case 'product':
                 return Mage::getSingleton('admin/session')->isAllowed('report/review/product');
-                break;
             default:
                 return Mage::getSingleton('admin/session')->isAllowed('report/review');
-                break;
         }
     }
 }
diff --git a/app/code/core/Mage/Adminhtml/controllers/Report/SalesController.php b/app/code/core/Mage/Adminhtml/controllers/Report/SalesController.php
index 102c72f1afa..d6caa67393c 100644
--- a/app/code/core/Mage/Adminhtml/controllers/Report/SalesController.php
+++ b/app/code/core/Mage/Adminhtml/controllers/Report/SalesController.php
@@ -387,34 +387,29 @@ public function refreshStatisticsAction()
         return $this->_forward('index', 'report_statistics');
     }
 
+    /**
+     * @inheritDoc
+     */
     protected function _isAllowed()
     {
         $action = strtolower($this->getRequest()->getActionName());
         switch ($action) {
             case 'sales':
                 return $this->_getSession()->isAllowed('report/salesroot/sales');
-                break;
             case 'tax':
                 return $this->_getSession()->isAllowed('report/salesroot/tax');
-                break;
             case 'shipping':
                 return $this->_getSession()->isAllowed('report/salesroot/shipping');
-                break;
             case 'invoiced':
                 return $this->_getSession()->isAllowed('report/salesroot/invoiced');
-                break;
             case 'refunded':
                 return $this->_getSession()->isAllowed('report/salesroot/refunded');
-                break;
             case 'coupons':
                 return $this->_getSession()->isAllowed('report/salesroot/coupons');
-                break;
             case 'bestsellers':
                 return $this->_getSession()->isAllowed('report/products/bestsellers');
-                break;
             default:
                 return $this->_getSession()->isAllowed('report/salesroot');
-                break;
         }
     }
 }
diff --git a/app/code/core/Mage/Adminhtml/controllers/Report/ShopcartController.php b/app/code/core/Mage/Adminhtml/controllers/Report/ShopcartController.php
index dcc5fdf0d57..529a44d581d 100644
--- a/app/code/core/Mage/Adminhtml/controllers/Report/ShopcartController.php
+++ b/app/code/core/Mage/Adminhtml/controllers/Report/ShopcartController.php
@@ -153,22 +153,21 @@ public function exportAbandonedExcelAction()
         $this->_prepareDownloadResponse($fileName, $content);
     }
 
+    /**
+     * @inheritDoc
+     */
     protected function _isAllowed()
     {
         $action = strtolower($this->getRequest()->getActionName());
         switch ($action) {
             case 'customer':
                 return Mage::getSingleton('admin/session')->isAllowed('report/shopcart/customer');
-                break;
             case 'product':
                 return Mage::getSingleton('admin/session')->isAllowed('report/shopcart/product');
-                break;
             case 'abandoned':
                 return Mage::getSingleton('admin/session')->isAllowed('report/shopcart/abandoned');
-                break;
             default:
                 return Mage::getSingleton('admin/session')->isAllowed('report/shopcart');
-                break;
         }
     }
 }
diff --git a/app/code/core/Mage/Adminhtml/controllers/Report/StatisticsController.php b/app/code/core/Mage/Adminhtml/controllers/Report/StatisticsController.php
index dbd27a8a0fe..5a788f00e93 100644
--- a/app/code/core/Mage/Adminhtml/controllers/Report/StatisticsController.php
+++ b/app/code/core/Mage/Adminhtml/controllers/Report/StatisticsController.php
@@ -33,6 +33,12 @@
  */
 class Mage_Adminhtml_Report_StatisticsController extends Mage_Adminhtml_Controller_Action
 {
+    /**
+     * ACL resource
+     * @see Mage_Adminhtml_Controller_Action::_isAllowed()
+     */
+    const ADMIN_RESOURCE = 'report/statistics';
+
     /**
      * Admin session model
      *
@@ -119,7 +125,7 @@ protected function _getCollectionNames()
     /**
      * Refresh statistics for last 25 hours
      *
-     * @return Mage_Adminhtml_Report_SalesController
+     * @return $this
      */
     public function refreshRecentAction()
     {
@@ -149,7 +155,7 @@ public function refreshRecentAction()
     /**
      * Refresh statistics for all period
      *
-     * @return Mage_Adminhtml_Report_SalesController
+     * @return $this
      */
     public function refreshLifetimeAction()
     {
@@ -185,11 +191,6 @@ public function indexAction()
             ->renderLayout();
     }
 
-    protected function _isAllowed()
-    {
-        return $this->_getSession()->isAllowed('report/statistics');
-    }
-
     /**
      * Retrieve admin session model
      *
diff --git a/app/code/core/Mage/Adminhtml/controllers/Report/TagController.php b/app/code/core/Mage/Adminhtml/controllers/Report/TagController.php
index 6a1167a022e..b38984ea122 100644
--- a/app/code/core/Mage/Adminhtml/controllers/Report/TagController.php
+++ b/app/code/core/Mage/Adminhtml/controllers/Report/TagController.php
@@ -280,25 +280,22 @@ public function exportTagDetailExcelAction()
         $this->_prepareDownloadResponse($fileName, $content);
     }
 
+    /**
+     * @inheritDoc
+     */
     protected function _isAllowed()
     {
         $action = strtolower($this->getRequest()->getActionName());
         switch ($action) {
             case 'customer':
                 return Mage::getSingleton('admin/session')->isAllowed('report/tags/customer');
-                break;
-            case 'product':
-                return Mage::getSingleton('admin/session')->isAllowed('report/tags/product');
-                break;
             case 'productall':
+            case 'product':
                 return Mage::getSingleton('admin/session')->isAllowed('report/tags/product');
-                break;
             case 'popular':
                 return Mage::getSingleton('admin/session')->isAllowed('report/tags/popular');
-                break;
             default:
                 return Mage::getSingleton('admin/session')->isAllowed('report/tags');
-                break;
         }
     }
 }
diff --git a/app/code/core/Mage/Adminhtml/controllers/ReportController.php b/app/code/core/Mage/Adminhtml/controllers/ReportController.php
index 9eb58cbb0af..57b4d3e55a9 100644
--- a/app/code/core/Mage/Adminhtml/controllers/ReportController.php
+++ b/app/code/core/Mage/Adminhtml/controllers/ReportController.php
@@ -40,41 +40,6 @@ public function _initAction()
         return $this;
     }
 
-
-/*
-    public function wishlistAction()
-    {
-        $this->_initAction()
-            ->_setActiveMenu('report/wishlist')
-            ->_addBreadcrumb(Mage::helper('adminhtml')->__('Wishlist Report'), Mage::helper('adminhtml')->__('Wishlist Report'))
-            ->_addContent($this->getLayout()->createBlock('adminhtml/report_wishlist'))
-            ->renderLayout();
-    }
-
-    /**
-     * Export wishlist report grid to CSV format
-     * /
-    public function exportWishlistCsvAction()
-    {
-        $fileName   = 'wishlist.csv';
-        $content    = $this->getLayout()->createBlock('adminhtml/report_wishlist_grid')
-            ->getCsvFile();
-
-        $this->_prepareDownloadResponse($fileName, $content);
-    }
-
-    /**
-     * Export wishlist report to Excel XML format
-     * /
-    public function exportWishlistExcelAction()
-    {
-        $fileName   = 'wishlist.xml';
-        $content    = $this->getLayout()->createBlock('adminhtml/report_wishlist_grid')
-            ->getExcelFile($fileName);
-
-        $this->_prepareDownloadResponse($fileName, $content);
-    }
-*/
     public function searchAction()
     {
         $this->_title($this->__('Reports'))->_title($this->__('Search Terms'));
@@ -111,39 +76,18 @@ public function exportSearchExcelAction()
 
         $this->_prepareDownloadResponse($fileName, $content);
     }
-/*
-    public function ordersAction()
-    {
-        $this->_initAction()
-            ->_setActiveMenu('report/orders')
-            ->_addBreadcrumb(Mage::helper('adminhtml')->__('Recent Orders'), Mage::helper('adminhtml')->__('Recent Orders'))
-            ->renderLayout();
-    }
-
-    public function totalsAction()
-    {
-        $this->_initAction()
-            ->_setActiveMenu('report/totals')
-            ->_addBreadcrumb(Mage::helper('adminhtml')->__('Order Totals'), Mage::helper('adminhtml')->__('Order Totals'))
-            ->renderLayout();
-    }
-*/
 
+    /**
+     * @inheritDoc
+     */
     protected function _isAllowed()
     {
         $action = strtolower($this->getRequest()->getActionName());
         switch ($action) {
             case 'search':
                 return Mage::getSingleton('admin/session')->isAllowed('report/search');
-                break;
-            /*
-            case 'customers':
-                return Mage::getSingleton('admin/session')->isAllowed('report/shopcart');
-                break;
-            */
             default:
                 return Mage::getSingleton('admin/session')->isAllowed('report');
-                break;
         }
     }
 }
diff --git a/app/code/core/Mage/Adminhtml/controllers/Rss/CatalogController.php b/app/code/core/Mage/Adminhtml/controllers/Rss/CatalogController.php
index d53396df3c0..198322e6c34 100644
--- a/app/code/core/Mage/Adminhtml/controllers/Rss/CatalogController.php
+++ b/app/code/core/Mage/Adminhtml/controllers/Rss/CatalogController.php
@@ -35,9 +35,7 @@
 class Mage_Adminhtml_Rss_CatalogController extends Mage_Adminhtml_Controller_Rss_Abstract
 {
     /**
-     * Check is allowed access to action
-     *
-     * @return bool
+     * @inheritDoc
      */
     protected function _isAllowed()
     {
diff --git a/app/code/core/Mage/Adminhtml/controllers/Rss/OrderController.php b/app/code/core/Mage/Adminhtml/controllers/Rss/OrderController.php
index 194c783589a..eb276497299 100644
--- a/app/code/core/Mage/Adminhtml/controllers/Rss/OrderController.php
+++ b/app/code/core/Mage/Adminhtml/controllers/Rss/OrderController.php
@@ -34,6 +34,11 @@
 
 class Mage_Adminhtml_Rss_OrderController extends Mage_Adminhtml_Controller_Rss_Abstract
 {
+    /**
+     * ACL resource
+     * @see Mage_Adminhtml_Controller_Action::_isAllowed()
+     */
+    const ADMIN_RESOURCE = 'sales/order/actions/view';
 
     public function newAction()
     {
@@ -42,14 +47,4 @@ public function newAction()
             $this->renderLayout();
         }
     }
-
-    /**
-     * Check is allowed access to action
-     *
-     * @return bool
-     */
-    protected function _isAllowed()
-    {
-        return Mage::getSingleton('admin/session')->isAllowed('sales/order/actions/view');
-    }
 }
diff --git a/app/code/core/Mage/Adminhtml/controllers/Sales/Billing/AgreementController.php b/app/code/core/Mage/Adminhtml/controllers/Sales/Billing/AgreementController.php
index 0471011a636..6b4f542e6c9 100644
--- a/app/code/core/Mage/Adminhtml/controllers/Sales/Billing/AgreementController.php
+++ b/app/code/core/Mage/Adminhtml/controllers/Sales/Billing/AgreementController.php
@@ -197,26 +197,21 @@ protected function _getSession()
     }
 
     /**
-     * Check currently called action by permissions for current user
-     *
-     * @return bool
+     * @inheritDoc
      */
     protected function _isAllowed()
     {
         $action = strtolower($this->getRequest()->getActionName());
         switch ($action) {
             case 'index':
-            case 'grid' :
-            case 'view' :
+            case 'grid':
+            case 'view':
                 return Mage::getSingleton('admin/session')->isAllowed('sales/billing_agreement/actions/view');
-                break;
             case 'cancel':
             case 'delete':
                 return Mage::getSingleton('admin/session')->isAllowed('sales/billing_agreement/actions/manage');
-                break;
             default:
                 return Mage::getSingleton('admin/session')->isAllowed('sales/billing_agreement');
-                break;
         }
     }
 }
diff --git a/app/code/core/Mage/Adminhtml/controllers/Sales/Order/CreateController.php b/app/code/core/Mage/Adminhtml/controllers/Sales/Order/CreateController.php
index d79eb6b3b2d..4d7f5e16c3b 100644
--- a/app/code/core/Mage/Adminhtml/controllers/Sales/Order/CreateController.php
+++ b/app/code/core/Mage/Adminhtml/controllers/Sales/Order/CreateController.php
@@ -543,9 +543,7 @@ public function saveAction()
     }
 
     /**
-     * Acl check for admin
-     *
-     * @return bool
+     * @inheritDoc
      */
     protected function _isAllowed()
     {
diff --git a/app/code/core/Mage/Adminhtml/controllers/Sales/Order/EditController.php b/app/code/core/Mage/Adminhtml/controllers/Sales/Order/EditController.php
index da122dbbe08..0b1ec2c9940 100644
--- a/app/code/core/Mage/Adminhtml/controllers/Sales/Order/EditController.php
+++ b/app/code/core/Mage/Adminhtml/controllers/Sales/Order/EditController.php
@@ -34,6 +34,12 @@
  */
 class Mage_Adminhtml_Sales_Order_EditController extends Mage_Adminhtml_Sales_Order_CreateController
 {
+    /**
+     * ACL resource
+     * @see Mage_Adminhtml_Controller_Action::_isAllowed()
+     */
+    const ADMIN_RESOURCE = 'sales/order/actions/edit';
+
     /**
      * Start edit order initialization
      */
@@ -73,14 +79,4 @@ public function indexAction()
             ->_setActiveMenu('sales/order')
             ->renderLayout();
     }
-
-    /**
-     * Acl check for admin
-     *
-     * @return bool
-     */
-    protected function _isAllowed()
-    {
-        return Mage::getSingleton('admin/session')->isAllowed('sales/order/actions/edit');
-    }
 }
diff --git a/app/code/core/Mage/Adminhtml/controllers/Sales/Order/StatusController.php b/app/code/core/Mage/Adminhtml/controllers/Sales/Order/StatusController.php
index 4c969b9808f..fa4726cfc0c 100644
--- a/app/code/core/Mage/Adminhtml/controllers/Sales/Order/StatusController.php
+++ b/app/code/core/Mage/Adminhtml/controllers/Sales/Order/StatusController.php
@@ -33,9 +33,14 @@
  */
 class Mage_Adminhtml_Sales_Order_StatusController extends Mage_Adminhtml_Controller_Action
 {
+    /**
+     * ACL resource
+     * @see Mage_Adminhtml_Controller_Action::_isAllowed()
+     */
+    const ADMIN_RESOURCE = 'system/order_statuses';
+
     /**
      * Additional initialization
-     *
      */
     protected function _construct()
     {
@@ -233,14 +238,4 @@ public function unassignAction()
         }
         $this->_redirect('*/*/');
     }
-
-    /**
-     * Check current user permission on resource and privilege
-     *
-     * @return bool
-     */
-    protected function _isAllowed()
-    {
-        return Mage::getSingleton('admin/session')->isAllowed('system/order_statuses');
-    }
 }
diff --git a/app/code/core/Mage/Adminhtml/controllers/Sales/Order/View/GiftmessageController.php b/app/code/core/Mage/Adminhtml/controllers/Sales/Order/View/GiftmessageController.php
index 4c1985cce11..10ce3d2a1d7 100644
--- a/app/code/core/Mage/Adminhtml/controllers/Sales/Order/View/GiftmessageController.php
+++ b/app/code/core/Mage/Adminhtml/controllers/Sales/Order/View/GiftmessageController.php
@@ -34,9 +34,14 @@
  */
 class Mage_Adminhtml_Sales_Order_View_GiftmessageController extends Mage_Adminhtml_Controller_Action
 {
+    /**
+     * ACL resource
+     * @see Mage_Adminhtml_Controller_Action::_isAllowed()
+     */
+    const ADMIN_RESOURCE = 'sales/order';
+
     /**
      * Additional initialization
-     *
      */
     protected function _construct()
     {
@@ -75,15 +80,4 @@ protected function _getGiftmessageSaveModel()
     {
         return Mage::getSingleton('adminhtml/giftmessage_save');
     }
-
-    /**
-     * Acl check for admin
-     *
-     * @return bool
-     */
-    protected function _isAllowed()
-    {
-        return Mage::getSingleton('admin/session')->isAllowed('sales/order');
-    }
-
 }
diff --git a/app/code/core/Mage/Adminhtml/controllers/Sales/OrderController.php b/app/code/core/Mage/Adminhtml/controllers/Sales/OrderController.php
index baaf3239059..73a128153a0 100644
--- a/app/code/core/Mage/Adminhtml/controllers/Sales/OrderController.php
+++ b/app/code/core/Mage/Adminhtml/controllers/Sales/OrderController.php
@@ -655,9 +655,7 @@ public function voidPaymentAction()
     }
 
     /**
-     * Acl check for admin
-     *
-     * @return bool
+     * @inheritDoc
      */
     protected function _isAllowed()
     {
@@ -782,7 +780,7 @@ public function addressSaveAction()
     }
 
     /**
-     * Controller predispatch method
+     * Controller pre-dispatch method
      *
      * @return Mage_Adminhtml_Controller_Action
      */
diff --git a/app/code/core/Mage/Adminhtml/controllers/Sales/Recurring/ProfileController.php b/app/code/core/Mage/Adminhtml/controllers/Sales/Recurring/ProfileController.php
index a5f62c17f6d..50129aba9c3 100644
--- a/app/code/core/Mage/Adminhtml/controllers/Sales/Recurring/ProfileController.php
+++ b/app/code/core/Mage/Adminhtml/controllers/Sales/Recurring/ProfileController.php
@@ -31,10 +31,16 @@
  */
 class Mage_Adminhtml_Sales_Recurring_ProfileController extends Mage_Adminhtml_Controller_Action
 {
+    /**
+     * ACL resource
+     * @see Mage_Adminhtml_Controller_Action::_isAllowed()
+     */
+    const ADMIN_RESOURCE = 'sales/recurring_profile';
+
     /**
      * Recurring profiles list
      *
-     * @return void
+     * @return $this
      */
     public function indexAction()
     {
@@ -173,7 +179,7 @@ public function customerGridAction()
     /**
      * Initialize customer by ID specified in request
      *
-     * @return Mage_Adminhtml_Sales_Billing_AgreementController
+     * @return $this
      */
     protected function _initCustomer()
     {
@@ -202,14 +208,4 @@ protected function _initProfile()
         Mage::register('current_recurring_profile', $profile);
         return $profile;
     }
-
-    /**
-     * Check is allowed access to action
-     *
-     * @return bool
-     */
-    protected function _isAllowed()
-    {
-        return Mage::getSingleton('admin/session')->isAllowed('sales/recurring_profile');
-    }
 }
diff --git a/app/code/core/Mage/Adminhtml/controllers/Sales/TransactionsController.php b/app/code/core/Mage/Adminhtml/controllers/Sales/TransactionsController.php
index 8d6e5d3fce1..0d1ab3445b0 100644
--- a/app/code/core/Mage/Adminhtml/controllers/Sales/TransactionsController.php
+++ b/app/code/core/Mage/Adminhtml/controllers/Sales/TransactionsController.php
@@ -125,8 +125,7 @@ public function fetchAction()
     }
 
     /**
-     * Check currently called action by permissions for current user
-     *
+     * @inheritDoc
      */
     protected function _isAllowed()
     {
@@ -134,10 +133,8 @@ protected function _isAllowed()
         switch ($action) {
             case 'fetch':
                 return Mage::getSingleton('admin/session')->isAllowed('sales/transactions/fetch');
-                break;
             default:
                 return Mage::getSingleton('admin/session')->isAllowed('sales/transactions');
-                break;
         }
     }
 }
diff --git a/app/code/core/Mage/Adminhtml/controllers/SalesController.php b/app/code/core/Mage/Adminhtml/controllers/SalesController.php
index 9f0374e7af7..102b65020f3 100644
--- a/app/code/core/Mage/Adminhtml/controllers/SalesController.php
+++ b/app/code/core/Mage/Adminhtml/controllers/SalesController.php
@@ -33,6 +33,12 @@
  */
 class Mage_Adminhtml_SalesController extends Mage_Adminhtml_Controller_Action
 {
+    /**
+     * ACL resource
+     * @see Mage_Adminhtml_Controller_Action::_isAllowed()
+     */
+    const ADMIN_RESOURCE = 'sales';
+
     /**
      * Additional initialization
      *
@@ -54,9 +60,4 @@ public function indexAction()
         $this->_addBreadcrumb($this->__('Orders'), $this->__('Orders'));
         $this->renderLayout();
     }
-
-    protected function _isAllowed()
-    {
-        return Mage::getSingleton('admin/session')->isAllowed('sales');
-    }
 }
diff --git a/app/code/core/Mage/Adminhtml/controllers/SitemapController.php b/app/code/core/Mage/Adminhtml/controllers/SitemapController.php
index e1a6160903f..898a4eb0d6b 100644
--- a/app/code/core/Mage/Adminhtml/controllers/SitemapController.php
+++ b/app/code/core/Mage/Adminhtml/controllers/SitemapController.php
@@ -33,13 +33,19 @@
  */
 class Mage_Adminhtml_SitemapController extends  Mage_Adminhtml_Controller_Action
 {
+    /**
+     * ACL resource
+     * @see Mage_Adminhtml_Controller_Action::_isAllowed()
+     */
+    const ADMIN_RESOURCE = 'catalog/sitemap';
+
     /**
      * Maximum sitemap name length
      */
     const MAXIMUM_SITEMAP_NAME_LENGTH = 32;
 
     /**
-     * Controller predispatch method
+     * Controller pre-dispatch method
      *
      * @return Mage_Adminhtml_Controller_Action
      */
@@ -301,14 +307,4 @@ public function generateAction()
         // go to grid
         $this->_redirect('*/*/');
     }
-
-    /**
-     * Check the permission to run it
-     *
-     * @return boolean
-     */
-    protected function _isAllowed()
-    {
-        return Mage::getSingleton('admin/session')->isAllowed('catalog/sitemap');
-    }
 }
diff --git a/app/code/core/Mage/Adminhtml/controllers/System/AccountController.php b/app/code/core/Mage/Adminhtml/controllers/System/AccountController.php
index f9817a99a90..bb1a4cf6bf8 100644
--- a/app/code/core/Mage/Adminhtml/controllers/System/AccountController.php
+++ b/app/code/core/Mage/Adminhtml/controllers/System/AccountController.php
@@ -34,6 +34,12 @@
 
 class Mage_Adminhtml_System_AccountController extends Mage_Adminhtml_Controller_Action
 {
+    /**
+     * ACL resource
+     * @see Mage_Adminhtml_Controller_Action::_isAllowed()
+     */
+    const ADMIN_RESOURCE = 'system/myaccount';
+
     public function indexAction()
     {
         $this->_title($this->__('System'))->_title($this->__('My Account'));
@@ -95,9 +101,4 @@ public function saveAction()
         }
         $this->getResponse()->setRedirect($this->getUrl("*/*/"));
     }
-
-    protected function _isAllowed()
-    {
-        return Mage::getSingleton('admin/session')->isAllowed('system/myaccount');
-    }
 }
diff --git a/app/code/core/Mage/Adminhtml/controllers/System/BackupController.php b/app/code/core/Mage/Adminhtml/controllers/System/BackupController.php
index 6ab8c45189f..3e1c8e58c62 100644
--- a/app/code/core/Mage/Adminhtml/controllers/System/BackupController.php
+++ b/app/code/core/Mage/Adminhtml/controllers/System/BackupController.php
@@ -34,7 +34,7 @@
 class Mage_Adminhtml_System_BackupController extends Mage_Adminhtml_Controller_Action
 {
     /**
-     * Controller predispatch method
+     * Controller pre-dispatch method
      *
      * @return Mage_Adminhtml_Controller_Action
      */
@@ -363,9 +363,7 @@ public function massDeleteAction()
     }
 
     /**
-     * Check Permissions for all actions
-     *
-     * @return bool
+     * @inheritDoc
      */
     protected function _isAllowed()
     {
diff --git a/app/code/core/Mage/Adminhtml/controllers/System/CacheController.php b/app/code/core/Mage/Adminhtml/controllers/System/CacheController.php
index 71b8ab3c65e..daced178b84 100644
--- a/app/code/core/Mage/Adminhtml/controllers/System/CacheController.php
+++ b/app/code/core/Mage/Adminhtml/controllers/System/CacheController.php
@@ -33,6 +33,12 @@
  */
 class Mage_Adminhtml_System_CacheController extends Mage_Adminhtml_Controller_Action
 {
+    /**
+     * ACL resource
+     * @see Mage_Adminhtml_Controller_Action::_isAllowed()
+     */
+    const ADMIN_RESOURCE = 'system/cache';
+
     /**
      * Retrieve session model
      *
@@ -333,9 +339,4 @@ public function refreshLayeredNavigationAction()
 
         $this->_redirect('*/*');
     }
-
-    protected function _isAllowed()
-    {
-        return Mage::getSingleton('admin/session')->isAllowed('system/cache');
-    }
 }
diff --git a/app/code/core/Mage/Adminhtml/controllers/System/Config/System/StorageController.php b/app/code/core/Mage/Adminhtml/controllers/System/Config/System/StorageController.php
index bbbdec4e9bf..970f48a4a8e 100644
--- a/app/code/core/Mage/Adminhtml/controllers/System/Config/System/StorageController.php
+++ b/app/code/core/Mage/Adminhtml/controllers/System/Config/System/StorageController.php
@@ -33,6 +33,12 @@
  */
 class Mage_Adminhtml_System_Config_System_StorageController extends Mage_Adminhtml_Controller_Action
 {
+    /**
+     * ACL resource
+     * @see Mage_Adminhtml_Controller_Action::_isAllowed()
+     */
+    const ADMIN_RESOURCE = 'system/config';
+
     /**
      * Return file storage singleton
      *
@@ -180,14 +186,4 @@ public function statusAction()
         $result = Mage::helper('core')->jsonEncode($result);
         Mage::app()->getResponse()->setBody($result);
     }
-
-    /**
-     * Check is allowed access to action
-     *
-     * @return bool
-     */
-    protected function _isAllowed()
-    {
-        return Mage::getSingleton('admin/session')->isAllowed('system/config');
-    }
 }
diff --git a/app/code/core/Mage/Adminhtml/controllers/System/ConfigController.php b/app/code/core/Mage/Adminhtml/controllers/System/ConfigController.php
index 697409e6671..693ac942a1c 100644
--- a/app/code/core/Mage/Adminhtml/controllers/System/ConfigController.php
+++ b/app/code/core/Mage/Adminhtml/controllers/System/ConfigController.php
@@ -33,6 +33,12 @@
  */
 class Mage_Adminhtml_System_ConfigController extends Mage_Adminhtml_Controller_Action
 {
+    /**
+     * ACL resource
+     * @see Mage_Adminhtml_Controller_Action::_isAllowed()
+     */
+    const ADMIN_RESOURCE = 'system/config';
+
     /**
      * Whether current section is allowed
      *
@@ -41,7 +47,7 @@ class Mage_Adminhtml_System_ConfigController extends Mage_Adminhtml_Controller_A
     protected $_isSectionAllowedFlag = true;
 
     /**
-     * Controller predispatch method
+     * Controller pre-dispatch method
      * Check if current section is found and is allowed
      *
      * @return $this
@@ -256,16 +262,6 @@ public function exportTableratesAction()
         $this->_prepareDownloadResponse($fileName, $content);
     }
 
-    /**
-     * Check is allow modify system configuration
-     *
-     * @return bool
-     */
-    protected function _isAllowed()
-    {
-        return Mage::getSingleton('admin/session')->isAllowed('system/config');
-    }
-
     /**
      * Check if specified section allowed in ACL
      *
diff --git a/app/code/core/Mage/Adminhtml/controllers/System/Convert/GuiController.php b/app/code/core/Mage/Adminhtml/controllers/System/Convert/GuiController.php
index 302a0e32ad7..4ff4eda8e6e 100644
--- a/app/code/core/Mage/Adminhtml/controllers/System/Convert/GuiController.php
+++ b/app/code/core/Mage/Adminhtml/controllers/System/Convert/GuiController.php
@@ -35,6 +35,12 @@
  */
 class Mage_Adminhtml_System_Convert_GuiController extends Mage_Adminhtml_System_Convert_ProfileController
 {
+    /**
+     * ACL resource
+     * @see Mage_Adminhtml_Controller_Action::_isAllowed()
+     */
+    const ADMIN_RESOURCE = 'admin/system/convert/gui';
+
     /**
      * Profiles list action
      */
@@ -131,9 +137,4 @@ public function downloadAction()
         $this->_initProfile();
         $profile = Mage::registry('current_convert_profile');
     }
-
-    protected function _isAllowed()
-    {
-        return Mage::getSingleton('admin/session')->isAllowed('admin/system/convert/gui');
-    }
 }
diff --git a/app/code/core/Mage/Adminhtml/controllers/System/Convert/ProfileController.php b/app/code/core/Mage/Adminhtml/controllers/System/Convert/ProfileController.php
index d4796f9254d..490f58362ec 100644
--- a/app/code/core/Mage/Adminhtml/controllers/System/Convert/ProfileController.php
+++ b/app/code/core/Mage/Adminhtml/controllers/System/Convert/ProfileController.php
@@ -33,6 +33,12 @@
  */
 class Mage_Adminhtml_System_Convert_ProfileController extends Mage_Adminhtml_Controller_Action
 {
+    /**
+     * ACL resource
+     * @see Mage_Adminhtml_Controller_Action::_isAllowed()
+     */
+    const ADMIN_RESOURCE = 'admin/system/convert/profiles';
+
     protected function _initProfile($idFieldName = 'id')
     {
         $this->_title($this->__('System'))
@@ -302,17 +308,12 @@ public function batchFinishAction()
 
     /**
      * Customer orders grid
-     *
      */
-    public function historyAction() {
+    public function historyAction()
+    {
         $this->_initProfile();
         $this->getResponse()->setBody(
             $this->getLayout()->createBlock('adminhtml/system_convert_profile_edit_tab_history')->toHtml()
         );
     }
-
-    protected function _isAllowed()
-    {
-        return Mage::getSingleton('admin/session')->isAllowed('admin/system/convert/profiles');
-    }
 }
diff --git a/app/code/core/Mage/Adminhtml/controllers/System/CurrencyController.php b/app/code/core/Mage/Adminhtml/controllers/System/CurrencyController.php
index ecd09a747aa..1150ceddaa1 100644
--- a/app/code/core/Mage/Adminhtml/controllers/System/CurrencyController.php
+++ b/app/code/core/Mage/Adminhtml/controllers/System/CurrencyController.php
@@ -33,6 +33,12 @@
  */
 class Mage_Adminhtml_System_CurrencyController extends Mage_Adminhtml_Controller_Action
 {
+    /**
+     * ACL resource
+     * @see Mage_Adminhtml_Controller_Action::_isAllowed()
+     */
+    const ADMIN_RESOURCE = 'system/currency/rates';
+
     /**
      * Init currency by currency code from request
      *
@@ -119,9 +125,4 @@ public function saveRatesAction()
 
         $this->_redirect('*/*/');
     }
-
-    protected function _isAllowed()
-    {
-        return Mage::getSingleton('admin/session')->isAllowed('system/currency/rates');
-    }
 }
diff --git a/app/code/core/Mage/Adminhtml/controllers/System/DesignController.php b/app/code/core/Mage/Adminhtml/controllers/System/DesignController.php
index 671c6f4b0cb..c14a346f550 100644
--- a/app/code/core/Mage/Adminhtml/controllers/System/DesignController.php
+++ b/app/code/core/Mage/Adminhtml/controllers/System/DesignController.php
@@ -24,11 +24,16 @@
  * @license    http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
 
-
 class Mage_Adminhtml_System_DesignController extends Mage_Adminhtml_Controller_Action
 {
     /**
-     * Controller predispatch method
+     * ACL resource
+     * @see Mage_Adminhtml_Controller_Action::_isAllowed()
+     */
+    const ADMIN_RESOURCE = 'system/design';
+
+    /**
+     * Controller pre-dispatch method
      *
      * @return Mage_Adminhtml_Controller_Action
      */
@@ -137,9 +142,4 @@ public function deleteAction()
         }
         $this->getResponse()->setRedirect($this->getUrl('*/*/'));
     }
-
-    protected function _isAllowed()
-    {
-        return Mage::getSingleton('admin/session')->isAllowed('system/design');
-    }
 }
diff --git a/app/code/core/Mage/Adminhtml/controllers/System/Email/TemplateController.php b/app/code/core/Mage/Adminhtml/controllers/System/Email/TemplateController.php
index f177d9a5388..3a4df726492 100644
--- a/app/code/core/Mage/Adminhtml/controllers/System/Email/TemplateController.php
+++ b/app/code/core/Mage/Adminhtml/controllers/System/Email/TemplateController.php
@@ -33,6 +33,12 @@
  */
 class Mage_Adminhtml_System_Email_TemplateController extends Mage_Adminhtml_Controller_Action
 {
+    /**
+     * ACL resource
+     * @see Mage_Adminhtml_Controller_Action::_isAllowed()
+     */
+    const ADMIN_RESOURCE = 'system/email_template';
+
     /**
      * Index action
      */
@@ -230,7 +236,7 @@ public function defaultTemplateAction()
     }
 
     /**
-     * Controller predispatch method
+     * Controller pre-dispatch method
      *
      * @return Mage_Adminhtml_Controller_Action
      */
@@ -263,14 +269,4 @@ protected function _initTemplate($idFieldName = 'template_id')
         }
         return $model;
     }
-
-    /**
-     * Check permissions
-     *
-     * @return bool
-     */
-    protected function _isAllowed()
-    {
-        return Mage::getSingleton('admin/session')->isAllowed('system/email_template');
-    }
 }
diff --git a/app/code/core/Mage/Adminhtml/controllers/System/StoreController.php b/app/code/core/Mage/Adminhtml/controllers/System/StoreController.php
index 684f38e23c2..be650828fd8 100644
--- a/app/code/core/Mage/Adminhtml/controllers/System/StoreController.php
+++ b/app/code/core/Mage/Adminhtml/controllers/System/StoreController.php
@@ -33,11 +33,17 @@
  */
 class Mage_Adminhtml_System_StoreController extends Mage_Adminhtml_Controller_Action
 {
-   /**
-     * Controller predispatch method
-     *
-     * @return Mage_Adminhtml_Controller_Action
+    /**
+     * ACL resource
+     * @see Mage_Adminhtml_Controller_Action::_isAllowed()
      */
+    const ADMIN_RESOURCE = 'system/store';
+
+   /**
+    * Controller pre-dispatch method
+    *
+    * @return Mage_Adminhtml_Controller_Action
+    */
     public function preDispatch()
     {
         $this->_setForcedFormKeyActions(array('deleteWebsitePost', 'deleteGroupPost', 'deleteStorePost'));
@@ -456,11 +462,6 @@ public function deleteStorePostAction()
         $this->_redirect('*/*/editStore', array('store_id' => $itemId));
     }
 
-    protected function _isAllowed()
-    {
-        return Mage::getSingleton('admin/session')->isAllowed('system/store');
-    }
-
     /**
      * Backup database
      *
diff --git a/app/code/core/Mage/Adminhtml/controllers/System/VariableController.php b/app/code/core/Mage/Adminhtml/controllers/System/VariableController.php
index 4eb5e7ed649..d5106732d39 100644
--- a/app/code/core/Mage/Adminhtml/controllers/System/VariableController.php
+++ b/app/code/core/Mage/Adminhtml/controllers/System/VariableController.php
@@ -33,6 +33,12 @@
  */
 class Mage_Adminhtml_System_VariableController extends Mage_Adminhtml_Controller_Action
 {
+    /**
+     * ACL resource
+     * @see Mage_Adminhtml_Controller_Action::_isAllowed()
+     */
+    const ADMIN_RESOURCE = 'system/variable';
+
     /**
      * Initialize Layout and set breadcrumbs
      *
@@ -69,7 +75,6 @@ protected function _initVariable()
 
     /**
      * Index Action
-     *
      */
     public function indexAction()
     {
@@ -82,7 +87,6 @@ public function indexAction()
 
     /**
      * New Action (forward to edit action)
-     *
      */
     public function newAction()
     {
@@ -91,7 +95,6 @@ public function newAction()
 
     /**
      * Edit Action
-     *
      */
     public function editAction()
     {
@@ -109,7 +112,6 @@ public function editAction()
 
     /**
      * Validate Action
-     *
      */
     public function validateAction()
     {
@@ -128,7 +130,6 @@ public function validateAction()
 
     /**
      * Save Action
-     *
      */
     public function saveAction()
     {
@@ -161,7 +162,6 @@ public function saveAction()
 
     /**
      * Delete Action
-     *
      */
     public function deleteAction()
     {
@@ -193,14 +193,4 @@ public function wysiwygPluginAction()
         $variables = array($storeContactVariabls, $customVariables);
         $this->getResponse()->setBody(Zend_Json::encode($variables));
     }
-
-    /**
-     * Check current user permission
-     *
-     * @return boolean
-     */
-    protected function _isAllowed()
-    {
-        return Mage::getSingleton('admin/session')->isAllowed('system/variable');
-    }
 }
diff --git a/app/code/core/Mage/Adminhtml/controllers/SystemController.php b/app/code/core/Mage/Adminhtml/controllers/SystemController.php
index 1715e17c7a6..f3e43bf71b1 100644
--- a/app/code/core/Mage/Adminhtml/controllers/SystemController.php
+++ b/app/code/core/Mage/Adminhtml/controllers/SystemController.php
@@ -33,6 +33,12 @@
  */
 class Mage_Adminhtml_SystemController extends Mage_Adminhtml_Controller_Action
 {
+    /**
+     * ACL resource
+     * @see Mage_Adminhtml_Controller_Action::_isAllowed()
+     */
+    const ADMIN_RESOURCE = 'system';
+
     public function indexAction()
     {
         $this->loadLayout();
@@ -49,9 +55,4 @@ public function setStoreAction()
         }
         $this->_redirectReferer();
     }
-
-    protected function _isAllowed()
-    {
-        return Mage::getSingleton('admin/session')->isAllowed('system');
-    }
 }
diff --git a/app/code/core/Mage/Adminhtml/controllers/TagController.php b/app/code/core/Mage/Adminhtml/controllers/TagController.php
index 07b2870b088..23792546900 100644
--- a/app/code/core/Mage/Adminhtml/controllers/TagController.php
+++ b/app/code/core/Mage/Adminhtml/controllers/TagController.php
@@ -340,8 +340,7 @@ public function massStatusAction()
     }
 
     /**
-     * Check currently called action by permissions for current user
-     *
+     * @inheritDoc
      */
     protected function _isAllowed()
     {
@@ -349,13 +348,10 @@ protected function _isAllowed()
         switch ($action) {
             case 'pending':
                 return Mage::getSingleton('admin/session')->isAllowed('catalog/tag/pending');
-                break;
             case 'all':
                 return Mage::getSingleton('admin/session')->isAllowed('catalog/tag/all');
-                break;
             default:
                 return Mage::getSingleton('admin/session')->isAllowed('catalog/tag');
-                break;
         }
     }
 }
diff --git a/app/code/core/Mage/Adminhtml/controllers/Tax/Class/CustomerController.php b/app/code/core/Mage/Adminhtml/controllers/Tax/Class/CustomerController.php
index dd18a77a8b1..e2a7ccfda82 100644
--- a/app/code/core/Mage/Adminhtml/controllers/Tax/Class/CustomerController.php
+++ b/app/code/core/Mage/Adminhtml/controllers/Tax/Class/CustomerController.php
@@ -31,12 +31,16 @@
  * @package    Mage_Adminhtml
  * @author      Magento Core Team 
  */
-
 class Mage_Adminhtml_Tax_Class_CustomerController extends Mage_Adminhtml_Controller_Action
 {
+    /**
+     * ACL resource
+     * @see Mage_Adminhtml_Controller_Action::_isAllowed()
+     */
+    const ADMIN_RESOURCE = 'sales/tax/classes_customer';
+
     /**
      * grid view
-     *
      */
     public function indexAction()
     {
@@ -55,7 +59,6 @@ public function indexAction()
 
     /**
      * new class action
-     *
      */
     public function newAction()
     {
@@ -64,7 +67,6 @@ public function newAction()
 
     /**
      * edit class action
-     *
      */
     public function editAction()
     {
@@ -174,14 +176,4 @@ protected function _initAction()
         ;
         return $this;
     }
-
-    /**
-     * Check current user permission on resource and privilege
-     *
-     * @return bool
-     */
-    protected function _isAllowed()
-    {
-        return Mage::getSingleton('admin/session')->isAllowed('sales/tax/classes_customer');
-    }
 }
diff --git a/app/code/core/Mage/Adminhtml/controllers/Tax/Class/ProductController.php b/app/code/core/Mage/Adminhtml/controllers/Tax/Class/ProductController.php
index 28d88f937a1..ad280d6611c 100644
--- a/app/code/core/Mage/Adminhtml/controllers/Tax/Class/ProductController.php
+++ b/app/code/core/Mage/Adminhtml/controllers/Tax/Class/ProductController.php
@@ -33,9 +33,14 @@
  */
 class Mage_Adminhtml_Tax_Class_ProductController extends Mage_Adminhtml_Controller_Action
 {
+    /**
+     * ACL resource
+     * @see Mage_Adminhtml_Controller_Action::_isAllowed()
+     */
+    const ADMIN_RESOURCE = 'sales/tax/classes_product';
+
     /**
      * view grid
-     *
      */
     public function indexAction()
     {
@@ -53,7 +58,6 @@ public function indexAction()
 
     /**
      * new class action
-     *
      */
     public function newAction()
     {
@@ -62,7 +66,6 @@ public function newAction()
 
     /**
      * edit class action
-     *
      */
     public function editAction()
     {
@@ -107,7 +110,6 @@ public function editAction()
 
     /**
      * delete class action
-     *
      */
     public function deleteAction()
     {
@@ -161,7 +163,7 @@ public function deleteAction()
     /**
      * Initialize action
      *
-     * @return Mage_Adminhtml_Controller_Action
+     * @return $this
      */
     protected function _initAction()
     {
@@ -173,15 +175,4 @@ protected function _initAction()
         ;
         return $this;
     }
-
-    /**
-     * Check current user permission on resource and privilege
-     *
-     * @return bool
-     */
-    protected function _isAllowed()
-    {
-        return Mage::getSingleton('admin/session')->isAllowed('sales/tax/classes_product');
-    }
-
 }
diff --git a/app/code/core/Mage/Adminhtml/controllers/Tax/ClassController.php b/app/code/core/Mage/Adminhtml/controllers/Tax/ClassController.php
index 2f7b0e6c1f1..8902ec730c6 100644
--- a/app/code/core/Mage/Adminhtml/controllers/Tax/ClassController.php
+++ b/app/code/core/Mage/Adminhtml/controllers/Tax/ClassController.php
@@ -91,9 +91,7 @@ protected function _initAction()
     }
 
     /**
-     * Check current user permission on resource and privilege
-     *
-     * @return bool
+     * @inheritDoc
      */
     protected function _isAllowed()
     {
diff --git a/app/code/core/Mage/Adminhtml/controllers/Tax/RateController.php b/app/code/core/Mage/Adminhtml/controllers/Tax/RateController.php
index 3baa6f5d959..7cf3f52b0e7 100644
--- a/app/code/core/Mage/Adminhtml/controllers/Tax/RateController.php
+++ b/app/code/core/Mage/Adminhtml/controllers/Tax/RateController.php
@@ -463,6 +463,9 @@ public function exportPostAction()
         $this->_prepareDownloadResponse('tax_rates.csv', $content);
     }
 
+    /**
+     * @inheritDoc
+     */
     protected function _isAllowed()
     {
 
@@ -470,13 +473,9 @@ protected function _isAllowed()
         switch ($action) {
             case 'importexport':
                 return Mage::getSingleton('admin/session')->isAllowed('sales/tax/import_export');
-                break;
             case 'index':
-                return Mage::getSingleton('admin/session')->isAllowed('sales/tax/rates');
-                break;
             default:
                 return Mage::getSingleton('admin/session')->isAllowed('sales/tax/rates');
-                break;
         }
     }
 }
diff --git a/app/code/core/Mage/Adminhtml/controllers/Tax/RuleController.php b/app/code/core/Mage/Adminhtml/controllers/Tax/RuleController.php
index 855e8629aac..c593cc940d7 100644
--- a/app/code/core/Mage/Adminhtml/controllers/Tax/RuleController.php
+++ b/app/code/core/Mage/Adminhtml/controllers/Tax/RuleController.php
@@ -33,6 +33,12 @@
  */
 class Mage_Adminhtml_Tax_RuleController extends Mage_Adminhtml_Controller_Action
 {
+    /**
+     * ACL resource
+     * @see Mage_Adminhtml_Controller_Action::_isAllowed()
+     */
+    const ADMIN_RESOURCE = 'sales/tax/rules';
+
     /**
      * Index action
      *
@@ -223,16 +229,6 @@ protected function _initAction()
         return $this;
     }
 
-    /**
-     * Check if sales rules is allowed
-     *
-     * @return bool
-     */
-    protected function _isAllowed()
-    {
-        return Mage::getSingleton('admin/session')->isAllowed('sales/tax/rules');
-    }
-
     /**
      * Return model instance
      *
@@ -257,7 +253,7 @@ protected function _getHelperModel($className)
     }
 
     /**
-     * Controller predispatch method
+     * Controller pre-dispatch method
      *
      * @return Mage_Adminhtml_Controller_Action
      */
diff --git a/app/code/core/Mage/Adminhtml/controllers/TaxController.php b/app/code/core/Mage/Adminhtml/controllers/TaxController.php
index 1e768dfe18d..002d6d1d71c 100644
--- a/app/code/core/Mage/Adminhtml/controllers/TaxController.php
+++ b/app/code/core/Mage/Adminhtml/controllers/TaxController.php
@@ -54,7 +54,7 @@ public function ignoreTaxNotificationAction()
     /**
      * Check is allowed access to action
      *
-     * @return bool
+     * @return true
      */
     protected function _isAllowed()
     {
diff --git a/app/code/core/Mage/Adminhtml/controllers/UrlrewriteController.php b/app/code/core/Mage/Adminhtml/controllers/UrlrewriteController.php
index 5489fc3e066..51d708ded6e 100644
--- a/app/code/core/Mage/Adminhtml/controllers/UrlrewriteController.php
+++ b/app/code/core/Mage/Adminhtml/controllers/UrlrewriteController.php
@@ -33,6 +33,12 @@
  */
 class Mage_Adminhtml_UrlrewriteController extends Mage_Adminhtml_Controller_Action
 {
+    /**
+     * ACL resource
+     * @see Mage_Adminhtml_Controller_Action::_isAllowed()
+     */
+    const ADMIN_RESOURCE = 'catalog/urlrewrite';
+
     /**
      * Instantiate urlrewrite, product and category
      *
@@ -219,14 +225,4 @@ public function deleteAction()
         }
         $this->_redirect('*/*/');
     }
-
-    /**
-     * Check whether this contoller is allowed in admin permissions
-     *
-     * @return bool
-     */
-    protected function _isAllowed()
-    {
-        return Mage::getSingleton('admin/session')->isAllowed('catalog/urlrewrite');
-    }
 }
diff --git a/app/code/core/Mage/Api2/controllers/Adminhtml/Api2/AttributeController.php b/app/code/core/Mage/Api2/controllers/Adminhtml/Api2/AttributeController.php
index b9fb0726a60..2ace9795e13 100644
--- a/app/code/core/Mage/Api2/controllers/Adminhtml/Api2/AttributeController.php
+++ b/app/code/core/Mage/Api2/controllers/Adminhtml/Api2/AttributeController.php
@@ -34,7 +34,13 @@
 class Mage_Api2_Adminhtml_Api2_AttributeController extends Mage_Adminhtml_Controller_Action
 {
     /**
-     * Controller predispatch method
+     * ACL resource
+     * @see Mage_Adminhtml_Controller_Action::_isAllowed()
+     */
+    const ADMIN_RESOURCE = 'system/api';
+
+    /**
+     * Controller pre-dispatch method
      *
      * @return Mage_Adminhtml_Controller_Action
      */
@@ -157,14 +163,4 @@ public function saveAction()
 
         $this->_redirect('*/*/edit', array('type' => $type));
     }
-
-    /**
-     * Check is allowed access to action
-     *
-     * @return bool
-     */
-    protected function _isAllowed()
-    {
-        return Mage::getSingleton('admin/session')->isAllowed('system/api');
-    }
 }
diff --git a/app/code/core/Mage/Api2/controllers/Adminhtml/Api2/RoleController.php b/app/code/core/Mage/Api2/controllers/Adminhtml/Api2/RoleController.php
index 238d13beae6..ddb8f5667c1 100644
--- a/app/code/core/Mage/Api2/controllers/Adminhtml/Api2/RoleController.php
+++ b/app/code/core/Mage/Api2/controllers/Adminhtml/Api2/RoleController.php
@@ -34,7 +34,7 @@
 class Mage_Api2_Adminhtml_Api2_RoleController extends Mage_Adminhtml_Controller_Action
 {
     /**
-     * Controller predispatch method
+     * Controller pre-dispatch method
      *
      * @return Mage_Adminhtml_Controller_Action
      */
@@ -298,9 +298,7 @@ public function deleteAction()
     }
 
     /**
-     * Check against ACL
-     *
-     * @return bool
+     * @inheritDoc
      */
     protected function _isAllowed()
     {
diff --git a/app/code/core/Mage/Bundle/controllers/Adminhtml/Bundle/SelectionController.php b/app/code/core/Mage/Bundle/controllers/Adminhtml/Bundle/SelectionController.php
index 3f930753627..73b302a249a 100644
--- a/app/code/core/Mage/Bundle/controllers/Adminhtml/Bundle/SelectionController.php
+++ b/app/code/core/Mage/Bundle/controllers/Adminhtml/Bundle/SelectionController.php
@@ -33,6 +33,12 @@
  */
 class Mage_Bundle_Adminhtml_Bundle_SelectionController extends Mage_Adminhtml_Controller_Action
 {
+    /**
+     * ACL resource
+     * @see Mage_Adminhtml_Controller_Action::_isAllowed()
+     */
+    const ADMIN_RESOURCE = 'catalog/products';
+
     protected function _construct()
     {
         $this->setUsedModuleName('Mage_Bundle');
@@ -67,13 +73,4 @@ public function gridAction()
                 ->toHtml()
         );
     }
-    /**
-     * Check for is allowed
-     *
-     * @return boolean
-     */
-    protected function _isAllowed()
-    {
-        return Mage::getSingleton('admin/session')->isAllowed('catalog/products');
-    }
 }
diff --git a/app/code/core/Mage/Captcha/controllers/Adminhtml/RefreshController.php b/app/code/core/Mage/Captcha/controllers/Adminhtml/RefreshController.php
index 9b986a0c147..bd10c3d575b 100644
--- a/app/code/core/Mage/Captcha/controllers/Adminhtml/RefreshController.php
+++ b/app/code/core/Mage/Captcha/controllers/Adminhtml/RefreshController.php
@@ -36,8 +36,6 @@ class Mage_Captcha_Adminhtml_RefreshController extends Mage_Adminhtml_Controller
     /**
      * Refreshes captcha and returns JSON encoded URL to image (AJAX action)
      * Example: {'imgSrc': 'http://example.com/media/captcha/67842gh187612ngf8s.png'}
-     *
-     * @return null
      */
     public function refreshAction()
     {
diff --git a/app/code/core/Mage/Centinel/controllers/Adminhtml/Centinel/IndexController.php b/app/code/core/Mage/Centinel/controllers/Adminhtml/Centinel/IndexController.php
index 7d3af1e7c56..99dafc3a98e 100644
--- a/app/code/core/Mage/Centinel/controllers/Adminhtml/Centinel/IndexController.php
+++ b/app/code/core/Mage/Centinel/controllers/Adminhtml/Centinel/IndexController.php
@@ -33,6 +33,12 @@
  */
 class Mage_Centinel_Adminhtml_Centinel_IndexController extends Mage_Adminhtml_Controller_Action
 {
+    /**
+     * ACL resource
+     * @see Mage_Adminhtml_Controller_Action::_isAllowed()
+     */
+    const ADMIN_RESOURCE = 'sales/order/actions/review_payment';
+
     /**
      * Process validate payment data action
      *
@@ -107,7 +113,7 @@ private function _getPayment()
     /**
      * Return Centinel validation model
      *
-     * @return Mage_Centinel_Model_Service
+     * @return Mage_Centinel_Model_Service|false
      */
     private function _getValidator()
     {
@@ -116,15 +122,5 @@ private function _getValidator()
         }
         return false;
     }
-
-    /**
-     * Check is allowed access to action
-     *
-     * @return bool
-     */
-    protected function _isAllowed()
-    {
-        return Mage::getSingleton('admin/session')->isAllowed('sales/order/actions/review_payment');
-    }
 }
 
diff --git a/app/code/core/Mage/CurrencySymbol/controllers/Adminhtml/System/CurrencysymbolController.php b/app/code/core/Mage/CurrencySymbol/controllers/Adminhtml/System/CurrencysymbolController.php
index 07ada9586e3..5d99a33fb3e 100644
--- a/app/code/core/Mage/CurrencySymbol/controllers/Adminhtml/System/CurrencysymbolController.php
+++ b/app/code/core/Mage/CurrencySymbol/controllers/Adminhtml/System/CurrencysymbolController.php
@@ -33,6 +33,12 @@
  */
 class Mage_CurrencySymbol_Adminhtml_System_CurrencysymbolController extends Mage_Adminhtml_Controller_Action
 {
+    /**
+     * ACL resource
+     * @see Mage_Adminhtml_Controller_Action::_isAllowed()
+     */
+    const ADMIN_RESOURCE = 'system/currency/symbols';
+
     /**
      * Show Currency Symbols Management dialog
      */
@@ -87,14 +93,4 @@ public function resetAction()
         Mage::getModel('currencysymbol/system_currencysymbol')->resetValues();
         $this->_redirectReferer();
     }
-
-    /**
-     * Check the permission to run it
-     *
-     * @return boolean
-     */
-    protected function _isAllowed()
-    {
-        return Mage::getSingleton('admin/session')->isAllowed('system/currency/symbols');
-    }
 }
diff --git a/app/code/core/Mage/Downloadable/controllers/Adminhtml/Downloadable/FileController.php b/app/code/core/Mage/Downloadable/controllers/Adminhtml/Downloadable/FileController.php
index 280c0eafba2..5284244f2e3 100644
--- a/app/code/core/Mage/Downloadable/controllers/Adminhtml/Downloadable/FileController.php
+++ b/app/code/core/Mage/Downloadable/controllers/Adminhtml/Downloadable/FileController.php
@@ -33,6 +33,11 @@
  */
 class Mage_Downloadable_Adminhtml_Downloadable_FileController extends Mage_Adminhtml_Controller_Action
 {
+    /**
+     * ACL resource
+     * @see Mage_Adminhtml_Controller_Action::_isAllowed()
+     */
+    const ADMIN_RESOURCE = 'catalog/products';
 
     /**
      * Upload file controller action
@@ -79,14 +84,4 @@ public function uploadAction()
 
         $this->getResponse()->setBody(Mage::helper('core')->jsonEncode($result));
     }
-
-    /**
-     * Check admin permissions for this controller
-     *
-     * @return boolean
-     */
-    protected function _isAllowed()
-    {
-        return Mage::getSingleton('admin/session')->isAllowed('catalog/products');
-    }
 }
diff --git a/app/code/core/Mage/Downloadable/controllers/FileController.php b/app/code/core/Mage/Downloadable/controllers/FileController.php
index 97fa69d0fa9..2e8ef544fbb 100644
--- a/app/code/core/Mage/Downloadable/controllers/FileController.php
+++ b/app/code/core/Mage/Downloadable/controllers/FileController.php
@@ -37,7 +37,7 @@
 class Mage_Downloadable_FileController extends Mage_Downloadable_Adminhtml_Downloadable_FileController
 {
     /**
-     * Controller predispatch method
+     * Controller pre-dispatch method
      * Show 404 front page
      */
     public function preDispatch()
diff --git a/app/code/core/Mage/Downloadable/controllers/Product/EditController.php b/app/code/core/Mage/Downloadable/controllers/Product/EditController.php
index a7635d9d01c..e65d93adc4d 100644
--- a/app/code/core/Mage/Downloadable/controllers/Product/EditController.php
+++ b/app/code/core/Mage/Downloadable/controllers/Product/EditController.php
@@ -37,7 +37,7 @@
 class Mage_Downloadable_Product_EditController extends Mage_Downloadable_Adminhtml_Downloadable_Product_EditController
 {
     /**
-     * Controller predispatch method
+     * Controller pre-dispatch method
      * Show 404 front page
      */
     public function preDispatch()
diff --git a/app/code/core/Mage/ImportExport/controllers/Adminhtml/ExportController.php b/app/code/core/Mage/ImportExport/controllers/Adminhtml/ExportController.php
index 0b89739d991..7d2819820c2 100644
--- a/app/code/core/Mage/ImportExport/controllers/Adminhtml/ExportController.php
+++ b/app/code/core/Mage/ImportExport/controllers/Adminhtml/ExportController.php
@@ -33,6 +33,12 @@
  */
 class Mage_ImportExport_Adminhtml_ExportController extends Mage_Adminhtml_Controller_Action
 {
+    /**
+     * ACL resource
+     * @see Mage_Adminhtml_Controller_Action::_isAllowed()
+     */
+    const ADMIN_RESOURCE = 'system/convert/export';
+
     /**
      * Custom constructor.
      *
@@ -58,16 +64,6 @@ protected function _initAction()
         return $this;
     }
 
-    /**
-     * Check access (in the ACL) for current user
-     *
-     * @return bool
-     */
-    protected function _isAllowed()
-    {
-        return Mage::getSingleton('admin/session')->isAllowed('system/convert/export');
-    }
-
     /**
      * Load data with filter applying and create file for download.
      *
diff --git a/app/code/core/Mage/ImportExport/controllers/Adminhtml/ImportController.php b/app/code/core/Mage/ImportExport/controllers/Adminhtml/ImportController.php
index ead258551fc..00386a41b7b 100644
--- a/app/code/core/Mage/ImportExport/controllers/Adminhtml/ImportController.php
+++ b/app/code/core/Mage/ImportExport/controllers/Adminhtml/ImportController.php
@@ -33,6 +33,12 @@
  */
 class Mage_ImportExport_Adminhtml_ImportController extends Mage_Adminhtml_Controller_Action
 {
+    /**
+     * ACL resource
+     * @see Mage_Adminhtml_Controller_Action::_isAllowed()
+     */
+    const ADMIN_RESOURCE = 'system/convert/import';
+
     /**
      * Custom constructor.
      *
@@ -58,16 +64,6 @@ protected function _initAction()
         return $this;
     }
 
-    /**
-     * Check access (in the ACL) for current user.
-     *
-     * @return bool
-     */
-    protected function _isAllowed()
-    {
-        return Mage::getSingleton('admin/session')->isAllowed('system/convert/import');
-    }
-
     /**
      * Index action.
      *
diff --git a/app/code/core/Mage/Index/controllers/Adminhtml/ProcessController.php b/app/code/core/Mage/Index/controllers/Adminhtml/ProcessController.php
index 03feebc00b6..4d9fe587695 100644
--- a/app/code/core/Mage/Index/controllers/Adminhtml/ProcessController.php
+++ b/app/code/core/Mage/Index/controllers/Adminhtml/ProcessController.php
@@ -25,6 +25,12 @@
  */
 class Mage_Index_Adminhtml_ProcessController extends Mage_Adminhtml_Controller_Action
 {
+    /**
+     * ACL resource
+     * @see Mage_Adminhtml_Controller_Action::_isAllowed()
+     */
+    const ADMIN_RESOURCE = 'system/index';
+
     /**
      * Initialize process object by request
      *
@@ -229,14 +235,4 @@ public function massChangeModeAction()
 
         $this->_redirect('*/*/list');
     }
-
-    /**
-     * Check ACL permissins
-     *
-     * @return bool
-     */
-    protected function _isAllowed()
-    {
-        return Mage::getSingleton('admin/session')->isAllowed('system/index');
-    }
 }
diff --git a/app/code/core/Mage/Oauth/controllers/Adminhtml/Oauth/Admin/TokenController.php b/app/code/core/Mage/Oauth/controllers/Adminhtml/Oauth/Admin/TokenController.php
index db361caab53..270fce26e45 100644
--- a/app/code/core/Mage/Oauth/controllers/Adminhtml/Oauth/Admin/TokenController.php
+++ b/app/code/core/Mage/Oauth/controllers/Adminhtml/Oauth/Admin/TokenController.php
@@ -161,9 +161,7 @@ public function deleteAction()
     }
 
     /**
-     * Check admin permissions for this controller
-     *
-     * @return boolean
+     * @inheritDoc
      */
     protected function _isAllowed()
     {
diff --git a/app/code/core/Mage/Oauth/controllers/Adminhtml/Oauth/AuthorizeController.php b/app/code/core/Mage/Oauth/controllers/Adminhtml/Oauth/AuthorizeController.php
index 24c39bd2e7f..082d3517a27 100644
--- a/app/code/core/Mage/Oauth/controllers/Adminhtml/Oauth/AuthorizeController.php
+++ b/app/code/core/Mage/Oauth/controllers/Adminhtml/Oauth/AuthorizeController.php
@@ -302,7 +302,7 @@ public function rejectSimpleAction()
     /**
      * Check admin permissions for this controller
      *
-     * @return boolean
+     * @return true
      */
     protected function _isAllowed()
     {
diff --git a/app/code/core/Mage/Oauth/controllers/Adminhtml/Oauth/AuthorizedTokensController.php b/app/code/core/Mage/Oauth/controllers/Adminhtml/Oauth/AuthorizedTokensController.php
index 9b08f5c1df6..58446eb11ef 100644
--- a/app/code/core/Mage/Oauth/controllers/Adminhtml/Oauth/AuthorizedTokensController.php
+++ b/app/code/core/Mage/Oauth/controllers/Adminhtml/Oauth/AuthorizedTokensController.php
@@ -155,9 +155,7 @@ public function deleteAction()
     }
 
     /**
-     * Check admin permissions for this controller
-     *
-     * @return boolean
+     * @inheritDoc
      */
     protected function _isAllowed()
     {
diff --git a/app/code/core/Mage/Oauth/controllers/Adminhtml/Oauth/ConsumerController.php b/app/code/core/Mage/Oauth/controllers/Adminhtml/Oauth/ConsumerController.php
index d048b2576e2..be85a6e20a8 100644
--- a/app/code/core/Mage/Oauth/controllers/Adminhtml/Oauth/ConsumerController.php
+++ b/app/code/core/Mage/Oauth/controllers/Adminhtml/Oauth/ConsumerController.php
@@ -237,9 +237,7 @@ public function saveAction()
     }
 
     /**
-     * Check admin permissions for this controller
-     *
-     * @return boolean
+     * @inheritDoc
      */
     protected function _isAllowed()
     {
diff --git a/app/code/core/Mage/Paygate/controllers/Adminhtml/Paygate/Authorizenet/PaymentController.php b/app/code/core/Mage/Paygate/controllers/Adminhtml/Paygate/Authorizenet/PaymentController.php
index 0a2a185d26a..deef4673e14 100644
--- a/app/code/core/Mage/Paygate/controllers/Adminhtml/Paygate/Authorizenet/PaymentController.php
+++ b/app/code/core/Mage/Paygate/controllers/Adminhtml/Paygate/Authorizenet/PaymentController.php
@@ -33,6 +33,11 @@
  */
 class Mage_Paygate_Adminhtml_Paygate_Authorizenet_PaymentController extends Mage_Adminhtml_Controller_Action
 {
+    /**
+     * ACL resource
+     * @see Mage_Adminhtml_Controller_Action::_isAllowed()
+     */
+    const ADMIN_RESOURCE = 'sales/order/actions/review_payment';
 
     /**
      * Cancel active partail authorizations
@@ -76,14 +81,4 @@ protected function _getPaymentMethodsHtml()
         $output = $layout->getOutput();
         return $output;
     }
-
-    /**
-     * Check is allowed access to action
-     *
-     * @return bool
-     */
-    protected function _isAllowed()
-    {
-        return Mage::getSingleton('admin/session')->isAllowed('sales/order/actions/review_payment');
-    }
 }
diff --git a/app/code/core/Mage/Paypal/controllers/Adminhtml/Paypal/ReportsController.php b/app/code/core/Mage/Paypal/controllers/Adminhtml/Paypal/ReportsController.php
index 65852fd195f..926eb678fdd 100644
--- a/app/code/core/Mage/Paypal/controllers/Adminhtml/Paypal/ReportsController.php
+++ b/app/code/core/Mage/Paypal/controllers/Adminhtml/Paypal/ReportsController.php
@@ -122,8 +122,7 @@ protected function _initAction()
     }
 
     /**
-     * ACL check
-     * @return bool
+     * @inheritDoc
      */
     protected function _isAllowed()
     {
@@ -132,13 +131,10 @@ protected function _isAllowed()
             case 'index':
             case 'details':
                 return Mage::getSingleton('admin/session')->isAllowed('report/salesroot/paypal_settlement_reports/view');
-                break;
             case 'fetch':
                 return Mage::getSingleton('admin/session')->isAllowed('report/salesroot/paypal_settlement_reports/fetch');
-                break;
             default:
                 return Mage::getSingleton('admin/session')->isAllowed('report/salesroot/paypal_settlement_reports');
-                break;
         }
     }
 }
diff --git a/app/code/core/Mage/Rss/controllers/CatalogController.php b/app/code/core/Mage/Rss/controllers/CatalogController.php
index 966d6ebef65..9224caea4e0 100644
--- a/app/code/core/Mage/Rss/controllers/CatalogController.php
+++ b/app/code/core/Mage/Rss/controllers/CatalogController.php
@@ -100,7 +100,7 @@ public function categoryAction()
     }
 
     /**
-     * Controller predispatch method to change area for some specific action.
+     * Controller pre-dispatch method to change area for some specific action.
      *
      * @return $this
      */
diff --git a/app/code/core/Mage/Rss/controllers/OrderController.php b/app/code/core/Mage/Rss/controllers/OrderController.php
index 0c7dcdb54a5..2c83d1280a6 100644
--- a/app/code/core/Mage/Rss/controllers/OrderController.php
+++ b/app/code/core/Mage/Rss/controllers/OrderController.php
@@ -77,7 +77,7 @@ public function statusAction()
     }
 
     /**
-     * Controller predispatch method to change area for some specific action.
+     * Controller pre-dispatch method to change area for some specific action.
      *
      * @return $this
      */
diff --git a/app/code/core/Mage/Widget/controllers/Adminhtml/Widget/InstanceController.php b/app/code/core/Mage/Widget/controllers/Adminhtml/Widget/InstanceController.php
index 784a1b3b3d4..e6582e4cba6 100644
--- a/app/code/core/Mage/Widget/controllers/Adminhtml/Widget/InstanceController.php
+++ b/app/code/core/Mage/Widget/controllers/Adminhtml/Widget/InstanceController.php
@@ -33,6 +33,12 @@
  */
 class Mage_Widget_Adminhtml_Widget_InstanceController extends Mage_Adminhtml_Controller_Action
 {
+    /**
+     * ACL resource
+     * @see Mage_Adminhtml_Controller_Action::_isAllowed()
+     */
+    const ADMIN_RESOURCE = 'cms/widget_instance';
+
     /**
      * Session getter
      *
@@ -300,7 +306,7 @@ public function templateAction()
     }
 
     /**
-     * Controller predispatch method
+     * Controller pre-dispatch method
      *
      * @return Mage_Adminhtml_Controller_Action
      */
@@ -310,16 +316,6 @@ public function preDispatch()
         return parent::preDispatch();
     }
 
-    /**
-     * Check is allowed access to action
-     *
-     * @return bool
-     */
-    protected function _isAllowed()
-    {
-        return Mage::getSingleton('admin/session')->isAllowed('cms/widget_instance');
-    }
-
     /**
      * Prepare widget parameters
      *
diff --git a/app/code/core/Mage/Widget/controllers/Adminhtml/WidgetController.php b/app/code/core/Mage/Widget/controllers/Adminhtml/WidgetController.php
index f87cde66385..5c772df417d 100644
--- a/app/code/core/Mage/Widget/controllers/Adminhtml/WidgetController.php
+++ b/app/code/core/Mage/Widget/controllers/Adminhtml/WidgetController.php
@@ -33,6 +33,12 @@
  */
 class Mage_Widget_Adminhtml_WidgetController extends Mage_Adminhtml_Controller_Action
 {
+    /**
+     * ACL resource
+     * @see Mage_Adminhtml_Controller_Action::_isAllowed()
+     */
+    const ADMIN_RESOURCE = 'cms/widget_instance';
+
     /**
      * Wisywyg widget plugin main page
      */
@@ -84,14 +90,4 @@ public function buildWidgetAction()
         $html = Mage::getSingleton('widget/widget')->getWidgetDeclaration($type, $params, $asIs);
         $this->getResponse()->setBody($html);
     }
-
-    /**
-     * Check is allowed access to action
-     *
-     * @return bool
-     */
-    protected function _isAllowed()
-    {
-        return Mage::getSingleton('admin/session')->isAllowed('cms/widget_instance');
-    }
 }
From 2e02eab9659436c8e935e21d8cffd10fc726f245 Mon Sep 17 00:00:00 2001
From: Fabrizio Balliano 
Date: Tue, 2 Aug 2022 15:40:04 +0200
Subject: [PATCH 02/38] Revert "Add basic text for Ukraine (#2074)" (#2325)
This reverts commit 33dfa269fa60d56f4d7af19a393179e3ae927fab.
---
 README.md                                                   | 2 --
 .../default/default/template/notification/toolbar.phtml     | 6 ------
 skin/adminhtml/default/default/boxes.css                    | 1 -
 skin/adminhtml/default/default/images/flag-ua.svg           | 4 ----
 4 files changed, 13 deletions(-)
 delete mode 100644 skin/adminhtml/default/default/images/flag-ua.svg
diff --git a/README.md b/README.md
index 3e0f1571500..6e9b434a477 100644
--- a/README.md
+++ b/README.md
@@ -11,8 +11,6 @@
 
 
 
-
 Stop russian war. **Free Ukraine!** ([Read more](https://en.wikipedia.org/wiki/2022_Russian_invasion_of_Ukraine))
-
 # Magento - Long Term Support
 
 This repository is the home of an **unofficial** community-driven project. It's goal is to be a dependable alternative
diff --git a/app/design/adminhtml/default/default/template/notification/toolbar.phtml b/app/design/adminhtml/default/default/template/notification/toolbar.phtml
index cf072655de3..b523dc6aa90 100644
--- a/app/design/adminhtml/default/default/template/notification/toolbar.phtml
+++ b/app/design/adminhtml/default/default/template/notification/toolbar.phtml
@@ -24,12 +24,6 @@
  * @license     http://opensource.org/licenses/afl-3.0.php  Academic Free License (AFL 3.0)
  */
 ?>
-
-
-
 
-
-
-
From 58de841edc1a5ce6816f8665a1082d4902221db0 Mon Sep 17 00:00:00 2001
From: Fabrizio Balliano 
Date: Tue, 2 Aug 2022 17:25:26 +0200
Subject: [PATCH 03/38] 
 Mage_Catalog_Model_Product_Attribute_Backend_Groupprice_Abstract: avoid
 loading all websites when using only the current one (#2351)
---
 .../Attribute/Backend/Groupprice/Abstract.php     | 15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)
diff --git a/app/code/core/Mage/Catalog/Model/Product/Attribute/Backend/Groupprice/Abstract.php b/app/code/core/Mage/Catalog/Model/Product/Attribute/Backend/Groupprice/Abstract.php
index b0e15b97587..ac70e2a5541 100644
--- a/app/code/core/Mage/Catalog/Model/Product/Attribute/Backend/Groupprice/Abstract.php
+++ b/app/code/core/Mage/Catalog/Model/Product/Attribute/Backend/Groupprice/Abstract.php
@@ -55,14 +55,23 @@ abstract protected function _getDuplicateErrorMessage();
     /**
      * Retrieve websites currency rates and base currency codes
      *
+     * @param int|null $websiteId
      * @return array
      */
-    protected function _getWebsiteCurrencyRates()
+    protected function _getWebsiteCurrencyRates($websiteId = null)
     {
         if (is_null($this->_rates)) {
             $this->_rates = array();
             $baseCurrency = Mage::app()->getBaseCurrencyCode();
-            foreach (Mage::app()->getWebsites() as $website) {
+
+            if (is_numeric($websiteId)) {
+                $website = Mage::app()->getWebsite($websiteId);
+                $websites = [$website];
+            } else {
+                $websites = Mage::app()->getWebsites();
+            }
+
+            foreach ($websites as $website) {
                 /* @var Mage_Core_Model_Website $website */
                 if ($website->getBaseCurrencyCode() != $baseCurrency) {
                     $rate = Mage::getModel('directory/currency')
@@ -189,7 +198,7 @@ public function validate($object)
      */
     public function preparePriceData(array $priceData, $productTypeId, $websiteId)
     {
-        $rates  = $this->_getWebsiteCurrencyRates();
+        $rates  = $this->_getWebsiteCurrencyRates($websiteId);
         $data   = array();
         $price  = Mage::getSingleton('catalog/product_type')->priceFactory($productTypeId);
         foreach ($priceData as $v) {
From a3fdffc17899bc661719d29d258333c20b7ff604 Mon Sep 17 00:00:00 2001
From: Fabian Blechschmidt 
Date: Wed, 3 Aug 2022 18:40:53 +0200
Subject: [PATCH 04/38] Added support for HTTP2 to Mage_HTTP_Client_Curl
 (#1137)
---
 lib/Mage/HTTP/Client/Curl.php | 56 ++++++++++++++++++++++++-----------
 1 file changed, 39 insertions(+), 17 deletions(-)
diff --git a/lib/Mage/HTTP/Client/Curl.php b/lib/Mage/HTTP/Client/Curl.php
index fd9e14e7b07..4d27ac15e03 100644
--- a/lib/Mage/HTTP/Client/Curl.php
+++ b/lib/Mage/HTTP/Client/Curl.php
@@ -421,31 +421,29 @@ public function doError($string)
      * Parse headers - CURL callback functin
      *
      * @param resource $ch curl handle, not needed
-     * @param string $data
+     * @param string   $data
+     *
      * @return int
      */
-    protected function parseHeaders($ch, $data)
+    protected function parseHeaders($ch, $data): int
     {
-        if($this->_headerCount == 0) {
+        if ($this->_headerCount === 0) {
+            $line = explode(' ', trim($data), 3);
 
-            $line = explode(" ", trim($data), 3);
-            if(count($line) != 3) {
-                return $this->doError("Invalid response line returned from server: ".$data);
-            }
-            $this->_responseStatus = intval($line[1]);
+            $this->validateHttpVersion($line);
+            $this->_responseStatus = (int)$line[1];
         } else {
             //var_dump($data);
             $name = $value = '';
-            $out = explode(": ", trim($data), 2);
-            if(count($out) == 2) {
-                $name = $out[0];
-                $value = $out[1];
+            $out  = explode(': ', trim($data), 2);
+            if (count($out) === 2) {
+                list($name, $value) = $out;
             }
 
-            if(strlen($name)) {
-                if("Set-Cookie" == $name) {
-                    if(!isset($this->_responseHeaders[$name])) {
-                        $this->_responseHeaders[$name] = array();
+            if ($name !== '') {
+                if ($name === 'Set-Cookie') {
+                    if (!isset($this->_responseHeaders[$name])) {
+                        $this->_responseHeaders[$name] = [];
                     }
                     $this->_responseHeaders[$name][] = $value;
                 } else {
@@ -456,10 +454,34 @@ protected function parseHeaders($ch, $data)
         }
         $this->_headerCount++;
 
-
         return strlen($data);
     }
 
+    /**
+     * @param array $line
+     *
+     * @throws Exception
+     */
+    protected function validateHttpVersion(array $line)
+    {
+        if ($line[0] === 'HTTP/1.0' || $line[0] === 'HTTP/1.1') {
+            if (count($line) !== 3) {
+                $this->doError('Invalid response line returned from server: ' . implode(' ', $line));
+            }
+
+            return;
+        }
+
+        if ($line[0] === 'HTTP/2') {
+            if (!in_array(count($line), [2, 3])) {
+                $this->doError('Invalid response line returned from server: ' . implode(' ', $line));
+            }
+
+            return;
+        }
+        $this->doError('Invalid response line returned from server: ' . $data);
+    }
+
     /**
      * Set curl option directly
      *
From ac1fa930567814047ee70fe0d995e4321d91417f Mon Sep 17 00:00:00 2001
From: Colin Mollenhour 
Date: Wed, 3 Aug 2022 09:41:36 -0700
Subject: [PATCH 05/38] Blocked access to all dot files (#2349)
---
 .htaccess | 6 ++++++
 1 file changed, 6 insertions(+)
diff --git a/.htaccess b/.htaccess
index 585273a3a4b..fbf3c6a99a4 100644
--- a/.htaccess
+++ b/.htaccess
@@ -99,6 +99,12 @@
 
     #RewriteBase /magento/
 
+############################################
+## Prevent serving "hidden" files like git repository
+
+    RewriteCond %{REQUEST_URI} /\.
+    RewriteRule ^(.*)$ / [R=404,L]
+
 ############################################
 ## uncomment next line to enable light API calls processing
 
From 44c7c0fe7c23791a3137ff960c92ef759c1321d2 Mon Sep 17 00:00:00 2001
From: Kevin Jakob 
Date: Fri, 5 Aug 2022 05:45:03 +0200
Subject: [PATCH 06/38] Capitalization Adjustment Regarding CamelCase in Method
 Names (#2365)
* refactor: Adjusted capitalization of two public methods.
* refactor: Adjusted capitalization of one protected method.
* refactor: Adjusted capitalization of where call.
* chore: Removed fixed error from phpstan baseline.
---
 .github/phpstan-baseline.neon                               | 5 -----
 app/code/core/Mage/Catalog/Block/Category/View.php          | 6 +++---
 app/code/core/Mage/Newsletter/Model/Resource/Subscriber.php | 2 +-
 .../base/default/template/catalog/category/view.phtml       | 4 ++--
 lib/Varien/Io/File.php                                      | 6 +++---
 5 files changed, 9 insertions(+), 14 deletions(-)
diff --git a/.github/phpstan-baseline.neon b/.github/phpstan-baseline.neon
index ee1e5c6e6f2..03b08972d45 100644
--- a/.github/phpstan-baseline.neon
+++ b/.github/phpstan-baseline.neon
@@ -5430,11 +5430,6 @@ parameters:
 			count: 2
 			path: ../app/code/core/Mage/Newsletter/Model/Resource/Queue.php
 
-		-
-			message: "#^Call to method Zend_Db_Select\\:\\:where\\(\\) with incorrect case\\: Where$#"
-			count: 1
-			path: ../app/code/core/Mage/Newsletter/Model/Resource/Subscriber.php
-
 		-
 			message: "#^Call to an undefined method Mage_Customer_Model_Entity_Attribute\\:\\:getAttributeId\\(\\)\\.$#"
 			count: 3
diff --git a/app/code/core/Mage/Catalog/Block/Category/View.php b/app/code/core/Mage/Catalog/Block/Category/View.php
index 743effb41a5..2240b9b418a 100644
--- a/app/code/core/Mage/Catalog/Block/Category/View.php
+++ b/app/code/core/Mage/Catalog/Block/Category/View.php
@@ -60,7 +60,7 @@ protected function _prepareLayout()
             /*
             want to show rss feed in the url
             */
-            if ($this->IsRssCatalogEnable() && $this->IsTopCategory()) {
+            if ($this->isRssCatalogEnable() && $this->isTopCategory()) {
                 $title = $this->helper('rss')->__('%s RSS Feed', $this->getCurrentCategory()->getName());
                 $headBlock->addItem('rss', $this->getRssLink(), 'title="'.$title.'"');
             }
@@ -72,7 +72,7 @@ protected function _prepareLayout()
     /**
      * @return string
      */
-    public function IsRssCatalogEnable()
+    public function isRssCatalogEnable()
     {
         return Mage::getStoreConfig('rss/catalog/category');
     }
@@ -80,7 +80,7 @@ public function IsRssCatalogEnable()
     /**
      * @return bool
      */
-    public function IsTopCategory()
+    public function isTopCategory()
     {
         return $this->getCurrentCategory()->getLevel()==2;
     }
diff --git a/app/code/core/Mage/Newsletter/Model/Resource/Subscriber.php b/app/code/core/Mage/Newsletter/Model/Resource/Subscriber.php
index 04f439b1414..17b07d0f880 100644
--- a/app/code/core/Mage/Newsletter/Model/Resource/Subscriber.php
+++ b/app/code/core/Mage/Newsletter/Model/Resource/Subscriber.php
@@ -127,7 +127,7 @@ public function loadByCustomer(Mage_Customer_Model_Customer $customer)
         $select = $this->_read->select()
             ->from($this->getMainTable())
             ->where('subscriber_email=:subscriber_email')
-            ->Where('store_id=:store_id');
+            ->where('store_id=:store_id');
 
         $result = $this->_read->fetchRow(
             $select,
diff --git a/app/design/frontend/base/default/template/catalog/category/view.phtml b/app/design/frontend/base/default/template/catalog/category/view.phtml
index 4a748657290..9cbacf2213a 100644
--- a/app/design/frontend/base/default/template/catalog/category/view.phtml
+++ b/app/design/frontend/base/default/template/catalog/category/view.phtml
@@ -28,7 +28,7 @@
 /**
  * Category view template
  *
- * @see Mage_Catalog_Block_Category_View
+ * @var Mage_Catalog_Block_Category_View $this
  */
 ?>
 
 
-    IsRssCatalogEnable() && $this->IsTopCategory()): ?>
+    isRssCatalogEnable() && $this->isTopCategory()): ?>
         
     
     
categoryAttribute($_category, $_category->getName(), 'name') ?>
diff --git a/lib/Varien/Io/File.php b/lib/Varien/Io/File.php
index c5a7c1e388e..04b24de8b05 100644
--- a/lib/Varien/Io/File.php
+++ b/lib/Varien/Io/File.php
@@ -255,7 +255,7 @@ public function streamClose()
         if ($this->_streamLocked) {
             $this->streamUnlock();
         }
-        if ($this->_IsValidSource($this->_streamHandler)) {
+        if ($this->_isValidSource($this->_streamHandler)) {
             @fclose($this->_streamHandler);
         }
         $this->_streamHandler = null;
@@ -468,7 +468,7 @@ public function read($filename, $dest=null)
      */
     public function write($filename, $src, $mode=null)
     {
-        if (!$this->_IsValidSource($src) || !$this->_isFilenameWriteable($filename)) {
+        if (!$this->_isValidSource($src) || !$this->_isFilenameWriteable($filename)) {
             return false;
         }
 
@@ -493,7 +493,7 @@ public function write($filename, $src, $mode=null)
      * @param string|resource $src
      * @return bool
      */
-    protected function _IsValidSource($src)
+    protected function _isValidSource($src)
     {
         // In case of a string
         if (is_string($src)) {
From f6dcc3898a701673e34e7014e2cb24217b280ea3 Mon Sep 17 00:00:00 2001
From: sv3n 
Date: Fri, 5 Aug 2022 05:48:11 +0200
Subject: [PATCH 07/38] Some microoptimization (#2335)
* Avoid duplicate method calls
* Replaced array_push()
* Changed substr() third parameter
* Use array_key_exists()
* php7 opcode - internal functions
---
 .../Adminhtml/Block/Api/Tab/Rolesedit.php     |   2 +-
 .../Product/Helper/Form/Gallery/Content.php   |  47 ++--
 .../Mage/Adminhtml/Block/Dashboard/Graph.php  |   6 +-
 .../Adminhtml/Block/Newsletter/Queue/Edit.php |   4 +-
 .../Block/Permissions/Tab/Rolesedit.php       |   4 +-
 .../Block/Sales/Order/Shipment/Packaging.php  |  68 +++---
 .../Block/System/Config/Switcher.php          |  35 +--
 .../Adminhtml/Block/System/Config/Tabs.php    | 102 ++++----
 .../System/Convert/Profile/Edit/Tab/Run.php   |   2 +-
 .../Adminhtml/Block/System/Store/Tree.php     |  30 +--
 .../Adminhtml/controllers/IndexController.php |   2 +-
 .../Newsletter/QueueController.php            |   9 +-
 .../Permissions/RoleController.php            |   2 +-
 .../Sales/Order/ShipmentController.php        |   4 +-
 app/code/core/Mage/Bundle/Model/Option.php    |   2 +-
 .../core/Mage/Bundle/Model/Product/Type.php   |  10 +-
 .../core/Mage/Catalog/Block/Layer/State.php   |   7 +-
 app/code/core/Mage/Catalog/Model/Category.php |   3 +-
 .../Mage/Catalog/Model/Layer/Filter/Price.php |   6 +-
 app/code/core/Mage/Catalog/Model/Product.php  |   2 +-
 .../core/Mage/Catalog/Model/Product/Api.php   |   2 +-
 .../Model/Product/Attribute/Backend/Media.php |   6 +-
 .../Model/Product/Type/Configurable.php       |   2 +-
 .../Catalog/Model/Product/Type/Grouped.php    |   2 +-
 .../core/Mage/Catalog/Model/Resource/Url.php  | 231 +++++++++---------
 .../Mage/CatalogInventory/Model/Observer.php  |  58 ++---
 app/code/core/Mage/Checkout/Model/Cart.php    |   3 +-
 app/code/core/Mage/Core/Block/Abstract.php    |   4 +-
 .../Mage/Core/Controller/Varien/Front.php     |   2 +-
 .../core/Mage/Core/Model/Design/Package.php   |   2 +-
 app/code/core/Mage/Core/Model/Email/Info.php  |   8 +-
 .../Mage/Core/Model/Email/Template/Mailer.php |   2 +-
 app/code/core/Mage/Core/Model/Store.php       |   1 +
 app/code/core/Mage/Core/Model/Store/Group.php |  30 +--
 app/code/core/Mage/Core/Model/Website.php     |  52 ++--
 .../controllers/AccountController.php         |   2 +-
 .../core/Mage/Downloadable/Helper/File.php    |   2 +-
 .../Mage/Downloadable/Model/Product/Type.php  |   2 +-
 .../Model/Import/Entity/Customer/Address.php  |   5 +-
 .../Model/Import/Entity/Product.php           |   2 +-
 .../Model/Entity/Quote/Item/Collection.php    |   5 +-
 app/code/core/Mage/Sales/Model/Quote.php      |   2 +-
 .../core/Mage/SalesRule/Model/Validator.php   |  40 +--
 app/code/core/Mage/Uploader/Helper/File.php   |   2 +-
 .../Mage/Usa/Model/Shipping/Carrier/Dhl.php   |   2 +-
 .../Model/Shipping/Carrier/Dhl/Label/Pdf.php  |   2 +-
 app/code/core/Mage/Widget/Model/Widget.php    |  27 +-
 .../Mage/Wishlist/Controller/Abstract.php     |   2 +-
 48 files changed, 451 insertions(+), 396 deletions(-)
diff --git a/app/code/core/Mage/Adminhtml/Block/Api/Tab/Rolesedit.php b/app/code/core/Mage/Adminhtml/Block/Api/Tab/Rolesedit.php
index ee45783d0ea..82e9e1fb31a 100644
--- a/app/code/core/Mage/Adminhtml/Block/Api/Tab/Rolesedit.php
+++ b/app/code/core/Mage/Adminhtml/Block/Api/Tab/Rolesedit.php
@@ -42,7 +42,7 @@ public function __construct() {
                 && $item->getApiPermission() == 'allow')
             {
                 $resources[$item->getResource_id()]['checked'] = true;
-                array_push($selrids, $item->getResource_id());
+                $selrids[] = $item->getResource_id();
             }
         }
 
diff --git a/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Helper/Form/Gallery/Content.php b/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Helper/Form/Gallery/Content.php
index 8a29d3f3109..52fa611de0d 100644
--- a/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Helper/Form/Gallery/Content.php
+++ b/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Helper/Form/Gallery/Content.php
@@ -24,7 +24,6 @@
  * @license    http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
 
-
 /**
  * Catalog product form gallery content
  *
@@ -47,6 +46,9 @@ public function __construct()
         $this->setTemplate('catalog/product/helper/gallery.phtml');
     }
 
+    /**
+     * @inheritDoc
+     */
     protected function _prepareLayout()
     {
         $this->setChild('uploader',
@@ -57,16 +59,16 @@ protected function _prepareLayout()
             ->setFileParameterName('image')
             ->setTarget(Mage::getModel('adminhtml/url')->addSessionParam()->getUrl(
                 '*/catalog_product_gallery/upload',
-                array('_query' => false)
+                ['_query' => false]
             ));
 
         $browseConfig = $this->getUploader()->getButtonConfig();
         $browseConfig
-            ->setAttributes(array(
+            ->setAttributes([
                 'accept' => $browseConfig->getMimeTypesByExtensions('gif, png, jpeg, jpg')
-            ));
+            ]);
 
-        Mage::dispatchEvent('catalog_product_gallery_prepare_layout', array('block' => $this));
+        Mage::dispatchEvent('catalog_product_gallery_prepare_layout', ['block' => $this]);
 
         return parent::_prepareLayout();
     }
@@ -91,11 +93,17 @@ public function getUploaderHtml()
         return $this->getChildHtml('uploader');
     }
 
+    /**
+     * @return string
+     */
     public function getJsObjectName()
     {
         return $this->getHtmlId() . 'JsObject';
     }
 
+    /**
+     * @return string
+     */
     public function getAddImagesButton()
     {
         return $this->getButtonHtml(
@@ -106,6 +114,9 @@ public function getAddImagesButton()
         );
     }
 
+    /**
+     * @return string
+     */
     public function getImagesJson()
     {
         if(is_array($this->getElement()->getValue())) {
@@ -121,14 +132,16 @@ public function getImagesJson()
         return '[]';
     }
 
+    /**
+     * @return string
+     */
     public function getImagesValuesJson()
     {
-        $values = array();
+        $values = [];
         foreach ($this->getMediaAttributes() as $attribute) {
-            /* @var $attribute Mage_Eav_Model_Entity_Attribute */
-            $values[$attribute->getAttributeCode()] = $this->getElement()->getDataObject()->getData(
-                $attribute->getAttributeCode()
-            );
+            /* @var Mage_Eav_Model_Entity_Attribute $attribute */
+            $attributeCode = $attribute->getAttributeCode();
+            $values[$attributeCode] = $this->getElement()->getDataObject()->getData($attributeCode);
         }
         return Mage::helper('core')->jsonEncode($values);
     }
@@ -140,18 +153,21 @@ public function getImagesValuesJson()
      */
     public function getImageTypes()
     {
-        $imageTypes = array();
+        $imageTypes = [];
         foreach ($this->getMediaAttributes() as $attribute) {
-            /* @var $attribute Mage_Eav_Model_Entity_Attribute */
-            $imageTypes[$attribute->getAttributeCode()] = array(
+            /* @var Mage_Eav_Model_Entity_Attribute $attribute */
+            $imageTypes[$attribute->getAttributeCode()] = [
                 'label' => $attribute->getFrontend()->getLabel() . ' '
                          . Mage::helper('catalog')->__($this->getElement()->getScopeLabel($attribute)),
                 'field' => $this->getElement()->getAttributeFieldName($attribute)
-            );
+            ];
         }
         return $imageTypes;
     }
 
+    /**
+     * @return bool
+     */
     public function hasUseDefault()
     {
         foreach ($this->getMediaAttributes() as $attribute) {
@@ -173,6 +189,9 @@ public function getMediaAttributes()
         return $this->getElement()->getDataObject()->getMediaAttributes();
     }
 
+    /**
+     * @return string
+     */
     public function getImageTypesJson()
     {
         return Mage::helper('core')->jsonEncode($this->getImageTypes());
diff --git a/app/code/core/Mage/Adminhtml/Block/Dashboard/Graph.php b/app/code/core/Mage/Adminhtml/Block/Dashboard/Graph.php
index 8672db23994..3a896f8798b 100644
--- a/app/code/core/Mage/Adminhtml/Block/Dashboard/Graph.php
+++ b/app/code/core/Mage/Adminhtml/Block/Dashboard/Graph.php
@@ -322,12 +322,12 @@ public function getChartUrl($directUrl = true)
                 $currentvalue = $thisdataarray[$j];
                 if (is_numeric($currentvalue)) {
                     $ylocation = $yorigin + $currentvalue;
-                    array_push($chartdata, $ylocation . $dataDelimiter);
+                    $chartdata[] = $ylocation . $dataDelimiter;
                 } else {
-                    array_push($chartdata, $dataMissing . $dataDelimiter);
+                    $chartdata[] = $dataMissing . $dataDelimiter;
                 }
             }
-            array_push($chartdata, $dataSetdelimiter);
+            $chartdata[] = $dataSetdelimiter;
         }
         $buffer = implode('', $chartdata);
 
diff --git a/app/code/core/Mage/Adminhtml/Block/Newsletter/Queue/Edit.php b/app/code/core/Mage/Adminhtml/Block/Newsletter/Queue/Edit.php
index d04b228324d..15bcb65cfd8 100644
--- a/app/code/core/Mage/Adminhtml/Block/Newsletter/Queue/Edit.php
+++ b/app/code/core/Mage/Adminhtml/Block/Newsletter/Queue/Edit.php
@@ -245,9 +245,7 @@ public function getIsTextType()
      */
     public function getCanResume()
     {
-        return in_array($this->getQueue()->getQueueStatus(), array(
-            Mage_Newsletter_Model_Queue::STATUS_PAUSE
-        ));
+        return $this->getQueue()->getQueueStatus() == Mage_Newsletter_Model_Queue::STATUS_PAUSE;
     }
 
     /**
diff --git a/app/code/core/Mage/Adminhtml/Block/Permissions/Tab/Rolesedit.php b/app/code/core/Mage/Adminhtml/Block/Permissions/Tab/Rolesedit.php
index 519eb2545dc..c0ade190065 100644
--- a/app/code/core/Mage/Adminhtml/Block/Permissions/Tab/Rolesedit.php
+++ b/app/code/core/Mage/Adminhtml/Block/Permissions/Tab/Rolesedit.php
@@ -105,7 +105,7 @@ public function __construct()
             if (array_key_exists(strtolower($itemResourceId), $resources)) {
                 if ($item->isAllowed()) {
                     $resources[$itemResourceId]['checked'] = true;
-                    array_push($selrids, $itemResourceId);
+                    $selrids[] = $itemResourceId;
                 }
             }
         }
@@ -119,7 +119,7 @@ public function __construct()
                     $undefinedResourceId
                 ) == Mage_Admin_Model_Rules::RULE_PERMISSION_ALLOWED
             ) {
-                array_push($selrids, $undefinedResourceId);
+                $selrids[] = $undefinedResourceId;
             }
         }
 
diff --git a/app/code/core/Mage/Adminhtml/Block/Sales/Order/Shipment/Packaging.php b/app/code/core/Mage/Adminhtml/Block/Sales/Order/Shipment/Packaging.php
index da7e996fa1f..f37cd5d3158 100644
--- a/app/code/core/Mage/Adminhtml/Block/Sales/Order/Shipment/Packaging.php
+++ b/app/code/core/Mage/Adminhtml/Block/Sales/Order/Shipment/Packaging.php
@@ -53,25 +53,26 @@ public function getConfigDataJson()
     {
         $shipmentId = $this->getShipment()->getId();
         $orderId = $this->getRequest()->getParam('order_id');
-        $urlParams = array();
+        $urlParams = [];
 
-        $itemsQty       = array();
-        $itemsPrice     = array();
-        $itemsName      = array();
-        $itemsWeight    = array();
-        $itemsProductId = array();
+        $itemsQty       = [];
+        $itemsPrice     = [];
+        $itemsName      = [];
+        $itemsWeight    = [];
+        $itemsProductId = [];
 
         if ($shipmentId) {
             $urlParams['shipment_id'] = $shipmentId;
             $createLabelUrl = $this->getUrl('*/sales_order_shipment/createLabel', $urlParams);
             $itemsGridUrl = $this->getUrl('*/sales_order_shipment/getShippingItemsGrid', $urlParams);
             foreach ($this->getShipment()->getAllItems() as $item) {
-                $itemsQty[$item->getId()]           = $item->getQty();
-                $itemsPrice[$item->getId()]         = $item->getPrice();
-                $itemsName[$item->getId()]          = $item->getName();
-                $itemsWeight[$item->getId()]        = $item->getWeight();
-                $itemsProductId[$item->getId()]     = $item->getProductId();
-                $itemsOrderItemId[$item->getId()]   = $item->getOrderItemId();
+                $itemId = $item->getId();
+                $itemsQty[$itemId]           = $item->getQty();
+                $itemsPrice[$itemId]         = $item->getPrice();
+                $itemsName[$itemId]          = $item->getName();
+                $itemsWeight[$itemId]        = $item->getWeight();
+                $itemsProductId[$itemId]     = $item->getProductId();
+                $itemsOrderItemId[$itemId]   = $item->getOrderItemId();
             }
         } else if ($orderId) {
             $urlParams['order_id'] = $orderId;
@@ -79,15 +80,16 @@ public function getConfigDataJson()
             $itemsGridUrl = $this->getUrl('*/sales_order_shipment/getShippingItemsGrid', $urlParams);
 
             foreach ($this->getShipment()->getAllItems() as $item) {
-                $itemsQty[$item->getOrderItemId()]          = $item->getQty()*1;
-                $itemsPrice[$item->getOrderItemId()]        = $item->getPrice();
-                $itemsName[$item->getOrderItemId()]         = $item->getName();
-                $itemsWeight[$item->getOrderItemId()]       = $item->getWeight();
-                $itemsProductId[$item->getOrderItemId()]    = $item->getProductId();
-                $itemsOrderItemId[$item->getOrderItemId()]  = $item->getOrderItemId();
+                $orderItemId = $item->getOrderItemId();
+                $itemsQty[$orderItemId]          = $item->getQty()*1;
+                $itemsPrice[$orderItemId]        = $item->getPrice();
+                $itemsName[$orderItemId]         = $item->getName();
+                $itemsWeight[$orderItemId]       = $item->getWeight();
+                $itemsProductId[$orderItemId]    = $item->getProductId();
+                $itemsOrderItemId[$orderItemId]  = $orderItemId;
             }
         }
-        $data = array(
+        $data = [
             'createLabelUrl'            => $createLabelUrl,
             'itemsGridUrl'              => $itemsGridUrl,
             'errorQtyOverLimit'         => Mage::helper('sales')->__('The quantity you want to add exceeds the total shipped quantity for some of selected Product(s)'),
@@ -100,7 +102,7 @@ public function getConfigDataJson()
             'shipmentItemsProductId'    => $itemsProductId,
             'shipmentItemsOrderItemId'  => $itemsOrderItemId,
             'customizable'              => $this->_getCustomizableContainers(),
-        );
+        ];
         return Mage::helper('core')->jsonEncode($data);
     }
 
@@ -117,14 +119,14 @@ public function getContainers()
         $carrier = $order->getShippingCarrier();
         $countryShipper = Mage::getStoreConfig(Mage_Shipping_Model_Shipping::XML_PATH_STORE_COUNTRY_ID, $storeId);
         if ($carrier) {
-            $params = new Varien_Object(array(
+            $params = new Varien_Object([
                 'method' => $order->getShippingMethod(true)->getMethod(),
                 'country_shipper' => $countryShipper,
                 'country_recipient' => $address->getCountryId(),
-            ));
+            ]);
             return $carrier->getContainerTypes($params);
         }
-        return array();
+        return [];
     }
 
     /**
@@ -138,7 +140,7 @@ protected function _getCustomizableContainers()
         if ($carrier) {
             return $carrier->getCustomizableContainerTypes();
         }
-        return array();
+        return [];
     }
 
     /**
@@ -169,7 +171,7 @@ public function getDeliveryConfirmationTypeByCode($code)
         $countryId = $this->getShipment()->getOrder()->getShippingAddress()->getCountryId();
         $carrier = $this->getShipment()->getOrder()->getShippingCarrier();
         if ($carrier) {
-            $params = new Varien_Object(array('country_recipient' => $countryId));
+            $params = new Varien_Object(['country_recipient' => $countryId]);
             $confirmationTypes = $carrier->getDeliveryConfirmationTypes($params);
             $confirmationType = !empty($confirmationTypes[$code]) ? $confirmationTypes[$code] : '';
             return $confirmationType;
@@ -203,7 +205,7 @@ public function getPackages()
         if ($packages) {
             $packages = unserialize($packages, ['allowed_classes' => false]);
         } else {
-            $packages = array();
+            $packages = [];
         }
         return $packages;
     }
@@ -258,11 +260,11 @@ public function getDeliveryConfirmationTypes()
     {
         $countryId = $this->getShipment()->getOrder()->getShippingAddress()->getCountryId();
         $carrier = $this->getShipment()->getOrder()->getShippingCarrier();
-        $params = new Varien_Object(array('country_recipient' => $countryId));
+        $params = new Varien_Object(['country_recipient' => $countryId]);
         if ($carrier && is_array($carrier->getDeliveryConfirmationTypes($params))) {
             return $carrier->getDeliveryConfirmationTypes($params);
         }
-        return array();
+        return [];
     }
 
     /**
@@ -276,10 +278,10 @@ public function getPrintButton()
         $url = $this->getUrl('*/sales_order_shipment/printPackage', $data);
         return $this->getLayout()
             ->createBlock('adminhtml/widget_button')
-            ->setData(array(
+            ->setData([
                 'label'   => Mage::helper('sales')->__('Print'),
                 'onclick' => 'setLocation(\'' . $url . '\')'
-            ))
+            ])
             ->toHtml();
     }
 
@@ -310,14 +312,14 @@ public function getContentTypes()
         $carrier = $order->getShippingCarrier();
         $countryShipper = Mage::getStoreConfig(Mage_Shipping_Model_Shipping::XML_PATH_STORE_COUNTRY_ID, $storeId);
         if ($carrier) {
-            $params = new Varien_Object(array(
+            $params = new Varien_Object([
                 'method' => $order->getShippingMethod(true)->getMethod(),
                 'country_shipper' => $countryShipper,
                 'country_recipient' => $address->getCountryId(),
-            ));
+            ]);
             return $carrier->getContentTypes($params);
         }
-        return array();
+        return [];
     }
 
     /**
diff --git a/app/code/core/Mage/Adminhtml/Block/System/Config/Switcher.php b/app/code/core/Mage/Adminhtml/Block/System/Config/Switcher.php
index b6a4c0bd4e1..b613e043f1b 100644
--- a/app/code/core/Mage/Adminhtml/Block/System/Config/Switcher.php
+++ b/app/code/core/Mage/Adminhtml/Block/System/Config/Switcher.php
@@ -24,9 +24,11 @@
  * @license    http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
 
-
 class Mage_Adminhtml_Block_System_Config_Switcher extends Mage_Adminhtml_Block_Template
 {
+    /**
+     * @inheritDoc
+     */
     protected function _prepareLayout()
     {
         $this->setTemplate('system/config/switcher.phtml');
@@ -50,13 +52,13 @@ public function getStoreSelectOptions()
 
         $url = Mage::getModel('adminhtml/url');
 
-        $options = array();
-        $options['default'] = array(
+        $options = [];
+        $options['default'] = [
             'label'    => Mage::helper('adminhtml')->__('Default Config'),
-            'url'      => $url->getUrl('*/*/*', array('section'=>$section)),
+            'url'      => $url->getUrl('*/*/*', ['section'=>$section]),
             'selected' => !$curWebsite && !$curStore,
             'style'    => 'background:#ccc; font-weight:bold;',
-        );
+        ];
 
         foreach ($storeModel->getWebsiteCollection() as $website) {
             $websiteShow = false;
@@ -71,34 +73,35 @@ public function getStoreSelectOptions()
                     }
                     if (!$websiteShow) {
                         $websiteShow = true;
-                        $options['website_' . $website->getCode()] = array(
+                        $options['website_' . $website->getCode()] = [
                             'label'    => $website->getName(),
-                            'url'      => $url->getUrl('*/*/*', array('section'=>$section, 'website'=>$website->getCode())),
+                            'url'      => $url->getUrl('*/*/*', ['section'=>$section, 'website'=>$website->getCode()]),
                             'selected' => !$curStore && $curWebsite == $website->getCode(),
                             'style'    => 'padding-left:16px; background:#DDD; font-weight:bold;',
-                        );
+                        ];
                     }
                     if (!$groupShow) {
                         $groupShow = true;
-                        $options['group_' . $group->getId() . '_open'] = array(
+                        $options['group_' . $group->getId() . '_open'] = [
                             'is_group'  => true,
                             'is_close'  => false,
                             'label'     => $group->getName(),
                             'style'     => 'padding-left:32px;'
-                        );
+                        ];
                     }
-                    $options['store_' . $store->getCode()] = array(
+                    $storeCode = $store->getCode();
+                    $options['store_' . $storeCode] = [
                         'label'    => $store->getName(),
-                        'url'      => $url->getUrl('*/*/*', array('section'=>$section, 'website'=>$website->getCode(), 'store'=>$store->getCode())),
-                        'selected' => $curStore == $store->getCode(),
+                        'url'      => $url->getUrl('*/*/*', ['section'=>$section, 'website'=>$website->getCode(), 'store'=>$storeCode]),
+                        'selected' => $curStore == $storeCode,
                         'style'    => '',
-                    );
+                    ];
                 }
                 if ($groupShow) {
-                    $options['group_' . $group->getId() . '_close'] = array(
+                    $options['group_' . $group->getId() . '_close'] = [
                         'is_group'  => true,
                         'is_close'  => true,
-                    );
+                    ];
                 }
             }
         }
diff --git a/app/code/core/Mage/Adminhtml/Block/System/Config/Tabs.php b/app/code/core/Mage/Adminhtml/Block/System/Config/Tabs.php
index c5399a18db7..6185cb440ab 100644
--- a/app/code/core/Mage/Adminhtml/Block/System/Config/Tabs.php
+++ b/app/code/core/Mage/Adminhtml/Block/System/Config/Tabs.php
@@ -24,7 +24,6 @@
  * @license    http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
 
-
 /**
  * System configuration tabs block
  *
@@ -84,22 +83,22 @@ public function initTabs()
 
         $sections = (array)$sections;
 
-        usort($sections, array($this, '_sort'));
-        usort($tabs, array($this, '_sort'));
+        usort($sections, [$this, '_sort']);
+        usort($tabs, [$this, '_sort']);
 
         foreach ($tabs as $tab) {
             $helperName = $configFields->getAttributeModule($tab);
             $label = Mage::helper($helperName)->__((string)$tab->label);
 
-            $this->addTab($tab->getName(), array(
+            $this->addTab($tab->getName(), [
                 'label' => $label,
                 'class' => (string) $tab->class
-            ));
+            ]);
         }
 
 
         foreach ($sections as $section) {
-            Mage::dispatchEvent('adminhtml_block_system_config_init_tab_sections_before', array('section' => $section));
+            Mage::dispatchEvent('adminhtml_block_system_config_init_tab_sections_before', ['section' => $section]);
             $hasChildren = $configFields->hasChildren($section, $websiteCode, $storeCode);
 
             //$code = $section->getPath();
@@ -120,15 +119,15 @@ public function initTabs()
                 if (!$this->getRequest()->getParam('website') && !$this->getRequest()->getParam('store')) {
                     $this->_addBreadcrumb($label);
                 } else {
-                    $this->_addBreadcrumb($label, '', $url->getUrl('*/*/*', array('section'=>$code)));
+                    $this->_addBreadcrumb($label, '', $url->getUrl('*/*/*', ['section'=>$code]));
                 }
             }
             if ( $sectionAllowed && $hasChildren) {
-                $this->addSection($code, (string)$section->tab, array(
+                $this->addSection($code, (string)$section->tab, [
                     'class'     => (string)$section->class,
                     'label'     => $label,
-                    'url'       => $url->getUrl('*/*/*', array('_current'=>true, 'section'=>$code)),
-                ));
+                    'url'       => $url->getUrl('*/*/*', ['_current'=>true, 'section'=>$code]),
+                ]);
             }
 
             if ($code == $current) {
@@ -150,6 +149,13 @@ public function initTabs()
         return $this;
     }
 
+    /**
+     * Add tab
+     *
+     * @param string $code
+     * @param array $config
+     * @return $this
+     */
     public function addTab($code, $config)
     {
         $tab = new Varien_Object($config);
@@ -173,6 +179,12 @@ public function getTab($code)
         return null;
     }
 
+    /**
+     * @param string $code
+     * @param string $tabCode
+     * @param array $config
+     * @return $this
+     */
     public function addSection($code, $tabCode, $config)
     {
         if($tab = $this->getTab($tabCode)) {
@@ -186,6 +198,11 @@ public function addSection($code, $tabCode, $config)
         return $this;
     }
 
+    /**
+     * Get tabs
+     *
+     * @return array
+     */
     public function getTabs()
     {
         return $this->_tabs;
@@ -208,13 +225,13 @@ public function getStoreSelectOptions()
 
         $url = Mage::getModel('adminhtml/url');
 
-        $options = array();
-        $options['default'] = array(
+        $options = [];
+        $options['default'] = [
             'label'    => Mage::helper('adminhtml')->__('Default Config'),
-            'url'      => $url->getUrl('*/*/*', array('section'=>$section)),
+            'url'      => $url->getUrl('*/*/*', ['section'=>$section]),
             'selected' => !$curWebsite && !$curStore,
             'style'    => 'background:#ccc; font-weight:bold;',
-        );
+        ];
 
         foreach ($storeModel->getWebsiteCollection() as $website) {
             $websiteShow = false;
@@ -229,34 +246,35 @@ public function getStoreSelectOptions()
                     }
                     if (!$websiteShow) {
                         $websiteShow = true;
-                        $options['website_' . $website->getCode()] = array(
+                        $options['website_' . $website->getCode()] = [
                             'label'    => $website->getName(),
-                            'url'      => $url->getUrl('*/*/*', array('section'=>$section, 'website'=>$website->getCode())),
+                            'url'      => $url->getUrl('*/*/*', ['section'=>$section, 'website'=>$website->getCode()]),
                             'selected' => !$curStore && $curWebsite == $website->getCode(),
                             'style'    => 'padding-left:16px; background:#DDD; font-weight:bold;',
-                        );
+                        ];
                     }
                     if (!$groupShow) {
                         $groupShow = true;
-                        $options['group_' . $group->getId() . '_open'] = array(
+                        $options['group_' . $group->getId() . '_open'] = [
                             'is_group'  => true,
                             'is_close'  => false,
                             'label'     => $group->getName(),
                             'style'     => 'padding-left:32px;'
-                        );
+                        ];
                     }
-                    $options['store_' . $store->getCode()] = array(
+                    $storeCode = $store->getCode();
+                    $options['store_' . $storeCode] = [
                         'label'    => $store->getName(),
-                        'url'      => $url->getUrl('*/*/*', array('section'=>$section, 'website'=>$website->getCode(), 'store'=>$store->getCode())),
-                        'selected' => $curStore == $store->getCode(),
+                        'url'      => $url->getUrl('*/*/*', ['section'=>$section, 'website'=>$website->getCode(), 'store'=>$storeCode]),
+                        'selected' => $curStore == $storeCode,
                         'style'    => '',
-                    );
+                    ];
                 }
                 if ($groupShow) {
-                    $options['group_' . $group->getId() . '_close'] = array(
+                    $options['group_' . $group->getId() . '_close'] = [
                         'is_group'  => true,
                         'is_close'  => true,
-                    );
+                    ];
                 }
             }
         }
@@ -277,36 +295,36 @@ public function getStoreButtonsHtml()
         $html = '';
 
         if (!$curWebsite && !$curStore) {
-            $html .= $this->getLayout()->createBlock('adminhtml/widget_button')->setData(array(
+            $html .= $this->getLayout()->createBlock('adminhtml/widget_button')->setData([
                 'label'     => Mage::helper('adminhtml')->__('New Website'),
                 'onclick'   => "location.href='".$this->getUrl('*/system_website/new')."'",
                 'class'     => 'add',
-            ))->toHtml();
+            ])->toHtml();
         } elseif (!$curStore) {
-            $html .= $this->getLayout()->createBlock('adminhtml/widget_button')->setData(array(
+            $html .= $this->getLayout()->createBlock('adminhtml/widget_button')->setData([
                 'label'     => Mage::helper('adminhtml')->__('Edit Website'),
-                'onclick'   => "location.href='".$this->getUrl('*/system_website/edit', array('website'=>$curWebsite))."'",
-            ))->toHtml();
-            $html .= $this->getLayout()->createBlock('adminhtml/widget_button')->setData(array(
+                'onclick'   => "location.href='".$this->getUrl('*/system_website/edit', ['website'=>$curWebsite])."'",
+            ])->toHtml();
+            $html .= $this->getLayout()->createBlock('adminhtml/widget_button')->setData([
                 'label'     => Mage::helper('adminhtml')->__('New Store View'),
-                'onclick'   => "location.href='".$this->getUrl('*/system_store/new', array('website'=>$curWebsite))."'",
+                'onclick'   => "location.href='".$this->getUrl('*/system_store/new', ['website'=>$curWebsite])."'",
                 'class'     => 'add',
-            ))->toHtml();
-            $html .= $this->getLayout()->createBlock('adminhtml/widget_button')->setData(array(
+            ])->toHtml();
+            $html .= $this->getLayout()->createBlock('adminhtml/widget_button')->setData([
                 'label'     => Mage::helper('adminhtml')->__('Delete Website'),
-                'onclick'   => "location.href='".$this->getUrl('*/system_website/delete', array('website'=>$curWebsite))."'",
+                'onclick'   => "location.href='".$this->getUrl('*/system_website/delete', ['website'=>$curWebsite])."'",
                 'class'     => 'delete',
-            ))->toHtml();
+            ])->toHtml();
         } else {
-            $html .= $this->getLayout()->createBlock('adminhtml/widget_button')->setData(array(
+            $html .= $this->getLayout()->createBlock('adminhtml/widget_button')->setData([
                 'label'     => Mage::helper('adminhtml')->__('Edit Store View'),
-                'onclick'   => "location.href='".$this->getUrl('*/system_store/edit', array('store'=>$curStore))."'",
-            ))->toHtml();
-            $html .= $this->getLayout()->createBlock('adminhtml/widget_button')->setData(array(
+                'onclick'   => "location.href='".$this->getUrl('*/system_store/edit', ['store'=>$curStore])."'",
+            ])->toHtml();
+            $html .= $this->getLayout()->createBlock('adminhtml/widget_button')->setData([
                 'label'     => Mage::helper('adminhtml')->__('Delete Store View'),
-                'onclick'   => "location.href='".$this->getUrl('*/system_store/delete', array('store'=>$curStore))."'",
+                'onclick'   => "location.href='".$this->getUrl('*/system_store/delete', ['store'=>$curStore])."'",
                 'class'     => 'delete',
-            ))->toHtml();
+            ])->toHtml();
         }
 
         return $html;
diff --git a/app/code/core/Mage/Adminhtml/Block/System/Convert/Profile/Edit/Tab/Run.php b/app/code/core/Mage/Adminhtml/Block/System/Convert/Profile/Edit/Tab/Run.php
index e561b270e30..8dbf5fce136 100644
--- a/app/code/core/Mage/Adminhtml/Block/System/Convert/Profile/Edit/Tab/Run.php
+++ b/app/code/core/Mage/Adminhtml/Block/System/Convert/Profile/Edit/Tab/Run.php
@@ -81,7 +81,7 @@ public function getImportedFiles()
         while (false !== ($entry = $dir->read())) {
             if($entry != '.'
                && $entry != '..'
-               && in_array(strtolower(substr($entry, strrpos($entry, '.')+1)), array($this->getParseType())))
+               && strtolower(substr($entry, strrpos($entry, '.') + 1)) == $this->getParseType())
             {
                 $files[] = $entry;
             }
diff --git a/app/code/core/Mage/Adminhtml/Block/System/Store/Tree.php b/app/code/core/Mage/Adminhtml/Block/System/Store/Tree.php
index 79fcfec4540..073cb238a38 100644
--- a/app/code/core/Mage/Adminhtml/Block/System/Store/Tree.php
+++ b/app/code/core/Mage/Adminhtml/Block/System/Store/Tree.php
@@ -24,7 +24,6 @@
  * @license    http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
 
-
 /**
  * Adminhtml store tree
  *
@@ -70,42 +69,43 @@ protected function _prepareLayout()
      */
     public function getTableData()
     {
-        $data = array();
+        $data = [];
         foreach (Mage::getModel('core/website')->getCollection() as $website) {
             /** @var Mage_Core_Model_Website $website */
             $groupCollection = $website->getGroupCollection();
-            $data[$website->getId()] = array(
+            $websiteId = $website->getId();
+            $data[$websiteId] = [
                 'object' => $website,
-                'storeGroups' => array(),
+                'storeGroups' => [],
                 'count' => 0
-            );
+            ];
             $defaultGroupId = $website->getDefaultGroupId();
             foreach ($groupCollection as $storeGroup) {
                 /** @var Mage_Core_Model_Store_Group $storeGroup */
                 $storeCollection = $storeGroup->getStoreCollection();
                 $storeGroupCount = max(1, $storeCollection->count());
-                $data[$website->getId()]['storeGroups'][$storeGroup->getId()] = array(
+                $data[$websiteId]['storeGroups'][$storeGroup->getId()] = [
                     'object' => $storeGroup,
-                    'stores' => array(),
+                    'stores' => [],
                     'count' => $storeGroupCount
-                );
-                $data[$website->getId()]['count'] += $storeGroupCount;
+                ];
+                $data[$websiteId]['count'] += $storeGroupCount;
                 if ($storeGroup->getId() == $defaultGroupId) {
                     $storeGroup->setData('is_default', true);
                 }
                 $defaultStoreId = $storeGroup->getDefaultStoreId();
                 foreach ($storeCollection as $store) {
                     /** @var Mage_Core_Model_Store $store */
-                    $data[$website->getId()]['storeGroups'][$storeGroup->getId()]['stores'][$store->getId()] = array(
+                    $data[$websiteId]['storeGroups'][$storeGroup->getId()]['stores'][$store->getId()] = [
                         'object' => $store
-                    );
+                    ];
                     if ($store->getId() == $defaultStoreId) {
                         $store->setData('is_default', true);
                     }
                 }
             }
 
-            $data[$website->getId()]['count'] = max(1, $data[$website->getId()]['count']);
+            $data[$websiteId]['count'] = max(1, $data[$websiteId]['count']);
         }
         return $data;
     }
@@ -130,7 +130,7 @@ public function renderWebsite(Mage_Core_Model_Website $website)
     {
         return $this->_createCellTemplate()
             ->setObject($website)
-            ->setLinkUrl($this->getUrl('*/*/editWebsite', array('website_id' => $website->getWebsiteId())))
+            ->setLinkUrl($this->getUrl('*/*/editWebsite', ['website_id' => $website->getWebsiteId()]))
             ->setInfo($this->__('Code') . ': ' . $this->escapeHtml($website->getCode()))
             ->toHtml();
     }
@@ -146,7 +146,7 @@ public function renderStoreGroup(Mage_Core_Model_Store_Group $storeGroup)
         $rootCategory = Mage::getModel('catalog/category')->load($storeGroup->getRootCategoryId());
         return $this->_createCellTemplate()
             ->setObject($storeGroup)
-            ->setLinkUrl($this->getUrl('*/*/editGroup', array('group_id' => $storeGroup->getGroupId())))
+            ->setLinkUrl($this->getUrl('*/*/editGroup', ['group_id' => $storeGroup->getGroupId()]))
             ->setInfo($this->__('Root Category') . ': ' . $this->escapeHtml($rootCategory->getName()))
             ->toHtml();
     }
@@ -161,7 +161,7 @@ public function renderStore(Mage_Core_Model_Store $store)
     {
         $cell = $this->_createCellTemplate()
             ->setObject($store)
-            ->setLinkUrl($this->getUrl('*/*/editStore', array('store_id' => $store->getStoreId())))
+            ->setLinkUrl($this->getUrl('*/*/editStore', ['store_id' => $store->getStoreId()]))
             ->setInfo($this->__('Code') . ': ' . $this->escapeHtml($store->getCode()));
         if (!$store->getIsActive()) {
             $cell->setClass('strike');
diff --git a/app/code/core/Mage/Adminhtml/controllers/IndexController.php b/app/code/core/Mage/Adminhtml/controllers/IndexController.php
index 87ee9d665e8..2811907966c 100644
--- a/app/code/core/Mage/Adminhtml/controllers/IndexController.php
+++ b/app/code/core/Mage/Adminhtml/controllers/IndexController.php
@@ -325,7 +325,7 @@ public function resetPasswordPostAction()
 
         $errorMessages = array();
         if (iconv_strlen($password) <= 0) {
-            array_push($errorMessages, Mage::helper('adminhtml')->__('New password field cannot be empty.'));
+            $errorMessages[] = Mage::helper('adminhtml')->__('New password field cannot be empty.');
         }
         /** @var Mage_Admin_Model_User $user */
         $user = $this->_getModel('admin/user')->load($userId);
diff --git a/app/code/core/Mage/Adminhtml/controllers/Newsletter/QueueController.php b/app/code/core/Mage/Adminhtml/controllers/Newsletter/QueueController.php
index ef5b6193324..33f40ab0377 100644
--- a/app/code/core/Mage/Adminhtml/controllers/Newsletter/QueueController.php
+++ b/app/code/core/Mage/Adminhtml/controllers/Newsletter/QueueController.php
@@ -129,8 +129,7 @@ public function pauseAction()
         $queue = Mage::getSingleton('newsletter/queue')
             ->load($this->getRequest()->getParam('id'));
 
-        if (!in_array($queue->getQueueStatus(),
-                      array(Mage_Newsletter_Model_Queue::STATUS_SENDING))) {
+        if ($queue->getQueueStatus() != Mage_Newsletter_Model_Queue::STATUS_SENDING) {
                $this->_redirect('*/*');
             return;
         }
@@ -146,8 +145,7 @@ public function resumeAction()
         $queue = Mage::getSingleton('newsletter/queue')
             ->load($this->getRequest()->getParam('id'));
 
-        if (!in_array($queue->getQueueStatus(),
-                      array(Mage_Newsletter_Model_Queue::STATUS_PAUSE))) {
+        if ($queue->getQueueStatus() != Mage_Newsletter_Model_Queue::STATUS_PAUSE) {
                $this->_redirect('*/*');
             return;
         }
@@ -163,8 +161,7 @@ public function cancelAction()
         $queue = Mage::getSingleton('newsletter/queue')
             ->load($this->getRequest()->getParam('id'));
 
-        if (!in_array($queue->getQueueStatus(),
-                      array(Mage_Newsletter_Model_Queue::STATUS_SENDING))) {
+        if ($queue->getQueueStatus() != Mage_Newsletter_Model_Queue::STATUS_SENDING) {
                $this->_redirect('*/*');
             return;
         }
diff --git a/app/code/core/Mage/Adminhtml/controllers/Permissions/RoleController.php b/app/code/core/Mage/Adminhtml/controllers/Permissions/RoleController.php
index b203b4a3684..58e1d7f08bc 100644
--- a/app/code/core/Mage/Adminhtml/controllers/Permissions/RoleController.php
+++ b/app/code/core/Mage/Adminhtml/controllers/Permissions/RoleController.php
@@ -339,7 +339,7 @@ public function refreshRolesAction()
                 } else {
                     foreach ($resourceAcl->getResources() as $resource) {
                         if ($resourceAcl->isAllowed($roleTypeId, $resource)) {
-                            array_push($selectedResourceIds, $resource);
+                            $selectedResourceIds[] = $resource;
                         }
                     }
                 }
diff --git a/app/code/core/Mage/Adminhtml/controllers/Sales/Order/ShipmentController.php b/app/code/core/Mage/Adminhtml/controllers/Sales/Order/ShipmentController.php
index 929524539be..9ed82dbb772 100644
--- a/app/code/core/Mage/Adminhtml/controllers/Sales/Order/ShipmentController.php
+++ b/app/code/core/Mage/Adminhtml/controllers/Sales/Order/ShipmentController.php
@@ -643,7 +643,7 @@ public function massPrintShippingLabelAction()
         switch ($request->getParam('massaction_prepare_key')) {
             case 'shipment_ids':
                 $ids = $request->getParam('shipment_ids');
-                array_filter($ids, 'intval');
+                array_filter($ids, '\intval');
                 if (!empty($ids)) {
                     $shipments = Mage::getResourceModel('sales/order_shipment_collection')
                         ->addFieldToFilter('entity_id', array('in' => $ids));
@@ -651,7 +651,7 @@ public function massPrintShippingLabelAction()
                 break;
             case 'order_ids':
                 $ids = $request->getParam('order_ids');
-                array_filter($ids, 'intval');
+                array_filter($ids, '\intval');
                 if (!empty($ids)) {
                     $shipments = Mage::getResourceModel('sales/order_shipment_collection')
                         ->setOrderFilter(array('in' => $ids));
diff --git a/app/code/core/Mage/Bundle/Model/Option.php b/app/code/core/Mage/Bundle/Model/Option.php
index ace6fea8b09..996294406b5 100644
--- a/app/code/core/Mage/Bundle/Model/Option.php
+++ b/app/code/core/Mage/Bundle/Model/Option.php
@@ -85,7 +85,7 @@ public function addSelection($selection)
         if (!$selections = $this->getData('selections')) {
             $selections = array();
         }
-        array_push($selections, $selection);
+        $selections[] = $selection;
         $this->setSelections($selections);
         return $this;
     }
diff --git a/app/code/core/Mage/Bundle/Model/Product/Type.php b/app/code/core/Mage/Bundle/Model/Product/Type.php
index 5495f85f097..6fdb7837690 100644
--- a/app/code/core/Mage/Bundle/Model/Product/Type.php
+++ b/app/code/core/Mage/Bundle/Model/Product/Type.php
@@ -542,7 +542,7 @@ protected function _prepareProduct(Varien_Object $buyRequest, $product, $process
 
         $options = $buyRequest->getBundleOption();
         if (is_array($options)) {
-            $options = array_filter($options, 'intval');
+            $options = array_filter($options, '\intval');
             $qtys = $buyRequest->getBundleOptionQty();
             foreach ($options as $_optionId => $_selections) {
                 if (empty($_selections)) {
@@ -673,7 +673,7 @@ protected function _prepareProduct(Varien_Object $buyRequest, $product, $process
                 }
 
                 $result[] = $_result[0]->setParentProductId($product->getId())
-                    ->addCustomOption('bundle_option_ids', serialize(array_map('intval', $optionIds)))
+                    ->addCustomOption('bundle_option_ids', serialize(array_map('\intval', $optionIds)))
                     ->addCustomOption('bundle_selection_attributes', serialize($attributes));
 
                 if ($isStrictProcessMode) {
@@ -690,7 +690,7 @@ protected function _prepareProduct(Varien_Object $buyRequest, $product, $process
             foreach ($result as $item) {
                 $item->addCustomOption('bundle_identity', $uniqueKey);
             }
-            $product->addCustomOption('bundle_option_ids', serialize(array_map('intval', $optionIds)));
+            $product->addCustomOption('bundle_option_ids', serialize(array_map('\intval', $optionIds)));
             $product->addCustomOption('bundle_selection_ids', serialize($selectionIds));
 
             return $result;
@@ -1009,8 +1009,8 @@ public function processBuyRequest($product, $buyRequest)
         $option     = $buyRequest->getBundleOption();
         $optionQty  = $buyRequest->getBundleOptionQty();
 
-        $option     = (is_array($option)) ? array_filter($option, 'intval') : array();
-        $optionQty  = (is_array($optionQty)) ? array_filter($optionQty, 'intval') : array();
+        $option     = (is_array($option)) ? array_filter($option, '\intval') : array();
+        $optionQty  = (is_array($optionQty)) ? array_filter($optionQty, '\intval') : array();
 
         $options = array(
             'bundle_option'     => $option,
diff --git a/app/code/core/Mage/Catalog/Block/Layer/State.php b/app/code/core/Mage/Catalog/Block/Layer/State.php
index 15d92c5ec89..29372d3ecc1 100644
--- a/app/code/core/Mage/Catalog/Block/Layer/State.php
+++ b/app/code/core/Mage/Catalog/Block/Layer/State.php
@@ -54,7 +54,7 @@ public function getActiveFilters()
     {
         $filters = $this->getLayer()->getState()->getFilters();
         if (!is_array($filters)) {
-            $filters = array();
+            $filters = [];
         }
         return $filters;
     }
@@ -66,9 +66,10 @@ public function getActiveFilters()
      */
     public function getClearUrl()
     {
-        $filterState = array();
+        $filterState = [];
         foreach ($this->getActiveFilters() as $item) {
-            $filterState[$item->getFilter()->getRequestVar()] = $item->getFilter()->getCleanValue();
+            $filter = $item->getFilter();
+            $filterState[$filter->getRequestVar()] = $filter->getCleanValue();
         }
         $params['_current']     = true;
         $params['_use_rewrite'] = true;
diff --git a/app/code/core/Mage/Catalog/Model/Category.php b/app/code/core/Mage/Catalog/Model/Category.php
index c3cc5a1bbcd..9d2285c55a3 100644
--- a/app/code/core/Mage/Catalog/Model/Category.php
+++ b/app/code/core/Mage/Catalog/Model/Category.php
@@ -421,7 +421,8 @@ public function getStoreIds()
         $storeCollection = Mage::getModel('core/store')->getCollection()->loadByCategoryIds($nodes);
         /** @var Mage_Core_Model_Store $store */
         foreach ($storeCollection as $store) {
-            $storeIds[$store->getId()] = $store->getId();
+            $storeId = $store->getId();
+            $storeIds[$storeId] = $storeId;
         }
 
         $entityStoreId = $this->getStoreId();
diff --git a/app/code/core/Mage/Catalog/Model/Layer/Filter/Price.php b/app/code/core/Mage/Catalog/Model/Layer/Filter/Price.php
index e347c547cab..a7bea9616e0 100644
--- a/app/code/core/Mage/Catalog/Model/Layer/Filter/Price.php
+++ b/app/code/core/Mage/Catalog/Model/Layer/Filter/Price.php
@@ -552,7 +552,7 @@ public function loadPrices($limit, $offset = null, $lowerPrice = null, $upperPri
     {
         $prices = $this->_getResource()->loadPrices($this, $limit, $offset, $lowerPrice, $upperPrice);
         if ($prices) {
-            $prices = array_map('floatval', $prices);
+            $prices = array_map('\floatval', $prices);
         }
 
         return $prices;
@@ -570,7 +570,7 @@ public function loadPreviousPrices($price, $index, $lowerPrice = null)
     {
         $prices = $this->_getResource()->loadPreviousPrices($this, $price, $index, $lowerPrice);
         if ($prices) {
-            $prices = array_map('floatval', $prices);
+            $prices = array_map('\floatval', $prices);
         }
 
         return $prices;
@@ -588,7 +588,7 @@ public function loadNextPrices($price, $rightIndex, $upperPrice = null)
     {
         $prices = $this->_getResource()->loadNextPrices($this, $price, $rightIndex, $upperPrice);
         if ($prices) {
-            $prices = array_map('floatval', $prices);
+            $prices = array_map('\floatval', $prices);
         }
 
         return $prices;
diff --git a/app/code/core/Mage/Catalog/Model/Product.php b/app/code/core/Mage/Catalog/Model/Product.php
index 881e9855ba0..efb9513f19f 100644
--- a/app/code/core/Mage/Catalog/Model/Product.php
+++ b/app/code/core/Mage/Catalog/Model/Product.php
@@ -589,7 +589,7 @@ public function setCategoryIds($ids)
         } elseif (!is_array($ids)) {
             Mage::throwException(Mage::helper('catalog')->__('Invalid category IDs.'));
         }
-        $ids = array_filter(array_map('intval', $ids));
+        $ids = array_filter(array_map('\intval', $ids));
         $this->setData('category_ids', $ids);
         return $this;
     }
diff --git a/app/code/core/Mage/Catalog/Model/Product/Api.php b/app/code/core/Mage/Catalog/Model/Product/Api.php
index 168ddde78dd..04bf8b3851a 100644
--- a/app/code/core/Mage/Catalog/Model/Product/Api.php
+++ b/app/code/core/Mage/Catalog/Model/Product/Api.php
@@ -449,7 +449,7 @@ public function getAdditionalAttributes($productType, $attributeSetId)
      */
     protected function _checkProductTypeExists($productType)
     {
-        if (!in_array($productType, array_keys(Mage::getModel('catalog/product_type')->getOptionArray()))) {
+        if (!array_key_exists($productType, Mage::getModel('catalog/product_type')->getOptionArray())) {
             $this->_fault('product_type_not_exists');
         }
     }
diff --git a/app/code/core/Mage/Catalog/Model/Product/Attribute/Backend/Media.php b/app/code/core/Mage/Catalog/Model/Product/Attribute/Backend/Media.php
index 224c7951219..a1712b5c857 100644
--- a/app/code/core/Mage/Catalog/Model/Product/Attribute/Backend/Media.php
+++ b/app/code/core/Mage/Catalog/Model/Product/Attribute/Backend/Media.php
@@ -167,12 +167,12 @@ public function beforeSave($object)
                 $object->setData($mediaAttrCode, 'no_selection');
             }
 
-            if (in_array($attrData, array_keys($newImages))) {
+            if (array_key_exists($attrData, $newImages)) {
                 $object->setData($mediaAttrCode, $newImages[$attrData]['new_file']);
                 $object->setData($mediaAttrCode.'_label', $newImages[$attrData]['label']);
             }
 
-            if (in_array($attrData, array_keys($existImages))) {
+            if (array_key_exists($attrData, $existImages)) {
                 $object->setData($mediaAttrCode.'_label', $existImages[$attrData]['label']);
             }
         }
@@ -585,7 +585,7 @@ protected function _moveImageFromTmp($file)
         }
 
         if (strrpos($file, '.tmp') == strlen($file)-4) {
-            $file = substr($file, 0, strlen($file)-4);
+            $file = substr($file, 0, -4);
         }
         $destFile = $this->_getUniqueFileName($file, $ioObject->dirsep());
 
diff --git a/app/code/core/Mage/Catalog/Model/Product/Type/Configurable.php b/app/code/core/Mage/Catalog/Model/Product/Type/Configurable.php
index f839a16ca1e..b2618afa6af 100644
--- a/app/code/core/Mage/Catalog/Model/Product/Type/Configurable.php
+++ b/app/code/core/Mage/Catalog/Model/Product/Type/Configurable.php
@@ -861,7 +861,7 @@ public function getSku($product = null)
     public function processBuyRequest($product, $buyRequest)
     {
         $superAttribute = $buyRequest->getSuperAttribute();
-        $superAttribute = (is_array($superAttribute)) ? array_filter($superAttribute, 'intval') : array();
+        $superAttribute = (is_array($superAttribute)) ? array_filter($superAttribute, '\intval') : array();
 
         $options = array('super_attribute' => $superAttribute);
 
diff --git a/app/code/core/Mage/Catalog/Model/Product/Type/Grouped.php b/app/code/core/Mage/Catalog/Model/Product/Type/Grouped.php
index 7e9b4354409..c48448ceb41 100644
--- a/app/code/core/Mage/Catalog/Model/Product/Type/Grouped.php
+++ b/app/code/core/Mage/Catalog/Model/Product/Type/Grouped.php
@@ -365,7 +365,7 @@ public function getProductsToPurchaseByReqGroups($product = null)
     public function processBuyRequest($product, $buyRequest)
     {
         $superGroup = $buyRequest->getSuperGroup();
-        $superGroup = (is_array($superGroup)) ? array_filter($superGroup, 'intval') : array();
+        $superGroup = (is_array($superGroup)) ? array_filter($superGroup, '\intval') : array();
 
         $options = array('super_group' => $superGroup);
 
diff --git a/app/code/core/Mage/Catalog/Model/Resource/Url.php b/app/code/core/Mage/Catalog/Model/Resource/Url.php
index eb4a07a60cb..ea2e937f62e 100644
--- a/app/code/core/Mage/Catalog/Model/Resource/Url.php
+++ b/app/code/core/Mage/Catalog/Model/Resource/Url.php
@@ -46,14 +46,14 @@ class Mage_Catalog_Model_Resource_Url extends Mage_Core_Model_Resource_Db_Abstra
      *
      * @var array
      */
-    protected $_categoryAttributes          = array();
+    protected $_categoryAttributes          = [];
 
     /**
      * Product attribute properties cache
      *
      * @var array
      */
-    protected $_productAttributes           = array();
+    protected $_productAttributes           = [];
 
     /**
      * Limit products for select
@@ -67,7 +67,7 @@ class Mage_Catalog_Model_Resource_Url extends Mage_Core_Model_Resource_Db_Abstra
      *
      * @var array
      */
-    protected $_rootChildrenIds             = array();
+    protected $_rootChildrenIds             = [];
 
     /**
      * Load core Url rewrite model
@@ -129,10 +129,10 @@ public function getRewriteByIdPath($idPath, $storeId)
             ->from($this->getMainTable())
             ->where('store_id = :store_id')
             ->where('id_path = :id_path');
-        $bind = array(
+        $bind = [
             'store_id' => (int)$storeId,
             'id_path'  => $idPath
-        );
+        ];
         $row = $adapter->fetchRow($select, $bind);
 
         if (!$row) {
@@ -158,10 +158,10 @@ public function getRewriteByRequestPath($requestPath, $storeId)
             ->from($this->getMainTable())
             ->where('store_id = :store_id')
             ->where('request_path = :request_path');
-        $bind = array(
+        $bind = [
             'request_path'  => $requestPath,
             'store_id'      => (int)$storeId
-        );
+        ];
         $row = $adapter->fetchRow($select, $bind);
 
         if (!$row) {
@@ -196,13 +196,13 @@ public function getLastUsedRewriteRequestIncrement($prefix, $suffix, $storeId)
             ->from($this->getMainTable(), new Zend_Db_Expr('MAX(' . $urlIncrementPartExpression . ')'))
             ->where('store_id = :store_id')
             ->where('request_path LIKE :request_path')
-            ->where($adapter->prepareSqlCondition('request_path', array(
+            ->where($adapter->prepareSqlCondition('request_path', [
                 'regexp' => '^' . preg_quote($prefix) . '[0-9]*' . preg_quote($suffix) . '$'
-            )));
-        $bind = array(
+            ]));
+        $bind = [
             'store_id'            => (int)$storeId,
             'request_path'        => $prefix . '%' . $suffix,
-        );
+        ];
 
         return (int)$adapter->fetchOne($select, $bind);
     }
@@ -221,7 +221,7 @@ public function checkRequestPaths($paths, $storeId)
             ->from($this->getMainTable(), 'request_path')
             ->where('store_id = :store_id')
             ->where('request_path IN (?)', $paths);
-        $data = $adapter->fetchCol($select, array('store_id' => $storeId));
+        $data = $adapter->fetchCol($select, ['store_id' => $storeId]);
         $paths = array_diff($paths, $data);
         if (empty($paths)) {
             return false;
@@ -241,17 +241,17 @@ public function checkRequestPaths($paths, $storeId)
      */
     public function prepareRewrites($storeId, $categoryIds = null, $productIds = null)
     {
-        $rewrites   = array();
+        $rewrites   = [];
         $adapter    = $this->_getWriteAdapter();
         $select     = $adapter->select()
             ->from($this->getMainTable())
             ->where('store_id = :store_id')
             ->where('is_system = ?', 1);
-        $bind = array('store_id' => $storeId);
+        $bind = ['store_id' => $storeId];
         if ($categoryIds === null) {
             $select->where('category_id IS NULL');
         } elseif ($categoryIds) {
-            $catIds = is_array($categoryIds) ? $categoryIds : array($categoryIds);
+            $catIds = is_array($categoryIds) ? $categoryIds : [$categoryIds];
 
             // Check maybe we request products and root category id is within categoryIds,
             // it's a separate case because root category products are stored with NULL categoryId
@@ -306,13 +306,13 @@ public function saveRewrite($rewriteData, $rewrite)
         if ($rewrite && $rewrite->getId()) {
             if ($rewriteData['request_path'] != $rewrite->getRequestPath()) {
                 // Update existing rewrites history and avoid chain redirects
-                $where = array('target_path = ?' => $rewrite->getRequestPath());
+                $where = ['target_path = ?' => $rewrite->getRequestPath()];
                 if ($rewrite->getStoreId()) {
                     $where['store_id = ?'] = (int)$rewrite->getStoreId();
                 }
                 $adapter->update(
                     $this->getMainTable(),
-                    array('target_path' => $rewriteData['request_path']),
+                    ['target_path' => $rewriteData['request_path']],
                     $where
                 );
             }
@@ -354,24 +354,24 @@ public function saveCategoryAttribute(Varien_Object $category, $attributeCode)
         if (!isset($this->_categoryAttributes[$attributeCode])) {
             $attribute = $this->getCategoryModel()->getResource()->getAttribute($attributeCode);
 
-            $this->_categoryAttributes[$attributeCode] = array(
+            $this->_categoryAttributes[$attributeCode] = [
                 'entity_type_id' => $attribute->getEntityTypeId(),
                 'attribute_id'   => $attribute->getId(),
                 'table'          => $attribute->getBackend()->getTable(),
                 'is_global'      => $attribute->getIsGlobal()
-            );
+            ];
             unset($attribute);
         }
 
         $attributeTable = $this->_categoryAttributes[$attributeCode]['table'];
 
-        $attributeData = array(
+        $attributeData = [
             'entity_type_id'    => $this->_categoryAttributes[$attributeCode]['entity_type_id'],
             'attribute_id'      => $this->_categoryAttributes[$attributeCode]['attribute_id'],
             'store_id'          => $category->getStoreId(),
             'entity_id'         => $category->getId(),
             'value'             => $category->getData($attributeCode)
-        );
+        ];
 
         if ($this->_categoryAttributes[$attributeCode]['is_global'] || $category->getStoreId() == 0) {
             $attributeData['store_id'] = 0;
@@ -386,7 +386,7 @@ public function saveCategoryAttribute(Varien_Object $category, $attributeCode)
 
         $row = $adapter->fetchRow($select);
         if ($row) {
-            $whereCond = array('value_id = ?' => $row['value_id']);
+            $whereCond = ['value_id = ?' => $row['value_id']];
             $adapter->update($attributeTable, $attributeData, $whereCond);
         } else {
             $adapter->insert($attributeTable, $attributeData);
@@ -403,7 +403,7 @@ public function saveCategoryAttribute(Varien_Object $category, $attributeCode)
 
             $row = $adapter->fetchRow($select);
             if ($row) {
-                $whereCond = array('value_id = ?' => $row['value_id']);
+                $whereCond = ['value_id = ?' => $row['value_id']];
                 $adapter->update($attributeTable, $attributeData, $whereCond);
             } else {
                 $adapter->insert($attributeTable, $attributeData);
@@ -428,33 +428,33 @@ protected function _getCategoryAttribute($attributeCode, $categoryIds, $storeId)
         if (!isset($this->_categoryAttributes[$attributeCode])) {
             $attribute = $this->getCategoryModel()->getResource()->getAttribute($attributeCode);
 
-            $this->_categoryAttributes[$attributeCode] = array(
+            $this->_categoryAttributes[$attributeCode] = [
                 'entity_type_id' => $attribute->getEntityTypeId(),
                 'attribute_id'   => $attribute->getId(),
                 'table'          => $attribute->getBackend()->getTable(),
                 'is_global'      => $attribute->getIsGlobal(),
                 'is_static'      => $attribute->isStatic()
-            );
+            ];
             unset($attribute);
         }
 
         if (!is_array($categoryIds)) {
-            $categoryIds = array($categoryIds);
+            $categoryIds = [$categoryIds];
         }
 
         $attributeTable = $this->_categoryAttributes[$attributeCode]['table'];
         $select         = $adapter->select();
-        $bind           = array();
+        $bind           = [];
         if ($this->_categoryAttributes[$attributeCode]['is_static']) {
             $select
                 ->from(
                     $this->getTable('catalog/category'),
-                    array('value' => $attributeCode, 'entity_id' => 'entity_id')
+                    ['value' => $attributeCode, 'entity_id' => 'entity_id']
                 )
                 ->where('entity_id IN(?)', $categoryIds);
         } elseif ($this->_categoryAttributes[$attributeCode]['is_global'] || $storeId == 0) {
             $select
-                ->from($attributeTable, array('entity_id', 'value'))
+                ->from($attributeTable, ['entity_id', 'value'])
                 ->where('attribute_id = :attribute_id')
                 ->where('store_id = ?', 0)
                 ->where('entity_id IN(?)', $categoryIds);
@@ -463,13 +463,13 @@ protected function _getCategoryAttribute($attributeCode, $categoryIds, $storeId)
             $valueExpr = $adapter->getCheckSql('t2.value_id > 0', 't2.value', 't1.value');
             $select
                 ->from(
-                    array('t1' => $attributeTable),
-                    array('entity_id', 'value' => $valueExpr)
+                    ['t1' => $attributeTable],
+                    ['entity_id', 'value' => $valueExpr]
                 )
                 ->joinLeft(
-                    array('t2' => $attributeTable),
+                    ['t2' => $attributeTable],
                     't1.entity_id = t2.entity_id AND t1.attribute_id = t2.attribute_id AND t2.store_id = :store_id',
-                    array()
+                    []
                 )
                 ->where('t1.store_id = ?', 0)
                 ->where('t1.attribute_id = :attribute_id')
@@ -481,7 +481,7 @@ protected function _getCategoryAttribute($attributeCode, $categoryIds, $storeId)
 
         $rowSet = $adapter->fetchAll($select, $bind);
 
-        $attributes = array();
+        $attributes = [];
         foreach ($rowSet as $row) {
             $attributes[$row['entity_id']] = $row['value'];
         }
@@ -508,24 +508,24 @@ public function saveProductAttribute(Varien_Object $product, $attributeCode)
         if (!isset($this->_productAttributes[$attributeCode])) {
             $attribute = $this->getProductModel()->getResource()->getAttribute($attributeCode);
 
-            $this->_productAttributes[$attributeCode] = array(
+            $this->_productAttributes[$attributeCode] = [
                 'entity_type_id' => $attribute->getEntityTypeId(),
                 'attribute_id'   => $attribute->getId(),
                 'table'          => $attribute->getBackend()->getTable(),
                 'is_global'      => $attribute->getIsGlobal()
-            );
+            ];
             unset($attribute);
         }
 
         $attributeTable = $this->_productAttributes[$attributeCode]['table'];
 
-        $attributeData = array(
+        $attributeData = [
             'entity_type_id'    => $this->_productAttributes[$attributeCode]['entity_type_id'],
             'attribute_id'      => $this->_productAttributes[$attributeCode]['attribute_id'],
             'store_id'          => $product->getStoreId(),
             'entity_id'         => $product->getId(),
             'value'             => $product->getData($attributeCode)
-        );
+        ];
 
         if ($this->_productAttributes[$attributeCode]['is_global'] || $product->getStoreId() == 0) {
             $attributeData['store_id'] = 0;
@@ -540,7 +540,7 @@ public function saveProductAttribute(Varien_Object $product, $attributeCode)
 
         $row = $adapter->fetchRow($select);
         if ($row) {
-            $whereCond = array('value_id = ?' => $row['value_id']);
+            $whereCond = ['value_id = ?' => $row['value_id']];
             $adapter->update($attributeTable, $attributeData, $whereCond);
         } else {
             $adapter->insert($attributeTable, $attributeData);
@@ -557,7 +557,7 @@ public function saveProductAttribute(Varien_Object $product, $attributeCode)
 
             $row = $adapter->fetchRow($select);
             if ($row) {
-                $whereCond = array('value_id = ?' => $row['value_id']);
+                $whereCond = ['value_id = ?' => $row['value_id']];
                 $adapter->update($attributeTable, $attributeData, $whereCond);
             } else {
                 $adapter->insert($attributeTable, $attributeData);
@@ -582,24 +582,24 @@ public function _getProductAttribute($attributeCode, $productIds, $storeId)
         if (!isset($this->_productAttributes[$attributeCode])) {
             $attribute = $this->getProductModel()->getResource()->getAttribute($attributeCode);
 
-            $this->_productAttributes[$attributeCode] = array(
+            $this->_productAttributes[$attributeCode] = [
                 'entity_type_id' => $attribute->getEntityTypeId(),
                 'attribute_id'   => $attribute->getId(),
                 'table'          => $attribute->getBackend()->getTable(),
                 'is_global'      => $attribute->getIsGlobal()
-            );
+            ];
             unset($attribute);
         }
 
         if (!is_array($productIds)) {
-            $productIds = array($productIds);
+            $productIds = [$productIds];
         }
-        $bind = array('attribute_id' => $this->_productAttributes[$attributeCode]['attribute_id']);
+        $bind = ['attribute_id' => $this->_productAttributes[$attributeCode]['attribute_id']];
         $select = $adapter->select();
         $attributeTable = $this->_productAttributes[$attributeCode]['table'];
         if ($this->_productAttributes[$attributeCode]['is_global'] || $storeId == 0) {
             $select
-                ->from($attributeTable, array('entity_id', 'value'))
+                ->from($attributeTable, ['entity_id', 'value'])
                 ->where('attribute_id = :attribute_id')
                 ->where('store_id = ?', 0)
                 ->where('entity_id IN(?)', $productIds);
@@ -607,13 +607,13 @@ public function _getProductAttribute($attributeCode, $productIds, $storeId)
             $valueExpr = $adapter->getCheckSql('t2.value_id > 0', 't2.value', 't1.value');
             $select
                 ->from(
-                    array('t1' => $attributeTable),
-                    array('entity_id', 'value' => $valueExpr)
+                    ['t1' => $attributeTable],
+                    ['entity_id', 'value' => $valueExpr]
                 )
                 ->joinLeft(
-                    array('t2' => $attributeTable),
+                    ['t2' => $attributeTable],
                     't1.entity_id = t2.entity_id AND t1.attribute_id = t2.attribute_id AND t2.store_id=:store_id',
-                    array()
+                    []
                 )
                 ->where('t1.store_id = ?', 0)
                 ->where('t1.attribute_id = :attribute_id')
@@ -623,7 +623,7 @@ public function _getProductAttribute($attributeCode, $productIds, $storeId)
 
         $rowSet = $adapter->fetchAll($select, $bind);
 
-        $attributes = array();
+        $attributes = [];
         foreach ($rowSet as $row) {
             $attributes[$row['entity_id']] = $row['value'];
         }
@@ -662,9 +662,10 @@ protected function _prepareCategoryParentId(Varien_Object $category)
      */
     protected function _prepareStoreRootCategories($stores)
     {
-        $rootCategoryIds = array();
+        $rootCategoryIds = [];
         foreach ($stores as $store) {
-            $rootCategoryIds[$store->getRootCategoryId()] = $store->getRootCategoryId();
+            $rootCategoryId = $store->getRootCategoryId();
+            $rootCategoryIds[$rootCategoryId] = $rootCategoryId;
         }
         if ($rootCategoryIds) {
             $categories = $this->_getCategories($rootCategoryIds);
@@ -694,20 +695,20 @@ protected function _getCategories($categoryIds, $storeId = null, $path = null)
     {
         $isActiveAttribute = Mage::getSingleton('eav/config')
             ->getAttribute(Mage_Catalog_Model_Category::ENTITY, 'is_active');
-        $categories        = array();
+        $categories        = [];
         $adapter           = $this->_getReadAdapter();
 
         if (!is_array($categoryIds)) {
-            $categoryIds = array($categoryIds);
+            $categoryIds = [$categoryIds];
         }
         $isActiveExpr = $adapter->getCheckSql('c.value_id > 0', 'c.value', 'd.value');
         $select = $adapter->select()
-            ->from(array('main_table' => $this->getTable('catalog/category')), array(
+            ->from(['main_table' => $this->getTable('catalog/category')], [
                 'main_table.entity_id',
                 'main_table.parent_id',
                 'main_table.level',
                 'is_active' => $isActiveExpr,
-                'main_table.path'));
+                'main_table.path']);
 
         // Prepare variables for checking whether categories belong to store
         if ($path === null) {
@@ -722,26 +723,26 @@ protected function _getCategories($categoryIds, $storeId = null, $path = null)
                 ->where('main_table.path LIKE ?', $path . '%')
                 ->order('main_table.path');
         }
-        $table = $this->getTable(array('catalog/category', 'int'));
+        $table = $this->getTable(['catalog/category', 'int']);
         $select->joinLeft(
-            array('d' => $table),
+            ['d' => $table],
             'd.attribute_id = :attribute_id AND d.store_id = 0 AND d.entity_id = main_table.entity_id',
-            array()
+            []
         )
         ->joinLeft(
-            array('c' => $table),
+            ['c' => $table],
             'c.attribute_id = :attribute_id AND c.store_id = :store_id AND c.entity_id = main_table.entity_id',
-            array()
+            []
         );
 
         if ($storeId !== null) {
             $rootCategoryPath = $this->getStores($storeId)->getRootCategoryPath();
             $rootCategoryPathLength = strlen($rootCategoryPath);
         }
-        $bind = array(
+        $bind = [
             'attribute_id' => (int)$isActiveAttribute->getId(),
             'store_id'     => (int)$storeId
-        );
+        ];
 
         $rowSet = $adapter->fetchAll($select, $bind);
         foreach ($rowSet as $row) {
@@ -768,7 +769,7 @@ protected function _getCategories($categoryIds, $storeId = null, $path = null)
         unset($rowSet);
 
         if ($storeId !== null && $categories) {
-            foreach (array('name', 'url_key', 'url_path') as $attributeCode) {
+            foreach (['name', 'url_key', 'url_path'] as $attributeCode) {
                 $attributes = $this->_getCategoryAttribute(
                     $attributeCode,
                     array_keys($categories),
@@ -832,20 +833,20 @@ public function loadCategoryChilds(Varien_Object $category)
         }
 
         $categories = $this->_getCategories(null, $category->getStoreId(), $category->getPath() . '/');
-        $category->setChilds(array());
+        $category->setChilds([]);
         foreach ($categories as $child) {
             if (!is_array($child->getChilds())) {
-                $child->setChilds(array());
+                $child->setChilds([]);
             }
             if ($child->getParentId() == $category->getId()) {
-                $category->setChilds($category->getChilds() + array($child->getId() => $child));
+                $category->setChilds($category->getChilds() + [$child->getId() => $child]);
             } else {
                 if (isset($categories[$child->getParentId()])) {
                     if (!is_array($categories[$child->getParentId()]->getChilds())) {
-                        $categories[$child->getParentId()]->setChilds(array());
+                        $categories[$child->getParentId()]->setChilds([]);
                     }
                     $categories[$child->getParentId()]->setChilds(
-                        $categories[$child->getParentId()]->getChilds() + array($child->getId() => $child)
+                        $categories[$child->getParentId()]->getChilds() + [$child->getId() => $child]
                     );
                 }
             }
@@ -871,10 +872,10 @@ public function getRootChildrenIds($categoryId, $categoryPath, $includeStart = t
             // Select all descedant category ids
             $adapter = $this->_getReadAdapter();
             $select = $adapter->select()
-                ->from(array($this->getTable('catalog/category')), array('entity_id'))
+                ->from([$this->getTable('catalog/category')], ['entity_id'])
                 ->where('path LIKE ?', $categoryPath . '/%');
 
-            $categoryIds = array();
+            $categoryIds = [];
             $rowSet = $adapter->fetchAll($select);
             foreach ($rowSet as $row) {
                 $categoryIds[$row['entity_id']] = $row['entity_id'];
@@ -924,10 +925,10 @@ public function getProductIdsByCategory($category)
         }
         $adapter = $this->_getReadAdapter();
         $select = $adapter->select()
-            ->from($this->getTable('catalog/category_product'), array('product_id'))
+            ->from($this->getTable('catalog/category_product'), ['product_id'])
             ->where('category_id = :category_id')
             ->order('product_id');
-        $bind = array('category_id' => $categoryId);
+        $bind = ['category_id' => $categoryId];
 
         return $adapter->fetchCol($select, $bind);
     }
@@ -943,25 +944,25 @@ public function getProductIdsByCategory($category)
      */
     protected function _getProducts($productIds, $storeId, $entityId, &$lastEntityId)
     {
-        $products   = array();
+        $products   = [];
         $websiteId  = Mage::app()->getStore($storeId)->getWebsiteId();
         $adapter    = $this->_getReadAdapter();
         if ($productIds !== null) {
             if (!is_array($productIds)) {
-                $productIds = array($productIds);
+                $productIds = [$productIds];
             }
         }
-        $bind = array(
+        $bind = [
             'website_id' => (int)$websiteId,
             'entity_id'  => (int)$entityId,
-        );
+        ];
         $select = $adapter->select()
             ->useStraightJoin(true)
-            ->from(array('e' => $this->getTable('catalog/product')), array('entity_id'))
+            ->from(['e' => $this->getTable('catalog/product')], ['entity_id'])
             ->join(
-                array('w' => $this->getTable('catalog/product_website')),
+                ['w' => $this->getTable('catalog/product_website')],
                 'e.entity_id = w.product_id AND w.website_id = :website_id',
-                array()
+                []
             )
             ->where('e.entity_id > :entity_id')
             ->order('e.entity_id')
@@ -974,7 +975,7 @@ protected function _getProducts($productIds, $storeId, $entityId, &$lastEntityId
         foreach ($rowSet as $row) {
             $product = new Varien_Object($row);
             $product->setIdFieldName('entity_id');
-            $product->setCategoryIds(array());
+            $product->setCategoryIds([]);
             $product->setStoreId($storeId);
             $products[$product->getId()] = $product;
             $lastEntityId = $product->getId();
@@ -986,7 +987,7 @@ protected function _getProducts($productIds, $storeId, $entityId, &$lastEntityId
             $select = $adapter->select()
                 ->from(
                     $this->getTable('catalog/category_product'),
-                    array('product_id', 'category_id')
+                    ['product_id', 'category_id']
                 )
                 ->where('product_id IN(?)', array_keys($products));
             $categories = $adapter->fetchAll($select);
@@ -997,7 +998,7 @@ protected function _getProducts($productIds, $storeId, $entityId, &$lastEntityId
                 $products[$productId]->setCategoryIds($categoryIds);
             }
 
-            foreach (array('name', 'url_key', 'url_path') as $attributeCode) {
+            foreach (['name', 'url_key', 'url_path'] as $attributeCode) {
                 $attributes = $this->_getProductAttribute($attributeCode, array_keys($products), $storeId);
                 foreach ($attributes as $productId => $attributeValue) {
                     $products[$productId]->setData($attributeCode, $attributeValue);
@@ -1048,7 +1049,7 @@ public function getProductsByCategory(Varien_Object $category, &$lastEntityId)
     {
         $productIds = $this->getProductIdsByCategory($category);
         if (!$productIds) {
-            return array();
+            return [];
         }
         return $this->_getProducts($productIds, $category->getStoreId(), $lastEntityId, $lastEntityId);
     }
@@ -1064,19 +1065,19 @@ public function clearCategoryProduct($storeId)
     {
         $adapter = $this->_getWriteAdapter();
         $select = $adapter->select()
-            ->from(array('tur' => $this->getMainTable()), $this->getIdFieldName())
+            ->from(['tur' => $this->getMainTable()], $this->getIdFieldName())
             ->joinLeft(
-                array('tcp' => $this->getTable('catalog/category_product')),
+                ['tcp' => $this->getTable('catalog/category_product')],
                 'tur.category_id = tcp.category_id AND tur.product_id = tcp.product_id',
-                array()
+                []
             )
             ->where('tur.store_id = :store_id')
             ->where('tur.category_id IS NOT NULL')
             ->where('tur.product_id IS NOT NULL')
             ->where('tcp.category_id IS NULL');
-        $rewriteIds = $adapter->fetchCol($select, array('store_id' => $storeId));
+        $rewriteIds = $adapter->fetchCol($select, ['store_id' => $storeId]);
         if ($rewriteIds) {
-            $where = array($this->getIdFieldName() . ' IN(?)' => $rewriteIds);
+            $where = [$this->getIdFieldName() . ' IN(?)' => $rewriteIds];
             $adapter->delete($this->getMainTable(), $where);
         }
 
@@ -1095,12 +1096,12 @@ public function clearCategoryProduct($storeId)
      * @param array $excludeCategoryIds Array of category Ids that should be skipped
      * @return $this
      */
-    public function clearProductRewrites($productId, $storeId, $excludeCategoryIds = array())
+    public function clearProductRewrites($productId, $storeId, $excludeCategoryIds = [])
     {
-        $where = array(
+        $where = [
             'product_id = ?' => $productId,
             'store_id = ?' => $storeId
-        );
+        ];
 
         if (!empty($excludeCategoryIds)) {
             $where['category_id NOT IN (?)'] = $excludeCategoryIds;
@@ -1131,11 +1132,11 @@ public function clearStoreCategoriesInvalidRewrites($storeId)
         $categoryIds = $this->getRootChildrenIds($rootCategoryId, $store->getRootCategoryPath());
 
         // Remove all store catalog rewrites that are for some category or cartegory/product not within store categories
-        $where   = array(
+        $where   = [
             'store_id = ?' => $storeId,
             'category_id IS NOT NULL', // For sure check that it's a catalog rewrite
             'category_id NOT IN (?)' => $categoryIds
-        );
+        ];
 
         $this->_getWriteAdapter()->delete($this->getMainTable(), $where);
 
@@ -1158,16 +1159,16 @@ public function clearStoreProductsInvalidRewrites($storeId, $productId = null)
     {
         $store   = $this->getStores($storeId);
         $adapter = $this->_getReadAdapter();
-        $bind    = array(
+        $bind    = [
             'website_id' => (int)$store->getWebsiteId(),
             'store_id'   => (int)$storeId
-        );
+        ];
         $select = $adapter->select()
-            ->from(array('rewrite' => $this->getMainTable()), $this->getIdFieldName())
+            ->from(['rewrite' => $this->getMainTable()], $this->getIdFieldName())
             ->joinLeft(
-                array('website' => $this->getTable('catalog/product_website')),
+                ['website' => $this->getTable('catalog/product_website')],
                 'rewrite.product_id = website.product_id AND website.website_id = :website_id',
-                array()
+                []
             )->where('rewrite.store_id = :store_id')
             ->where('rewrite.category_id IS NULL');
         if ($productId) {
@@ -1179,7 +1180,7 @@ public function clearStoreProductsInvalidRewrites($storeId, $productId = null)
 
         $rewriteIds = $adapter->fetchCol($select, $bind);
         if ($rewriteIds) {
-            $where = array($this->getIdFieldName() . ' IN(?)' => $rewriteIds);
+            $where = [$this->getIdFieldName() . ' IN(?)' => $rewriteIds];
             $this->_getWriteAdapter()->delete($this->getMainTable(), $where);
         }
 
@@ -1227,7 +1228,7 @@ public function deleteCategoryProductStoreRewrites($categoryId, $productIds = nu
         // Notice that we don't include category_id = NULL in case of root category,
         // because product removed from all categories but assigned to store's website is still
         // assumed to be in root cat. Unassigned products must be removed by other routine.
-        $condition = array('category_id = ?' => $categoryId);
+        $condition = ['category_id = ?' => $categoryId];
         if (empty($productIds)) {
             $condition[] = 'product_id IS NOT NULL';
         } else {
@@ -1256,7 +1257,7 @@ public function deleteCategoryProductStoreRewrites($categoryId, $productIds = nu
      */
     public function getRewriteByProductStore(array $products)
     {
-        $result = array();
+        $result = [];
 
         if (empty($products)) {
             return $result;
@@ -1265,26 +1266,26 @@ public function getRewriteByProductStore(array $products)
 
         $select = $adapter->select()
             ->from(
-                array('i' => $this->getTable('catalog/category_product_index')),
-                array('product_id', 'store_id', 'visibility')
+                ['i' => $this->getTable('catalog/category_product_index')],
+                ['product_id', 'store_id', 'visibility']
             )
             ->joinLeft(
-                array('r' => $this->getMainTable()),
+                ['r' => $this->getMainTable()],
                 'i.product_id = r.product_id AND i.store_id=r.store_id AND r.category_id IS NULL',
-                array('request_path')
+                ['request_path']
             );
 
-        $bind = array();
+        $bind = [];
         foreach ($products as $productId => $storeId) {
             $catId = Mage::app()->getStore($storeId)->getRootCategoryId();
             $productBind = 'product_id' . $productId;
             $storeBind   = 'store_id' . $storeId;
             $catBind     = 'category_id' . $catId;
-            $cond  = '(' . implode(' AND ', array(
+            $cond  = '(' . implode(' AND ', [
                 'i.product_id = :' . $productBind,
                 'i.store_id = :' . $storeBind,
                 'i.category_id = :' . $catBind,
-            )) . ')';
+                ]) . ')';
             $bind[$productBind] = $productId;
             $bind[$storeBind]   = $storeId;
             $bind[$catBind]     = $catId;
@@ -1293,11 +1294,11 @@ public function getRewriteByProductStore(array $products)
 
         $rowSet = $adapter->fetchAll($select, $bind);
         foreach ($rowSet as $row) {
-            $result[$row['product_id']] = array(
+            $result[$row['product_id']] = [
                 'store_id'      => $row['store_id'],
                 'visibility'    => $row['visibility'],
                 'url_rewrite'   => $row['request_path'],
-            );
+            ];
         }
 
         return $result;
@@ -1312,7 +1313,7 @@ public function getRewriteByProductStore(array $products)
      * @param array $_checkedPaths internal varible to prevent infinite loops.
      * @return string | bool
      */
-    public function findFinalTargetPath($requestPath, $storeId, &$_checkedPaths = array())
+    public function findFinalTargetPath($requestPath, $storeId, &$_checkedPaths = [])
     {
         if (in_array($requestPath, $_checkedPaths)) {
             return false;
@@ -1321,7 +1322,7 @@ public function findFinalTargetPath($requestPath, $storeId, &$_checkedPaths = ar
         $_checkedPaths[] = $requestPath;
 
         $select = $this->_getWriteAdapter()->select()
-            ->from($this->getMainTable(), array('target_path', 'id_path'))
+            ->from($this->getMainTable(), ['target_path', 'id_path'])
             ->where('store_id = ?', $storeId)
             ->where('request_path = ?', $requestPath);
 
@@ -1359,10 +1360,10 @@ public function deleteRewrite($requestPath, $storeId)
      */
     public function deleteRewriteRecord($requestPath, $storeId, $rp = false)
     {
-        $conditions =  array(
+        $conditions =  [
             'store_id = ?' => $storeId,
             'request_path = ?' => $requestPath,
-        );
+        ];
         if ($rp) {
             $conditions['options = ?'] = 'RP';
         }
diff --git a/app/code/core/Mage/CatalogInventory/Model/Observer.php b/app/code/core/Mage/CatalogInventory/Model/Observer.php
index 9a06dc685c6..11809fd4e4e 100644
--- a/app/code/core/Mage/CatalogInventory/Model/Observer.php
+++ b/app/code/core/Mage/CatalogInventory/Model/Observer.php
@@ -40,7 +40,7 @@ class Mage_CatalogInventory_Model_Observer
      * @deprecated after 1.4.2.0-rc1
      * @var array
      */
-    protected $_checkedProductsQty = array();
+    protected $_checkedProductsQty = [];
 
     /**
      * Product qty's checked
@@ -48,14 +48,14 @@ class Mage_CatalogInventory_Model_Observer
      *
      * @var array
      */
-    protected $_checkedQuoteItems = array();
+    protected $_checkedQuoteItems = [];
 
     /**
      * Array of items that need to be reindexed
      *
      * @var array
      */
-    protected $_itemsForReindex = array();
+    protected $_itemsForReindex = [];
 
     /**
      * Array, indexed by product's id to contain stockItems of already loaded products
@@ -63,7 +63,7 @@ class Mage_CatalogInventory_Model_Observer
      *
      * @var array
      */
-    protected $_stockItemsArray = array();
+    protected $_stockItemsArray = [];
 
     /**
      * Add stock information to product
@@ -179,21 +179,21 @@ public function copyInventoryData($observer)
         $newProduct = $observer->getEvent()->getNewProduct();
 
         $newProduct->unsStockItem();
-        $stockData = array(
+        $stockData = [
             'use_config_min_qty'        => 1,
             'use_config_min_sale_qty'   => 1,
             'use_config_max_sale_qty'   => 1,
             'use_config_backorders'     => 1,
             'use_config_notify_stock_qty' => 1
-        );
+        ];
         $currentStockItem = $currentProduct->getStockItem();
         if ($currentStockItem) {
-            $stockData += array(
+            $stockData += [
                 'use_config_enable_qty_inc'  => $currentStockItem->getData('use_config_enable_qty_inc'),
                 'enable_qty_increments'             => $currentStockItem->getData('enable_qty_increments'),
                 'use_config_qty_increments'         => $currentStockItem->getData('use_config_qty_increments'),
                 'qty_increments'                    => $currentStockItem->getData('qty_increments'),
-            );
+            ];
         }
         $newProduct->setStockData($stockData);
 
@@ -258,10 +258,10 @@ protected function _prepareItemForSave($item, $product)
     protected function _removeErrorsFromQuoteAndItem($item, $code)
     {
         if ($item->getHasError()) {
-            $params = array(
+            $params = [
                 'origin' => 'cataloginventory',
                 'code' => $code
-            );
+            ];
             $item->removeErrorInfosByParams($params);
         }
 
@@ -289,10 +289,10 @@ protected function _removeErrorsFromQuoteAndItem($item, $code)
         }
 
         if ($quote->getHasError() && $canRemoveErrorFromQuote) {
-            $params = array(
+            $params = [
                 'origin' => 'cataloginventory',
                 'code' => $code
-            );
+            ];
             $quote->removeErrorInfosByParams(null, $params);
         }
 
@@ -689,10 +689,10 @@ protected function _addItemToQtyArray($quoteItem, &$items)
             if ($quoteItem->getProduct()) {
                 $stockItem = $quoteItem->getProduct()->getStockItem();
             }
-            $items[$productId] = array(
+            $items[$productId] = [
                 'item' => $stockItem,
                 'qty'  => $quoteItem->getTotalQty()
-            );
+            ];
         }
     }
 
@@ -710,7 +710,7 @@ protected function _addItemToQtyArray($quoteItem, &$items)
      */
     protected function _getProductsQty($relatedItems)
     {
-        $items = array();
+        $items = [];
         foreach ($relatedItems as $item) {
             $productId  = $item->getProductId();
             if (!$productId) {
@@ -729,7 +729,7 @@ protected function _getProductsQty($relatedItems)
     }
 
     /**
-     * Refresh stock index for specific stock items after succesful order placement
+     * Refresh stock index for specific stock items after successful order placement
      *
      * @param Varien_Event_Observer $observer
      * @return Mage_CatalogInventory_Model_Observer
@@ -739,13 +739,15 @@ public function reindexQuoteInventory($observer)
         // Reindex quote ids
         /** @var Mage_Sales_Model_Quote $quote */
         $quote = $observer->getEvent()->getQuote();
-        $productIds = array();
+        $productIds = [];
         foreach ($quote->getAllItems() as $item) {
-            $productIds[$item->getProductId()] = $item->getProductId();
+            $productId = $item->getProductId();
+            $productIds[$productId] = $productId;
             $children   = $item->getChildrenItems();
             if ($children) {
                 foreach ($children as $childItem) {
-                    $productIds[$childItem->getProductId()] = $childItem->getProductId();
+                    $childItemProductId = $childItem->getProductId();
+                    $productIds[$childItemProductId] = $childItemProductId;
                 }
             }
         }
@@ -758,10 +760,10 @@ public function reindexQuoteInventory($observer)
          * This limits the number of stock re-indexing that takes place,
          * especially in stores where stock is not managed
          **/
-        $productIds = array_map('intval', $productIds);
+        $productIds = array_map('\intval', $productIds);
         $stockCollection = Mage::getModel('cataloginventory/stock_item')->getCollection()
-            ->addFieldToFilter('product_id', array('in' => $productIds))
-            ->addFieldToFilter('manage_stock', array('eq' => 1));
+            ->addFieldToFilter('product_id', ['in' => $productIds])
+            ->addFieldToFilter('manage_stock', ['eq' => 1]);
         $stockCollection->getSelect()->reset(Zend_Db_Select::COLUMNS)->columns(['product_id']);
         $productIds = $stockCollection->getColumnValues('product_id');
 
@@ -770,14 +772,14 @@ public function reindexQuoteInventory($observer)
         }
 
         // Reindex previously remembered items
-        $productIds = array();
+        $productIds = [];
         foreach ($this->_itemsForReindex as $item) {
             $item->save();
             $productIds[] = $item->getProductId();
         }
         Mage::getResourceSingleton('catalog/product_indexer_price')->reindexProductIds($productIds);
 
-        $this->_itemsForReindex = array(); // Clear list of remembered items - we don't need it anymore
+        $this->_itemsForReindex = []; // Clear list of remembered items - we don't need it anymore
 
         return $this;
     }
@@ -791,7 +793,7 @@ public function refundOrderInventory($observer)
     {
         /* @var Mage_Sales_Model_Order_Creditmemo $creditmemo */
         $creditmemo = $observer->getEvent()->getCreditmemo();
-        $items = array();
+        $items = [];
         foreach ($creditmemo->getAllItems() as $item) {
             /* @var Mage_Sales_Model_Order_Creditmemo_Item $item */
             $return = false;
@@ -810,10 +812,10 @@ public function refundOrderInventory($observer)
                 if (isset($items[$item->getProductId()])) {
                     $items[$item->getProductId()]['qty'] += $qty;
                 } else {
-                    $items[$item->getProductId()] = array(
+                    $items[$item->getProductId()] = [
                         'qty'  => $qty,
                         'item' => null,
-                    );
+                    ];
                 }
             }
         }
@@ -968,7 +970,7 @@ public function lockOrderInventoryData($observer)
     {
         /** @var Mage_Sales_Model_Order $order */
         $order = $observer->getEvent()->getOrder();
-        $productIds = array();
+        $productIds = [];
 
         /**
          * Do lock only for new order
diff --git a/app/code/core/Mage/Checkout/Model/Cart.php b/app/code/core/Mage/Checkout/Model/Cart.php
index 8e46c6bf58a..6ec634bb3e7 100644
--- a/app/code/core/Mage/Checkout/Model/Cart.php
+++ b/app/code/core/Mage/Checkout/Model/Cart.php
@@ -101,7 +101,8 @@ public function getQuoteProductIds()
         if (is_null($products)) {
             $products = array();
             foreach ($this->getQuote()->getAllItems() as $item) {
-                $products[$item->getProductId()] = $item->getProductId();
+                $productId = $item->getProductId();
+                $products[$productId] = $productId;
             }
             $this->setData('product_ids', $products);
         }
diff --git a/app/code/core/Mage/Core/Block/Abstract.php b/app/code/core/Mage/Core/Block/Abstract.php
index ddd108223c3..a00e1c149b0 100644
--- a/app/code/core/Mage/Core/Block/Abstract.php
+++ b/app/code/core/Mage/Core/Block/Abstract.php
@@ -723,7 +723,7 @@ public function insert($block, $siblingName = '', $after = false, $alias = '')
 
         if ($siblingName === '') {
             if ($after) {
-                array_push($this->_sortedChildren, $name);
+                $this->_sortedChildren[] = $name;
             } else {
                 array_unshift($this->_sortedChildren, $name);
             }
@@ -736,7 +736,7 @@ public function insert($block, $siblingName = '', $after = false, $alias = '')
                 array_splice($this->_sortedChildren, $key, 0, $name);
             } else {
                 if ($after) {
-                    array_push($this->_sortedChildren, $name);
+                    $this->_sortedChildren[] = $name;
                 } else {
                     array_unshift($this->_sortedChildren, $name);
                 }
diff --git a/app/code/core/Mage/Core/Controller/Varien/Front.php b/app/code/core/Mage/Core/Controller/Varien/Front.php
index 8910c655eeb..91a1bff1ea8 100644
--- a/app/code/core/Mage/Core/Controller/Varien/Front.php
+++ b/app/code/core/Mage/Core/Controller/Varien/Front.php
@@ -396,7 +396,7 @@ protected function _isAdminFrontNameMatched($request)
         if (is_array($adminFrontNameNodes)) {
             foreach ($adminFrontNameNodes as $frontNameNode) {
                 /** @var SimpleXMLElement $frontNameNode */
-                array_push($adminFrontNames, (string)$frontNameNode);
+                $adminFrontNames[] = (string)$frontNameNode;
             }
         }
 
diff --git a/app/code/core/Mage/Core/Model/Design/Package.php b/app/code/core/Mage/Core/Model/Design/Package.php
index 20dd83fe24a..9ab1ea4a566 100644
--- a/app/code/core/Mage/Core/Model/Design/Package.php
+++ b/app/code/core/Mage/Core/Model/Design/Package.php
@@ -888,7 +888,7 @@ protected function _cssMergerImportCallback($match)
     protected function _cssMergerUrlCallback($match)
     {
         $quote = ($match[1][0] == "'" || $match[1][0] == '"') ? $match[1][0] : '';
-        $uri = ($quote == '') ? $match[1] : substr($match[1], 1, strlen($match[1]) - 2);
+        $uri = ($quote == '') ? $match[1] : substr($match[1], 1, -1);
         $uri = $this->_prepareUrl($uri);
 
         return "url({$quote}{$uri}{$quote})";
diff --git a/app/code/core/Mage/Core/Model/Email/Info.php b/app/code/core/Mage/Core/Model/Email/Info.php
index ac76384db93..a4557cb4baa 100644
--- a/app/code/core/Mage/Core/Model/Email/Info.php
+++ b/app/code/core/Mage/Core/Model/Email/Info.php
@@ -76,8 +76,8 @@ class Mage_Core_Model_Email_Info extends Varien_Object
      */
     public function addBcc($email, $name = null)
     {
-        array_push($this->_bccNames, $name);
-        array_push($this->_bccEmails, $email);
+        $this->_bccNames[] = $name;
+        $this->_bccEmails[] = $email;
         return $this;
     }
 
@@ -90,8 +90,8 @@ public function addBcc($email, $name = null)
      */
     public function addTo($email, $name = null)
     {
-        array_push($this->_toNames, $name);
-        array_push($this->_toEmails, $email);
+        $this->_toNames[] = $name;
+        $this->_toEmails[] = $email;
         return $this;
     }
 
diff --git a/app/code/core/Mage/Core/Model/Email/Template/Mailer.php b/app/code/core/Mage/Core/Model/Email/Template/Mailer.php
index 7af8b8c6b47..7ff671c3323 100644
--- a/app/code/core/Mage/Core/Model/Email/Template/Mailer.php
+++ b/app/code/core/Mage/Core/Model/Email/Template/Mailer.php
@@ -52,7 +52,7 @@ class Mage_Core_Model_Email_Template_Mailer extends Varien_Object
      */
     public function addEmailInfo(Mage_Core_Model_Email_Info $emailInfo)
     {
-        array_push($this->_emailInfos, $emailInfo);
+        $this->_emailInfos[] = $emailInfo;
         return $this;
     }
 
diff --git a/app/code/core/Mage/Core/Model/Store.php b/app/code/core/Mage/Core/Model/Store.php
index 2335bc25be4..bd46cde21a1 100644
--- a/app/code/core/Mage/Core/Model/Store.php
+++ b/app/code/core/Mage/Core/Model/Store.php
@@ -42,6 +42,7 @@
  * @method $this setName(string $value)
  * @method $thissetRootCategoryPath(string $value)
  * @method $this setRootCategory(Mage_Catalog_Model_Category $value)
+ * @method $this setRootCategoryPath(string $value)
  * @method int getSortOrder()
  * @method $this setSortOrder(int $value)
  * @method int getStoreId()
diff --git a/app/code/core/Mage/Core/Model/Store/Group.php b/app/code/core/Mage/Core/Model/Store/Group.php
index 92f0e1ec010..81673a5fa46 100644
--- a/app/code/core/Mage/Core/Model/Store/Group.php
+++ b/app/code/core/Mage/Core/Model/Store/Group.php
@@ -76,14 +76,14 @@ class Mage_Core_Model_Store_Group extends Mage_Core_Model_Abstract
      *
      * @var array
      */
-    protected $_storeIds = array();
+    protected $_storeIds = [];
 
     /**
      * Group store codes array
      *
      * @var array
      */
-    protected $_storeCodes = array();
+    protected $_storeCodes = [];
 
     /**
      * The number of stores in a group
@@ -125,14 +125,15 @@ protected function _construct()
      */
     protected function _loadStores()
     {
-        $this->_stores = array();
+        $this->_stores = [];
         $this->_storesCount = 0;
         /** @var Mage_Core_Model_Store $store */
         foreach ($this->getStoreCollection() as $store) {
-            $this->_stores[$store->getId()] = $store;
-            $this->_storeIds[$store->getId()] = $store->getId();
-            $this->_storeCodes[$store->getId()] = $store->getCode();
-            if ($this->getDefaultStoreId() == $store->getId()) {
+            $storeId = $store->getId();
+            $this->_stores[$storeId] = $store;
+            $this->_storeIds[$storeId] = $storeId;
+            $this->_storeCodes[$storeId] = $store->getCode();
+            if ($this->getDefaultStoreId() == $storeId) {
                 $this->_defaultStore = $store;
             }
             $this->_storesCount ++;
@@ -146,13 +147,14 @@ protected function _loadStores()
      */
     public function setStores($stores)
     {
-        $this->_stores = array();
+        $this->_stores = [];
         $this->_storesCount = 0;
         foreach ($stores as $store) {
-            $this->_stores[$store->getId()] = $store;
-            $this->_storeIds[$store->getId()] = $store->getId();
-            $this->_storeCodes[$store->getId()] = $store->getCode();
-            if ($this->getDefaultStoreId() == $store->getId()) {
+            $storeId = $store->getId();
+            $this->_stores[$storeId] = $store;
+            $this->_storeIds[$storeId] = $storeId;
+            $this->_storeCodes[$storeId] = $store->getCode();
+            if ($this->getDefaultStoreId() == $storeId) {
                 $this->_defaultStore = $store;
             }
             $this->_storesCount ++;
@@ -267,10 +269,10 @@ public function getDefaultStoreByLocale($locale)
      */
     public function getStoresByLocale($locale)
     {
-        $stores = array();
+        $stores = [];
         foreach ($this->getStores() as $store) {
             if ($store->getLocaleCode() == $locale) {
-                array_push($stores, $store);
+                $stores[] = $store;
             }
         }
         return $stores;
diff --git a/app/code/core/Mage/Core/Model/Website.php b/app/code/core/Mage/Core/Model/Website.php
index 94039d0de77..d4797bc2d04 100644
--- a/app/code/core/Mage/Core/Model/Website.php
+++ b/app/code/core/Mage/Core/Model/Website.php
@@ -73,7 +73,7 @@ class Mage_Core_Model_Website extends Mage_Core_Model_Abstract
      *
      * @var array
      */
-    protected $_configCache = array();
+    protected $_configCache = [];
 
     /**
      * Website Group Coleection array
@@ -87,7 +87,7 @@ class Mage_Core_Model_Website extends Mage_Core_Model_Abstract
      *
      * @var array
      */
-    protected $_groupIds = array();
+    protected $_groupIds = [];
 
     /**
      * The number of groups in a website
@@ -108,14 +108,14 @@ class Mage_Core_Model_Website extends Mage_Core_Model_Abstract
      *
      * @var array
      */
-    protected $_storeIds = array();
+    protected $_storeIds = [];
 
     /**
      * Website store codes array
      *
      * @var array
      */
-    protected $_storeCodes = array();
+    protected $_storeCodes = [];
 
     /**
      * The number of stores in a website
@@ -215,7 +215,7 @@ public function getConfig($path)
                 #throw Mage::exception('Mage_Core', Mage::helper('core')->__('Invalid website\'s configuration path: %s', $path));
             }
             if ($config->hasChildren()) {
-                $value = array();
+                $value = [];
                 foreach ($config->children() as $k => $v) {
                     $value[$k] = $v;
                 }
@@ -233,12 +233,13 @@ public function getConfig($path)
      */
     protected function _loadGroups()
     {
-        $this->_groups = array();
+        $this->_groups = [];
         $this->_groupsCount = 0;
         foreach ($this->getGroupCollection() as $group) {
-            $this->_groups[$group->getId()] = $group;
-            $this->_groupIds[$group->getId()] = $group->getId();
-            if ($this->getDefaultGroupId() == $group->getId()) {
+            $groupId = $group->getId();
+            $this->_groups[$groupId] = $group;
+            $this->_groupIds[$groupId] = $groupId;
+            if ($this->getDefaultGroupId() == $groupId) {
                 $this->_defaultGroup = $group;
             }
             $this->_groupsCount ++;
@@ -253,12 +254,13 @@ protected function _loadGroups()
      */
     public function setGroups($groups)
     {
-        $this->_groups = array();
+        $this->_groups = [];
         $this->_groupsCount = 0;
         foreach ($groups as $group) {
-            $this->_groups[$group->getId()] = $group;
-            $this->_groupIds[$group->getId()] = $group->getId();
-            if ($this->getDefaultGroupId() == $group->getId()) {
+            $groupId = $group->getId();
+            $this->_groups[$groupId] = $group;
+            $this->_groupIds[$groupId] = $groupId;
+            if ($this->getDefaultGroupId() == $groupId) {
                 $this->_defaultGroup = $group;
             }
             $this->_groupsCount ++;
@@ -339,13 +341,14 @@ public function getDefaultGroup()
      */
     protected function _loadStores()
     {
-        $this->_stores = array();
+        $this->_stores = [];
         $this->_storesCount = 0;
         foreach ($this->getStoreCollection() as $store) {
-            $this->_stores[$store->getId()] = $store;
-            $this->_storeIds[$store->getId()] = $store->getId();
-            $this->_storeCodes[$store->getId()] = $store->getCode();
-            if ($this->getDefaultGroup() && $this->getDefaultGroup()->getDefaultStoreId() == $store->getId()) {
+            $storeId = $store->getId();
+            $this->_stores[$storeId] = $store;
+            $this->_storeIds[$storeId] = $storeId;
+            $this->_storeCodes[$storeId] = $store->getCode();
+            if ($this->getDefaultGroup() && $this->getDefaultGroup()->getDefaultStoreId() == $storeId) {
                 $this->_defaultStore = $store;
             }
             $this->_storesCount ++;
@@ -359,13 +362,14 @@ protected function _loadStores()
      */
     public function setStores($stores)
     {
-        $this->_stores = array();
+        $this->_stores = [];
         $this->_storesCount = 0;
         foreach ($stores as $store) {
-            $this->_stores[$store->getId()] = $store;
-            $this->_storeIds[$store->getId()] = $store->getId();
-            $this->_storeCodes[$store->getId()] = $store->getCode();
-            if ($this->getDefaultGroup() && $this->getDefaultGroup()->getDefaultStoreId() == $store->getId()) {
+            $storeId = $store->getId();
+            $this->_stores[$storeId] = $store;
+            $this->_storeIds[$storeId] = $storeId;
+            $this->_storeCodes[$storeId] = $store->getCode();
+            if ($this->getDefaultGroup() && $this->getDefaultGroup()->getDefaultStoreId() == $storeId) {
                 $this->_defaultStore = $store;
             }
             $this->_storesCount ++;
@@ -460,7 +464,7 @@ public function isCanDelete()
      */
     public function getWebsiteGroupStore()
     {
-        return implode('-', array($this->getWebsiteId(), $this->getGroupId(), $this->getStoreId()));
+        return implode('-', [$this->getWebsiteId(), $this->getGroupId(), $this->getStoreId()]);
     }
 
     /**
diff --git a/app/code/core/Mage/Customer/controllers/AccountController.php b/app/code/core/Mage/Customer/controllers/AccountController.php
index 99e50de1461..192d8f8a4e4 100644
--- a/app/code/core/Mage/Customer/controllers/AccountController.php
+++ b/app/code/core/Mage/Customer/controllers/AccountController.php
@@ -851,7 +851,7 @@ public function resetPasswordPostAction()
 
         $errorMessages = array();
         if (iconv_strlen($password) <= 0) {
-            array_push($errorMessages, $this->_getHelper('customer')->__('New password field cannot be empty.'));
+            $errorMessages[] = $this->_getHelper('customer')->__('New password field cannot be empty.');
         }
         /** @var Mage_Customer_Model_Customer $customer */
         $customer = $this->_getModel('customer/customer')->load($customerId);
diff --git a/app/code/core/Mage/Downloadable/Helper/File.php b/app/code/core/Mage/Downloadable/Helper/File.php
index e4d426e0486..1722868258c 100644
--- a/app/code/core/Mage/Downloadable/Helper/File.php
+++ b/app/code/core/Mage/Downloadable/Helper/File.php
@@ -112,7 +112,7 @@ protected function _moveFileFromTmp($baseTmpPath, $basePath, $file)
         }
 
         if (strrpos($file, '.tmp') == strlen($file)-4) {
-            $file = substr($file, 0, strlen($file)-4);
+            $file = substr($file, 0, -4);
         }
 
         $destFile = dirname($file) . $ioObject->dirsep()
diff --git a/app/code/core/Mage/Downloadable/Model/Product/Type.php b/app/code/core/Mage/Downloadable/Model/Product/Type.php
index 49a45f167ac..689f2c6b7e7 100644
--- a/app/code/core/Mage/Downloadable/Model/Product/Type.php
+++ b/app/code/core/Mage/Downloadable/Model/Product/Type.php
@@ -467,7 +467,7 @@ public function isSalable($product = null)
     public function processBuyRequest($product, $buyRequest)
     {
         $links = $buyRequest->getLinks();
-        $links = (is_array($links)) ? array_filter($links, 'intval') : array();
+        $links = (is_array($links)) ? array_filter($links, '\intval') : array();
 
         $options = array('links' => $links);
 
diff --git a/app/code/core/Mage/ImportExport/Model/Import/Entity/Customer/Address.php b/app/code/core/Mage/ImportExport/Model/Import/Entity/Customer/Address.php
index 1f3a1eff267..77a0ba95afd 100644
--- a/app/code/core/Mage/ImportExport/Model/Import/Entity/Customer/Address.php
+++ b/app/code/core/Mage/ImportExport/Model/Import/Entity/Customer/Address.php
@@ -299,9 +299,10 @@ protected function _initAttributes()
             ->addExcludeHiddenFrontendFilter();
 
         foreach ($addrCollection as $attribute) {
-            $this->_attributes[self::getColNameForAttrCode($attribute->getAttributeCode())] = array(
+            $attributeCode = $attribute->getAttributeCode();
+            $this->_attributes[self::getColNameForAttrCode($attributeCode)] = array(
                 'id'          => $attribute->getId(),
-                'code'        => $attribute->getAttributeCode(),
+                'code'        => $attributeCode,
                 'table'       => $attribute->getBackend()->getTable(),
                 'is_required' => $attribute->getIsRequired(),
                 'rules'       => $attribute->getValidateRules()
diff --git a/app/code/core/Mage/ImportExport/Model/Import/Entity/Product.php b/app/code/core/Mage/ImportExport/Model/Import/Entity/Product.php
index e513f406536..10ef205acca 100644
--- a/app/code/core/Mage/ImportExport/Model/Import/Entity/Product.php
+++ b/app/code/core/Mage/ImportExport/Model/Import/Entity/Product.php
@@ -1979,7 +1979,7 @@ protected function _saveStockItem()
      */
     protected function _filterRowData(&$rowData)
     {
-        $rowData = array_filter($rowData, 'strlen');
+        $rowData = array_filter($rowData, '\strlen');
         // Exceptions - for sku - put them back in
         if (!isset($rowData[self::COL_SKU])) {
             $rowData[self::COL_SKU] = null;
diff --git a/app/code/core/Mage/Sales/Model/Entity/Quote/Item/Collection.php b/app/code/core/Mage/Sales/Model/Entity/Quote/Item/Collection.php
index c5bae261fdb..51e3dfbfcdc 100644
--- a/app/code/core/Mage/Sales/Model/Entity/Quote/Item/Collection.php
+++ b/app/code/core/Mage/Sales/Model/Entity/Quote/Item/Collection.php
@@ -123,9 +123,10 @@ protected function _afterLoad()
      */
     protected function _getProductCollection()
     {
-        $productIds = array();
+        $productIds = [];
         foreach ($this as $item) {
-            $productIds[$item->getProductId()] = $item->getProductId();
+            $productId = $item->getProductId();
+            $productIds[$productId] = $productId;
             if ($item->getSuperProductId()) {
                 $productIds[$item->getSuperProductId()] = $item->getSuperProductId();
             }
diff --git a/app/code/core/Mage/Sales/Model/Quote.php b/app/code/core/Mage/Sales/Model/Quote.php
index b9b8bdd2c5c..8b655e4ccc2 100644
--- a/app/code/core/Mage/Sales/Model/Quote.php
+++ b/app/code/core/Mage/Sales/Model/Quote.php
@@ -1602,7 +1602,7 @@ public function getErrors()
         foreach ($this->getMessages() as $message) {
             /* @var Mage_Core_Model_Message_Abstract $error */
             if ($message->getType() == Mage_Core_Model_Message::ERROR) {
-                array_push($errors, $message);
+                $errors[] = $message;
             }
         }
         return $errors;
diff --git a/app/code/core/Mage/SalesRule/Model/Validator.php b/app/code/core/Mage/SalesRule/Model/Validator.php
index f8c6514c546..a75a6ed3956 100644
--- a/app/code/core/Mage/SalesRule/Model/Validator.php
+++ b/app/code/core/Mage/SalesRule/Model/Validator.php
@@ -54,14 +54,14 @@ class Mage_SalesRule_Model_Validator extends Mage_Core_Model_Abstract
      *
      * @var array
      */
-    protected $_roundingDeltas = array();
+    protected $_roundingDeltas = [];
 
     /**
      * Base rounding deltas
      *
      * @var array
      */
-    protected $_baseRoundingDeltas = array();
+    protected $_baseRoundingDeltas = [];
 
     /**
      * Quote address
@@ -91,14 +91,14 @@ class Mage_SalesRule_Model_Validator extends Mage_Core_Model_Abstract
      * Information about item totals for rules.
      * @var array
      */
-    protected $_rulesItemTotals = array();
+    protected $_rulesItemTotals = [];
 
     /**
      * Store information about addresses which cart fixed rule applied for
      *
      * @var array
      */
-    protected $_cartFixedRuleUsedForAddress = array();
+    protected $_cartFixedRuleUsedForAddress = [];
 
     /**
      * Defines if rule with stop further rules is already applied
@@ -320,7 +320,7 @@ public function process(Mage_Sales_Model_Quote_Item_Abstract $item)
             return $this;
         }
 
-        $appliedRuleIds = array();
+        $appliedRuleIds = [];
         $this->_stopFurtherRules = false;
         foreach ($this->_getRules() as $rule) {
             /* @var Mage_SalesRule_Model_Rule $rule */
@@ -455,18 +455,18 @@ public function process(Mage_Sales_Model_Quote_Item_Abstract $item)
                     break;
             }
 
-            $result = new Varien_Object(array(
+            $result = new Varien_Object([
                 'discount_amount'      => $discountAmount,
                 'base_discount_amount' => $baseDiscountAmount,
-            ));
-            Mage::dispatchEvent('salesrule_validator_process', array(
+            ]);
+            Mage::dispatchEvent('salesrule_validator_process', [
                 'rule'    => $rule,
                 'item'    => $item,
                 'address' => $address,
                 'quote'   => $quote,
                 'qty'     => $qty,
                 'result'  => $result,
-            ));
+            ]);
 
             $discountAmount = $result->getDiscountAmount();
             $baseDiscountAmount = $result->getBaseDiscountAmount();
@@ -511,7 +511,8 @@ public function process(Mage_Sales_Model_Quote_Item_Abstract $item)
             $item->setOriginalDiscountAmount($originalDiscountAmount);
             $item->setBaseOriginalDiscountAmount($baseOriginalDiscountAmount);
 
-            $appliedRuleIds[$rule->getRuleId()] = $rule->getRuleId();
+            $ruleId = $rule->getRuleId();
+            $appliedRuleIds[$ruleId] = $ruleId;
 
             $this->_maintainAddressCouponCode($address, $rule);
             $this->_addDiscountDescription($address, $rule);
@@ -759,7 +760,7 @@ public function processShippingAmount(Mage_Sales_Model_Quote_Address $address)
             $baseShippingAmount = $address->getBaseShippingAmount();
         }
         $quote              = $address->getQuote();
-        $appliedRuleIds = array();
+        $appliedRuleIds = [];
         foreach ($this->_getRules() as $rule) {
             /* @var Mage_SalesRule_Model_Rule $rule */
             if (!$rule->getApplyToShipping() || !$this->_canProcessRule($rule, $address)) {
@@ -818,7 +819,8 @@ public function processShippingAmount(Mage_Sales_Model_Quote_Address $address)
             );
             $address->setShippingDiscountAmount($discountAmount);
             $address->setBaseShippingDiscountAmount($baseDiscountAmount);
-            $appliedRuleIds[$rule->getRuleId()] = $rule->getRuleId();
+            $ruleId = $rule->getRuleId();
+            $appliedRuleIds[$ruleId] = $ruleId;
 
             $this->_maintainAddressCouponCode($address, $rule);
             $this->_addDiscountDescription($address, $rule);
@@ -844,10 +846,10 @@ public function processShippingAmount(Mage_Sales_Model_Quote_Address $address)
     public function mergeIds($a1, $a2, $asString = true)
     {
         if (!is_array($a1)) {
-            $a1 = empty($a1) ? array() : explode(',', $a1);
+            $a1 = empty($a1) ? [] : explode(',', $a1);
         }
         if (!is_array($a2)) {
-            $a2 = empty($a2) ? array() : explode(',', $a2);
+            $a2 = empty($a2) ? [] : explode(',', $a2);
         }
         $a = array_unique(array_merge($a1, $a2));
         if ($asString) {
@@ -891,7 +893,7 @@ public function getCartFixedRuleUsedForAddress($ruleId)
      */
     public function initTotals($items, Mage_Sales_Model_Quote_Address $address)
     {
-        $address->setCartFixedRules(array());
+        $address->setCartFixedRules([]);
 
         if (!$items) {
             return $this;
@@ -918,11 +920,11 @@ public function initTotals($items, Mage_Sales_Model_Quote_Address $address)
                     $validItemsCount++;
                 }
 
-                $this->_rulesItemTotals[$rule->getId()] = array(
+                $this->_rulesItemTotals[$rule->getId()] = [
                     'items_price' => $ruleTotalItemsPrice,
                     'base_items_price' => $ruleTotalBaseItemsPrice,
                     'items_count' => $validItemsCount,
-                );
+                ];
             }
         }
         $this->_stopFurtherRules = false;
@@ -1091,12 +1093,12 @@ protected function _getHelper($name)
      */
     public function sortItemsByPriority($items)
     {
-        $itemsSorted = array();
+        $itemsSorted = [];
         foreach ($this->_getRules() as $rule) {
             foreach ($items as $itemKey => $itemValue) {
                 if ($rule->getActions()->validate($itemValue)) {
                     unset($items[$itemKey]);
-                    array_push($itemsSorted, $itemValue);
+                    $itemsSorted[] = $itemValue;
                 }
             }
         }
diff --git a/app/code/core/Mage/Uploader/Helper/File.php b/app/code/core/Mage/Uploader/Helper/File.php
index 46853a782c9..f0d2ac4cbfc 100644
--- a/app/code/core/Mage/Uploader/Helper/File.php
+++ b/app/code/core/Mage/Uploader/Helper/File.php
@@ -733,7 +733,7 @@ public function getDataMaxSize()
     public function getDataMaxSizeInBytes()
     {
         $iniSize = $this->getDataMaxSize();
-        $size = substr($iniSize, 0, strlen($iniSize)-1);
+        $size = substr($iniSize, 0, -1);
         $parsedSize = 0;
         switch (strtolower(substr($iniSize, strlen($iniSize)-1))) {
             case 't':
diff --git a/app/code/core/Mage/Usa/Model/Shipping/Carrier/Dhl.php b/app/code/core/Mage/Usa/Model/Shipping/Carrier/Dhl.php
index ab43bb35712..d15d85259da 100644
--- a/app/code/core/Mage/Usa/Model/Shipping/Carrier/Dhl.php
+++ b/app/code/core/Mage/Usa/Model/Shipping/Carrier/Dhl.php
@@ -483,7 +483,7 @@ protected function _doRequest()
 
             foreach ($methods as $method) {
                 $shipment = false;
-                if (in_array($method, array_keys($this->getCode('special_express')))) {
+                if (array_key_exists($method, $this->getCode('special_express'))) {
                     $r->setService('E');
                     $r->setExtendedService($this->getCode('special_express', $method));
                 } else {
diff --git a/app/code/core/Mage/Usa/Model/Shipping/Carrier/Dhl/Label/Pdf.php b/app/code/core/Mage/Usa/Model/Shipping/Carrier/Dhl/Label/Pdf.php
index 44a1aaec46e..6181f6439eb 100644
--- a/app/code/core/Mage/Usa/Model/Shipping/Carrier/Dhl/Label/Pdf.php
+++ b/app/code/core/Mage/Usa/Model/Shipping/Carrier/Dhl/Label/Pdf.php
@@ -109,7 +109,7 @@ public function render()
                     (string)$piece->LicensePlate,
                     (string)$piece->LicensePlateBarCode
                 );
-            array_push($pdf->pages, $page);
+            $pdf->pages[] = $page;
             $i++;
         }
         return $pdf->render();
diff --git a/app/code/core/Mage/Widget/Model/Widget.php b/app/code/core/Mage/Widget/Model/Widget.php
index 7286027f258..6fe6e4967d2 100644
--- a/app/code/core/Mage/Widget/Model/Widget.php
+++ b/app/code/core/Mage/Widget/Model/Widget.php
@@ -52,7 +52,7 @@ public function getXmlConfig()
                 Mage::app()->saveCache(
                     $config->getXmlString(),
                     'widget_config',
-                    array(Mage_Core_Model_Config::CACHE_TAG)
+                    [Mage_Core_Model_Config::CACHE_TAG]
                 );
             }
         }
@@ -112,7 +112,7 @@ public function getConfigAsObject($type)
 
         // Correct widget parameters and convert its data to objects
         $params = $object->getData('parameters');
-        $newParams = array();
+        $newParams = [];
         if (is_array($params)) {
             $sortOrder = 0;
             foreach ($params as $key => $data) {
@@ -121,7 +121,7 @@ public function getConfigAsObject($type)
                     $data['sort_order'] = isset($data['sort_order']) ? (int)$data['sort_order'] : $sortOrder;
 
                     // prepare values (for drop-dawns) specified directly in configuration
-                    $values = array();
+                    $values = [];
                     if (isset($data['values']) && is_array($data['values'])) {
                         foreach ($data['values'] as $value) {
                             if (isset($value['label']) && isset($value['value'])) {
@@ -148,7 +148,7 @@ public function getConfigAsObject($type)
                 }
             }
         }
-        uasort($newParams, array($this, '_sortParameters'));
+        uasort($newParams, [$this, '_sortParameters']);
         $object->setData('parameters', $newParams);
 
         return $object;
@@ -160,7 +160,7 @@ public function getConfigAsObject($type)
      * @param array $filters Key-value array of filters for widget node properties
      * @return Varien_Simplexml_Element
      */
-    public function getWidgetsXml($filters = array())
+    public function getWidgetsXml($filters = [])
     {
         $widgets = $this->getXmlConfig()->getNode();
         $result = clone $widgets;
@@ -191,22 +191,23 @@ public function getWidgetsXml($filters = array())
      * @param array $filters Key-value array of filters for widget node properties
      * @return array
      */
-    public function getWidgetsArray($filters = array())
+    public function getWidgetsArray($filters = [])
     {
         if (!$this->_getData('widgets_array')) {
-            $result = array();
+            $result = [];
             /** @var Varien_Simplexml_Element $widget */
             foreach ($this->getWidgetsXml($filters) as $widget) {
                 $helper = $widget->getAttribute('module') ? $widget->getAttribute('module') : 'widget';
                 $helper = Mage::helper($helper);
-                $result[$widget->getName()] = array(
+                $widgetName = $widget->getName();
+                $result[$widgetName] = [
                     'name'          => $helper->__((string)$widget->name),
-                    'code'          => $widget->getName(),
+                    'code'          => $widgetName,
                     'type'          => $widget->getAttribute('type'),
                     'description'   => $helper->__((string)$widget->description)
-                );
+                ];
             }
-            usort($result, array($this, "_sortWidgets"));
+            usort($result, [$this, "_sortWidgets"]);
             $this->setData('widgets_array', $result);
         }
         return $this->_getData('widgets_array');
@@ -220,7 +221,7 @@ public function getWidgetsArray($filters = array())
      * @param bool $asIs Return result as widget directive(true) or as placeholder image(false)
      * @return string Widget directive ready to parse
      */
-    public function getWidgetDeclaration($type, $params = array(), $asIs = true)
+    public function getWidgetDeclaration($type, $params = [], $asIs = true)
     {
         $directive = '{{widget type="' . $type . '"';
 
@@ -268,7 +269,7 @@ public function getWidgetDeclaration($type, $params = array(), $asIs = true)
      */
     public function getWidgetsRequiredJsFiles()
     {
-        $result = array();
+        $result = [];
         foreach ($this->getWidgetsXml() as $widget) {
             if ($widget->js) {
                 foreach (explode(',', (string)$widget->js) as $js) {
diff --git a/app/code/core/Mage/Wishlist/Controller/Abstract.php b/app/code/core/Mage/Wishlist/Controller/Abstract.php
index 11a0c62a993..6cc3c9db0a3 100644
--- a/app/code/core/Mage/Wishlist/Controller/Abstract.php
+++ b/app/code/core/Mage/Wishlist/Controller/Abstract.php
@@ -98,7 +98,7 @@ public function allcartAction()
 
         $qtysString = $this->getRequest()->getParam('qty');
         if (isset($qtysString)) {
-            $qtys = array_filter(json_decode($qtysString), 'strlen');
+            $qtys = array_filter(json_decode($qtysString), '\strlen');
         }
 
         /** @var Mage_Wishlist_Model_Item $item */
From 64dd9b004b9dfc0193a603f215eeb7ce147c5907 Mon Sep 17 00:00:00 2001
From: Ng Kiat Siong 
Date: Fri, 5 Aug 2022 16:40:40 +0800
Subject: [PATCH 08/38] Enclosed error with  tag for prettier error print
 (if developer mode is enabled). (#2368)
---
 app/Mage.php | 2 ++
 1 file changed, 2 insertions(+)
diff --git a/app/Mage.php b/app/Mage.php
index fe8c92afea4..fb6b1b8b301 100644
--- a/app/Mage.php
+++ b/app/Mage.php
@@ -33,6 +33,8 @@
 if (!empty($_SERVER['MAGE_IS_DEVELOPER_MODE']) || !empty($_ENV['MAGE_IS_DEVELOPER_MODE'])) {
     Mage::setIsDeveloperMode(true);
     ini_set('display_errors', 1);
+    ini_set('error_prepend_string', '');
+    ini_set('error_append_string', '');
 }
 
 /**
From 4fb7615b74997a5f1b1af8e73d3a51237cbcec2c Mon Sep 17 00:00:00 2001
From: sv3n 
Date: Fri, 5 Aug 2022 10:43:21 +0200
Subject: [PATCH 09/38] Updated phpstan to 1.8.2 (#2367)
---
 .github/phpstan-baseline.neon | 19 ++-----------------
 composer.json                 | 11 ++++++-----
 composer.lock                 | 20 ++++++++++----------
 3 files changed, 18 insertions(+), 32 deletions(-)
diff --git a/.github/phpstan-baseline.neon b/.github/phpstan-baseline.neon
index 03b08972d45..7f28dc496a3 100644
--- a/.github/phpstan-baseline.neon
+++ b/.github/phpstan-baseline.neon
@@ -3312,7 +3312,7 @@ parameters:
 
 		-
 			message: "#^Binary operation \"\\*\" between string and 0\\.3 results in an error\\.$#"
-			count: 2
+			count: 1
 			path: ../app/code/core/Mage/Catalog/Model/Resource/Product/Indexer/Price.php
 
 		-
@@ -3477,7 +3477,7 @@ parameters:
 
 		-
 			message: "#^Binary operation \"\\*\" between string and 0\\.3 results in an error\\.$#"
-			count: 2
+			count: 1
 			path: ../app/code/core/Mage/CatalogInventory/Model/Resource/Indexer/Stock.php
 
 		-
@@ -3720,11 +3720,6 @@ parameters:
 			count: 1
 			path: ../app/code/core/Mage/Checkout/Block/Links.php
 
-		-
-			message: "#^PHPDoc tag @param has invalid value \\(\\$item\\)\\: Unexpected token \"\\$item\", expected type at offset 18$#"
-			count: 2
-			path: ../app/code/core/Mage/Checkout/Block/Multishipping/Addresses.php
-
 		-
 			message: "#^Call to an undefined method Mage_Core_Helper_Abstract\\:\\:displayCartBothPrices\\(\\)\\.$#"
 			count: 1
@@ -5580,16 +5575,6 @@ parameters:
 			count: 1
 			path: ../app/code/core/Mage/Payment/Helper/Data.php
 
-		-
-			message: "#^PHPDoc tag @param has invalid value \\(\\$a\\)\\: Unexpected token \"\\$a\", expected type at offset 18$#"
-			count: 1
-			path: ../app/code/core/Mage/Payment/Helper/Data.php
-
-		-
-			message: "#^PHPDoc tag @param has invalid value \\(\\$b\\)\\: Unexpected token \"\\$b\", expected type at offset 35$#"
-			count: 1
-			path: ../app/code/core/Mage/Payment/Helper/Data.php
-
 		-
 			message: "#^Comparison operation \"\\<\" between \\(array\\|float\\|int\\) and 0\\.0001 results in an error\\.$#"
 			count: 1
diff --git a/composer.json b/composer.json
index 799328c4f2e..26d11b9262d 100644
--- a/composer.json
+++ b/composer.json
@@ -9,21 +9,21 @@
   "require": {
     "php": ">=7.0 <7.5 || >=8.0 <8.1",
     "ext-curl": "*",
+    "ext-dom": "*",
     "ext-gd": "*",
+    "ext-iconv": "*",
     "ext-json": "*",
+    "ext-libxml": "*",
     "ext-mbstring": "*",
     "ext-pdo": "*",
     "ext-simplexml": "*",
-    "ext-dom": "*",
-    "ext-libxml": "*",
     "ext-soap": "*",
-    "ext-iconv": "*",
     "ext-zlib": "*",
     "magento-hackathon/magento-composer-installer": "^3.1 || ^2.1 || ^4.0"
   },
   "require-dev": {
     "macopedia/phpstan-magento1": "^1.0.4",
-    "phpstan/phpstan": "^1.7.1"
+    "phpstan/phpstan": "^1.8"
   },
   "authors": [
     {
@@ -63,6 +63,7 @@
   "config": {
     "allow-plugins": {
       "magento-hackathon/magento-composer-installer": true
-    }
+    },
+    "sort-packages": true
   }
 }
diff --git a/composer.lock b/composer.lock
index 9c018cf41e1..bd88c14120e 100644
--- a/composer.lock
+++ b/composer.lock
@@ -4,7 +4,7 @@
         "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
         "This file is @generated automatically"
     ],
-    "content-hash": "2299d18979b1136a95773f7421ba16d4",
+    "content-hash": "41b19faf78fd7832d437d8c94c9cb252",
     "packages": [
         {
             "name": "eloquent/enumeration",
@@ -1204,16 +1204,16 @@
         },
         {
             "name": "phpstan/phpstan",
-            "version": "1.7.1",
+            "version": "1.8.2",
             "source": {
                 "type": "git",
                 "url": "https://github.com/phpstan/phpstan.git",
-                "reference": "e3baed2ee2ef322e0f9b8fe8f87fdbe024c7c719"
+                "reference": "c53312ecc575caf07b0e90dee43883fdf90ca67c"
             },
             "dist": {
                 "type": "zip",
-                "url": "https://api.github.com/repos/phpstan/phpstan/zipball/e3baed2ee2ef322e0f9b8fe8f87fdbe024c7c719",
-                "reference": "e3baed2ee2ef322e0f9b8fe8f87fdbe024c7c719",
+                "url": "https://api.github.com/repos/phpstan/phpstan/zipball/c53312ecc575caf07b0e90dee43883fdf90ca67c",
+                "reference": "c53312ecc575caf07b0e90dee43883fdf90ca67c",
                 "shasum": ""
             },
             "require": {
@@ -1239,7 +1239,7 @@
             "description": "PHPStan - PHP Static Analysis Tool",
             "support": {
                 "issues": "https://github.com/phpstan/phpstan/issues",
-                "source": "https://github.com/phpstan/phpstan/tree/1.7.1"
+                "source": "https://github.com/phpstan/phpstan/tree/1.8.2"
             },
             "funding": [
                 {
@@ -1259,7 +1259,7 @@
                     "type": "tidelift"
                 }
             ],
-            "time": "2022-05-24T09:05:09+00:00"
+            "time": "2022-07-20T09:57:31+00:00"
         }
     ],
     "aliases": [],
@@ -1270,15 +1270,15 @@
     "platform": {
         "php": ">=7.0 <7.5 || >=8.0 <8.1",
         "ext-curl": "*",
+        "ext-dom": "*",
         "ext-gd": "*",
+        "ext-iconv": "*",
         "ext-json": "*",
+        "ext-libxml": "*",
         "ext-mbstring": "*",
         "ext-pdo": "*",
         "ext-simplexml": "*",
-        "ext-dom": "*",
-        "ext-libxml": "*",
         "ext-soap": "*",
-        "ext-iconv": "*",
         "ext-zlib": "*"
     },
     "platform-dev": [],
From ef45711bb541c304b75daf16bc9f707260f60fb5 Mon Sep 17 00:00:00 2001
From: Scott Moore 
Date: Fri, 5 Aug 2022 05:20:41 -0400
Subject: [PATCH 10/38] Escape product titles in MSRP JavaScript (#2366)
* Product names were not escaped. If contained a double quote, would break the JavaScript for MSRP/MAP
* update contribution list
---
 .all-contributorsrc                                      | 9 +++++++++
 README.md                                                | 1 +
 .../template/catalog/product/price_msrp_item.phtml       | 2 +-
 3 files changed, 11 insertions(+), 1 deletion(-)
diff --git a/.all-contributorsrc b/.all-contributorsrc
index 4e583980e23..eabd644b004 100644
--- a/.all-contributorsrc
+++ b/.all-contributorsrc
@@ -1342,6 +1342,15 @@
       "contributions": [
         "code"
       ]
+    },
+    {
+      "login": "discountscott",
+      "name": "Scott Moore",
+      "avatar_url": "https://avatars.githubusercontent.com/u/5454596?v=4",
+      "profile": "https://github.com/discountscott",
+      "contributions": [
+        "code"
+      ]
     }
   ],
   "contributorsPerLine": 7
diff --git a/README.md b/README.md
index 6e9b434a477..fb6aac2551d 100644
--- a/README.md
+++ b/README.md
@@ -392,6 +392,7 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
   
   
       Enéias Ramos de Melo | 
+      Scott Moore | 
   
 
 
diff --git a/app/design/frontend/base/default/template/catalog/product/price_msrp_item.phtml b/app/design/frontend/base/default/template/catalog/product/price_msrp_item.phtml
index 585d107cb28..684e7fe016f 100644
--- a/app/design/frontend/base/default/template/catalog/product/price_msrp_item.phtml
+++ b/app/design/frontend/base/default/template/catalog/product/price_msrp_item.phtml
@@ -84,7 +84,7 @@
 
                 Catalog.Map.addHelpLink(
                     $(''),
-                    "getName() ?>",
+                    "escapeHtml($_product->getName()) ?>",
                     $(""),
                     '',
                     "isSalable() ? $this->getAddToCartUrlCustom($_product, array(), false) : '' ?>"
From ceb122e982f737ba8f6afb72d0eda4ce2c3727f7 Mon Sep 17 00:00:00 2001
From: ADDISON <8360474+ADDISON74@users.noreply.github.com>
Date: Sat, 6 Aug 2022 00:13:03 +0300
Subject: [PATCH 11/38] Update boxes.css (#2330)
---
 skin/adminhtml/default/default/boxes.css | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/skin/adminhtml/default/default/boxes.css b/skin/adminhtml/default/default/boxes.css
index 601d2b74c86..f406ef42a50 100644
--- a/skin/adminhtml/default/default/boxes.css
+++ b/skin/adminhtml/default/default/boxes.css
@@ -205,10 +205,10 @@ table.actions td                { vertical-align:top; }
 .grid tr.filter select           { width:100%; }
 .grid tr.filter .range .range-line { margin-bottom:3px; width:100px; }
 .grid tr.filter .range div.date  { min-width:121px; }
-.grid tr.filter .range input     { float:right; width:50px !important; margin-top:0; }
-.grid tr.filter .range select    { float:right; width:56px !important; margin-top:0; }
-.grid tr.filter .range .label    { display:block; width:36px; float:left; padding-left:2px; }
-.grid tr.filter .date img        { width:15px; height:15px; cursor:pointer; vertical-align:middle; }
+.grid tr.filter .range input     { width:60px !important; margin-top:0; }
+.grid tr.filter .range select    { float:right; width:65px !important; margin-top:0; }
+.grid tr.filter .range .label    { display:block; width:30px; float:left; padding-right:3px; text-align:right; }
+.grid tr.filter .date img        { width:15px; height:15px; cursor:pointer; vertical-align:middle; padding-left:3px; }
 .grid .head-massaction select    { width:auto !important; max-width:90px; }
 .grid select.select-export-filter,
 .grid select.multiselect-export-filter { width:278px; }
From cb0af47c893d9b89456a82e13fa00acaebaa5413 Mon Sep 17 00:00:00 2001
From: Fabrizio Balliano 
Date: Sat, 6 Aug 2022 16:50:30 +0100
Subject: [PATCH 12/38] Force describeTable() to use read DB adapter (#2371)
---
 app/code/core/Mage/Catalog/Model/Resource/Category/Flat.php | 4 ++--
 app/code/core/Mage/Catalog/Model/Resource/Product/Flat.php  | 6 +++---
 app/code/core/Mage/Core/Model/Resource/Abstract.php         | 2 +-
 app/code/core/Mage/Core/Model/Resource/Db/Abstract.php      | 2 +-
 app/code/core/Mage/Eav/Model/Entity/Abstract.php            | 2 +-
 app/code/core/Mage/Index/Model/Resource/Abstract.php        | 6 +++---
 6 files changed, 11 insertions(+), 11 deletions(-)
diff --git a/app/code/core/Mage/Catalog/Model/Resource/Category/Flat.php b/app/code/core/Mage/Catalog/Model/Resource/Category/Flat.php
index a62f8ccfe62..e4492ee89d4 100644
--- a/app/code/core/Mage/Catalog/Model/Resource/Category/Flat.php
+++ b/app/code/core/Mage/Catalog/Model/Resource/Category/Flat.php
@@ -665,7 +665,7 @@ protected function _getStaticColumns()
         $helper = Mage::getResourceHelper('catalog');
         $columns = array();
         $columnsToSkip = array('entity_type_id', 'attribute_set_id');
-        $describe = $this->_getWriteAdapter()->describeTable($this->getTable('catalog/category'));
+        $describe = $this->_getReadAdapter()->describeTable($this->getTable('catalog/category'));
 
         foreach ($describe as $column) {
             if (in_array($column['COLUMN_NAME'], $columnsToSkip)) {
@@ -1161,7 +1161,7 @@ protected function _prepareDataForAllFields($category, $replaceFields = array())
     {
         $table = $this->getMainStoreTable($category->getStoreId());
         $this->_getWriteAdapter()->resetDdlCache($table);
-        $table = $this->_getWriteAdapter()->describeTable($table);
+        $table = $this->_getReadAdapter()->describeTable($table);
         $data = array();
         $idFieldName = Mage::getSingleton('catalog/category')->getIdFieldName();
         foreach ($table as $column => $columnData) {
diff --git a/app/code/core/Mage/Catalog/Model/Resource/Product/Flat.php b/app/code/core/Mage/Catalog/Model/Resource/Product/Flat.php
index 66aa3baabca..419a7deb90e 100644
--- a/app/code/core/Mage/Catalog/Model/Resource/Product/Flat.php
+++ b/app/code/core/Mage/Catalog/Model/Resource/Product/Flat.php
@@ -118,7 +118,7 @@ public function getTypeId()
      */
     public function getAttributeForSelect($attributeCode)
     {
-        $describe = $this->_getWriteAdapter()->describeTable($this->getFlatTableName());
+        $describe = $this->_getReadAdapter()->describeTable($this->getFlatTableName());
         if (!isset($describe[$attributeCode])) {
             return null;
         }
@@ -140,7 +140,7 @@ public function getAttributeForSelect($attributeCode)
      */
     public function getAttributeSortColumn($attributeCode)
     {
-        $describe = $this->_getWriteAdapter()->describeTable($this->getFlatTableName());
+        $describe = $this->_getReadAdapter()->describeTable($this->getFlatTableName());
         if (!isset($describe[$attributeCode])) {
             return null;
         }
@@ -158,7 +158,7 @@ public function getAttributeSortColumn($attributeCode)
      */
     public function getAllTableColumns()
     {
-        $describe = $this->_getWriteAdapter()->describeTable($this->getFlatTableName());
+        $describe = $this->_getReadAdapter()->describeTable($this->getFlatTableName());
         return array_keys($describe);
     }
 
diff --git a/app/code/core/Mage/Core/Model/Resource/Abstract.php b/app/code/core/Mage/Core/Model/Resource/Abstract.php
index 5dddab013bb..8c8b21fc543 100644
--- a/app/code/core/Mage/Core/Model/Resource/Abstract.php
+++ b/app/code/core/Mage/Core/Model/Resource/Abstract.php
@@ -211,7 +211,7 @@ protected function _unserializeField(Varien_Object $object, $field, $defaultValu
     protected function _prepareDataForTable(Varien_Object $object, $table)
     {
         $data = array();
-        $fields = $this->_getWriteAdapter()->describeTable($table);
+        $fields = $this->_getReadAdapter()->describeTable($table);
         foreach (array_keys($fields) as $field) {
             if ($object->hasData($field)) {
                 $fieldValue = $object->getData($field);
diff --git a/app/code/core/Mage/Core/Model/Resource/Db/Abstract.php b/app/code/core/Mage/Core/Model/Resource/Db/Abstract.php
index dff7a4ceb8c..e2843bb2611 100644
--- a/app/code/core/Mage/Core/Model/Resource/Db/Abstract.php
+++ b/app/code/core/Mage/Core/Model/Resource/Db/Abstract.php
@@ -618,7 +618,7 @@ public function hasDataChanged($object)
             return true;
         }
 
-        $fields = $this->_getWriteAdapter()->describeTable($this->getMainTable());
+        $fields = $this->_getReadAdapter()->describeTable($this->getMainTable());
         foreach (array_keys($fields) as $field) {
             if ($object->getOrigData($field) != $object->getData($field)) {
                 return true;
diff --git a/app/code/core/Mage/Eav/Model/Entity/Abstract.php b/app/code/core/Mage/Eav/Model/Entity/Abstract.php
index 2453f3d6b40..9988c3db5ac 100644
--- a/app/code/core/Mage/Eav/Model/Entity/Abstract.php
+++ b/app/code/core/Mage/Eav/Model/Entity/Abstract.php
@@ -1167,7 +1167,7 @@ protected function _collectSaveData($newObject)
             $origData = array();
         }
 
-        $staticFields   = $this->_getWriteAdapter()->describeTable($this->getEntityTable());
+        $staticFields   = $this->_getReadAdapter()->describeTable($this->getEntityTable());
         $staticFields   = array_keys($staticFields);
         $attributeCodes = array_keys($this->_attributesByCode);
 
diff --git a/app/code/core/Mage/Index/Model/Resource/Abstract.php b/app/code/core/Mage/Index/Model/Resource/Abstract.php
index 54cc1657e49..759c508226a 100644
--- a/app/code/core/Mage/Index/Model/Resource/Abstract.php
+++ b/app/code/core/Mage/Index/Model/Resource/Abstract.php
@@ -142,11 +142,11 @@ public function cloneIndexTable($asOriginal = false)
     public function insertFromTable($sourceTable, $destTable, $readToIndex = true)
     {
         if ($readToIndex) {
-            $sourceColumns = array_keys($this->_getWriteAdapter()->describeTable($sourceTable));
-            $targetColumns = array_keys($this->_getWriteAdapter()->describeTable($destTable));
+            $sourceColumns = array_keys($this->_getReadAdapter()->describeTable($sourceTable));
+            $targetColumns = array_keys($this->_getReadAdapter()->describeTable($destTable));
         } else {
             $sourceColumns = array_keys($this->_getIndexAdapter()->describeTable($sourceTable));
-            $targetColumns = array_keys($this->_getWriteAdapter()->describeTable($destTable));
+            $targetColumns = array_keys($this->_getReadAdapter()->describeTable($destTable));
         }
         $select = $this->_getIndexAdapter()->select()->from($sourceTable, $sourceColumns);
 
From f46bedb89d6d1ef8598fe550217943a0c1d161fe Mon Sep 17 00:00:00 2001
From: sv3n 
Date: Sat, 6 Aug 2022 21:36:17 +0200
Subject: [PATCH 13/38] Do not install n98/n98_layouthelper (#2373)
---
 composer.json | 3 +++
 composer.lock | 2 +-
 2 files changed, 4 insertions(+), 1 deletion(-)
diff --git a/composer.json b/composer.json
index 26d11b9262d..415c65276d0 100644
--- a/composer.json
+++ b/composer.json
@@ -25,6 +25,9 @@
     "macopedia/phpstan-magento1": "^1.0.4",
     "phpstan/phpstan": "^1.8"
   },
+  "conflict": {
+    "n98/n98_layouthelper": "*"
+  },
   "authors": [
     {
       "name": "Lee Saferite",
diff --git a/composer.lock b/composer.lock
index bd88c14120e..67fca161c56 100644
--- a/composer.lock
+++ b/composer.lock
@@ -4,7 +4,7 @@
         "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
         "This file is @generated automatically"
     ],
-    "content-hash": "41b19faf78fd7832d437d8c94c9cb252",
+    "content-hash": "ab93d8594c177fde90bd1611fb18162c",
     "packages": [
         {
             "name": "eloquent/enumeration",
From 83a3e9f4ec290d15b3503ed46b6289c7a6c73aef Mon Sep 17 00:00:00 2001
From: Fabrizio Balliano 
Date: Sun, 7 Aug 2022 09:07:12 +0100
Subject: [PATCH 14/38] Add apt update to XML validation workflow (#2376)
---
 .github/workflows/xml_validate.yml | 2 ++
 1 file changed, 2 insertions(+)
diff --git a/.github/workflows/xml_validate.yml b/.github/workflows/xml_validate.yml
index 531bbfcd63d..d653827dc28 100644
--- a/.github/workflows/xml_validate.yml
+++ b/.github/workflows/xml_validate.yml
@@ -11,6 +11,8 @@ jobs:
     steps:
     - name: "Checkout repository"
       uses: actions/checkout@master
+    - name: "Update APT repositories"
+      run: "sudo apt update"
     - name: "Install xmllint"
       run: "sudo apt-get -y install libxml2-utils"
     - name: "Validate XMLs"
From 23d180d0a438516f078a076f404f65b169e32f07 Mon Sep 17 00:00:00 2001
From: Ng Kiat Siong 
Date: Mon, 8 Aug 2022 07:20:32 +0800
Subject: [PATCH 15/38] Merged PR #2375
---
 .github/phpstan-baseline.neon                     | 15 ---------------
 .../Block/Customer/Edit/Renderer/Region.php       |  6 ++----
 .../Block/Adminhtml/Frontend/Region/Updater.php   |  2 +-
 .../Block/Adminhtml/Frontend/Region/Updater.php   |  2 +-
 .../default/default/template/tax/rate/form.phtml  |  2 +-
 .../default/template/weee/renderer/tax.phtml      |  2 +-
 .../default/template/checkout/cart/shipping.phtml |  2 +-
 .../template/checkout/onepage/billing.phtml       |  2 +-
 .../template/checkout/onepage/shipping.phtml      |  2 +-
 .../default/template/customer/address/edit.phtml  |  2 +-
 .../default/template/customer/form/address.phtml  |  2 +-
 .../default/template/customer/form/register.phtml |  2 +-
 .../persistent/checkout/onepage/billing.phtml     |  2 +-
 .../persistent/customer/form/register.phtml       |  2 +-
 .../default/template/checkout/cart/shipping.phtml |  2 +-
 .../template/checkout/onepage/shipping.phtml      |  2 +-
 .../default/template/customer/address/edit.phtml  |  2 +-
 .../default/template/customer/form/address.phtml  |  2 +-
 .../template/paypal/express/review/address.phtml  |  2 +-
 .../persistent/checkout/onepage/billing.phtml     |  2 +-
 .../persistent/customer/form/register.phtml       |  2 +-
 21 files changed, 21 insertions(+), 38 deletions(-)
diff --git a/.github/phpstan-baseline.neon b/.github/phpstan-baseline.neon
index 7f28dc496a3..b501ed8ad74 100644
--- a/.github/phpstan-baseline.neon
+++ b/.github/phpstan-baseline.neon
@@ -290,11 +290,6 @@ parameters:
 			count: 1
 			path: ../app/code/core/Mage/Adminhtml/Block/Cms/Page/Grid.php
 
-		-
-			message: "#^Call to an undefined method Mage_Core_Helper_Abstract\\:\\:getRegionJsonByStore\\(\\)\\.$#"
-			count: 1
-			path: ../app/code/core/Mage/Adminhtml/Block/Customer/Edit/Renderer/Region.php
-
 		-
 			message: "#^Call to an undefined method Mage_Core_Helper_Abstract\\:\\:getNamePrefixOptions\\(\\)\\.$#"
 			count: 1
@@ -4500,11 +4495,6 @@ parameters:
 			count: 2
 			path: ../app/code/core/Mage/Dataflow/Model/Profile.php
 
-		-
-			message: "#^Call to an undefined method Mage_Core_Helper_Abstract\\:\\:getRegionJson\\(\\)\\.$#"
-			count: 1
-			path: ../app/code/core/Mage/Directory/Block/Adminhtml/Frontend/Region/Updater.php
-
 		-
 			message: "#^Cannot call method addCountryFilter\\(\\) on Mage_Core_Model_Resource_Db_Collection_Abstract\\|false\\.$#"
 			count: 2
@@ -7330,11 +7320,6 @@ parameters:
 			count: 1
 			path: ../app/code/core/Mage/Tag/Model/Tag/Relation.php
 
-		-
-			message: "#^Call to an undefined method Mage_Core_Helper_Abstract\\:\\:getRegionJson\\(\\)\\.$#"
-			count: 1
-			path: ../app/code/core/Mage/Tax/Block/Adminhtml/Frontend/Region/Updater.php
-
 		-
 			message: "#^Call to an undefined method Mage_Core_Helper_Abstract\\:\\:validateCatalogPricesAndFptConfiguration\\(\\)\\.$#"
 			count: 2
diff --git a/app/code/core/Mage/Adminhtml/Block/Customer/Edit/Renderer/Region.php b/app/code/core/Mage/Adminhtml/Block/Customer/Edit/Renderer/Region.php
index 7815934a028..b0d077dca41 100644
--- a/app/code/core/Mage/Adminhtml/Block/Customer/Edit/Renderer/Region.php
+++ b/app/code/core/Mage/Adminhtml/Block/Customer/Edit/Renderer/Region.php
@@ -59,9 +59,7 @@ public function __construct(array $args = array())
     public function render(Varien_Data_Form_Element_Abstract $element)
     {
         $country = $element->getForm()->getElement('country_id');
-        if (!is_null($country)) {
-            $countryId = $country->getValue();
-        } else {
+        if (is_null($country)) {
             return $element->getDefaultHtml();
         }
 
@@ -84,7 +82,7 @@ public function render(Varien_Data_Form_Element_Abstract $element)
         $html .= '' . "\n";
 
         $html .= '' . "\n";
diff --git a/app/code/core/Mage/Directory/Block/Adminhtml/Frontend/Region/Updater.php b/app/code/core/Mage/Directory/Block/Adminhtml/Frontend/Region/Updater.php
index 256dfc1d2c7..84f5095f8f6 100644
--- a/app/code/core/Mage/Directory/Block/Adminhtml/Frontend/Region/Updater.php
+++ b/app/code/core/Mage/Directory/Block/Adminhtml/Frontend/Region/Updater.php
@@ -33,7 +33,7 @@ class Mage_Directory_Block_Adminhtml_Frontend_Region_Updater extends Mage_Adminh
     protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
     {
         $html = parent::_getElementHtml($element);
-        $html .= "";
+        $html .= "";
 
         return $html;
     }
diff --git a/app/code/core/Mage/Tax/Block/Adminhtml/Frontend/Region/Updater.php b/app/code/core/Mage/Tax/Block/Adminhtml/Frontend/Region/Updater.php
index 476ea5ff4f6..daecf0aa0a8 100644
--- a/app/code/core/Mage/Tax/Block/Adminhtml/Frontend/Region/Updater.php
+++ b/app/code/core/Mage/Tax/Block/Adminhtml/Frontend/Region/Updater.php
@@ -48,7 +48,7 @@ protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
                }
                ';
 
-        $html .= sprintf($js, $this->helper('directory')->getRegionJson());
+        $html .= sprintf($js, Mage::helper('directory')->getRegionJsonByStore());
         return $html;
     }
 }
diff --git a/app/design/adminhtml/default/default/template/tax/rate/form.phtml b/app/design/adminhtml/default/default/template/tax/rate/form.phtml
index df460fda9f5..8d4b864d869 100644
--- a/app/design/adminhtml/default/default/template/tax/rate/form.phtml
+++ b/app/design/adminhtml/default/default/template/tax/rate/form.phtml
@@ -29,5 +29,5 @@
  
 getChildHtml('form_after');?>
 
diff --git a/app/design/adminhtml/default/default/template/weee/renderer/tax.phtml b/app/design/adminhtml/default/default/template/weee/renderer/tax.phtml
index 8e6e08c5ce6..c931b805b68 100644
--- a/app/design/adminhtml/default/default/template/weee/renderer/tax.phtml
+++ b/app/design/adminhtml/default/default/template/weee/renderer/tax.phtml
@@ -114,7 +114,7 @@
             $(data.prefix + '_weee_tax_row_'+data.index+'_country').value = data.country;
             $(data.prefix + '_weee_tax_row_'+data.index+'_website').value = data.website_id;
 
-            updater = new RegionUpdater(data.prefix + '_weee_tax_row_'+data.index+'_country', null, data.prefix + '_weee_tax_row_'+data.index+'_state', helper('directory')->getRegionJson() ?>, 'disable', true);
+            updater = new RegionUpdater(data.prefix + '_weee_tax_row_'+data.index+'_country', null, data.prefix + '_weee_tax_row_'+data.index+'_state', getRegionJsonByStore() ?>, 'disable', true);
             updater.update();
 
             $(data.prefix + '_weee_tax_row_'+data.index+'_state').value   = data.state;
diff --git a/app/design/frontend/base/default/template/checkout/cart/shipping.phtml b/app/design/frontend/base/default/template/checkout/cart/shipping.phtml
index c707d83eeb5..a66a50ffcaf 100644
--- a/app/design/frontend/base/default/template/checkout/cart/shipping.phtml
+++ b/app/design/frontend/base/default/template/checkout/cart/shipping.phtml
@@ -74,7 +74,7 @@
         
         
 
diff --git a/app/design/frontend/base/default/template/checkout/onepage/billing.phtml b/app/design/frontend/base/default/template/checkout/onepage/billing.phtml
index 08f47375339..edc05490dfd 100644
--- a/app/design/frontend/base/default/template/checkout/onepage/billing.phtml
+++ b/app/design/frontend/base/default/template/checkout/onepage/billing.phtml
@@ -220,6 +220,6 @@
     //billingForm.setElementsRelation('billing:country_id', 'billing:region', 'getUrl('directory/json/childRegion') ?>', '__('Select State/Province...') ?>');
     $('billing-address-select') && billing.newAddress(!$('billing-address-select').value);
 
-    var billingRegionUpdater = new RegionUpdater('billing:country_id', 'billing:region', 'billing:region_id', helper('directory')->getRegionJson() ?>, undefined, 'billing:postcode');
+    var billingRegionUpdater = new RegionUpdater('billing:country_id', 'billing:region', 'billing:region_id', getRegionJsonByStore() ?>, undefined, 'billing:postcode');
 //]]>
 
diff --git a/app/design/frontend/base/default/template/checkout/onepage/shipping.phtml b/app/design/frontend/base/default/template/checkout/onepage/shipping.phtml
index be42d10cd75..44106214be4 100644
--- a/app/design/frontend/base/default/template/checkout/onepage/shipping.phtml
+++ b/app/design/frontend/base/default/template/checkout/onepage/shipping.phtml
@@ -152,6 +152,6 @@
     //shippingForm.setElementsRelation('shipping:country_id', 'shipping:region', 'getUrl('directory/json/childRegion') ?>', 'jsQuoteEscape($this->__('Select State/Province...')) ?>');
     $('shipping-address-select') && shipping.newAddress(!$('shipping-address-select').value);
 
-    var shippingRegionUpdater = new RegionUpdater('shipping:country_id', 'shipping:region', 'shipping:region_id', helper('directory')->getRegionJson() ?>, undefined, 'shipping:postcode');
+    var shippingRegionUpdater = new RegionUpdater('shipping:country_id', 'shipping:region', 'shipping:region_id', getRegionJsonByStore() ?>, undefined, 'shipping:postcode');
 //]]>
 
diff --git a/app/design/frontend/base/default/template/customer/address/edit.phtml b/app/design/frontend/base/default/template/customer/address/edit.phtml
index 9f9acd4051a..4716c94f389 100644
--- a/app/design/frontend/base/default/template/customer/address/edit.phtml
+++ b/app/design/frontend/base/default/template/customer/address/edit.phtml
@@ -160,6 +160,6 @@
 
diff --git a/app/design/frontend/base/default/template/customer/form/address.phtml b/app/design/frontend/base/default/template/customer/form/address.phtml
index b95e7861764..835e682d275 100644
--- a/app/design/frontend/base/default/template/customer/form/address.phtml
+++ b/app/design/frontend/base/default/template/customer/form/address.phtml
@@ -24,7 +24,7 @@
  * @license     http://opensource.org/licenses/afl-3.0.php  Academic Free License (AFL 3.0)
  */
 ?>
-
+
 
 
     getAddressId()): ?>__('Edit Address Entry') ?>__('New Address Entry') ?>
diff --git a/app/design/frontend/base/default/template/customer/form/register.phtml b/app/design/frontend/base/default/template/customer/form/register.phtml
index d25b217ca61..cd3b8af6ba0 100644
--- a/app/design/frontend/base/default/template/customer/form/register.phtml
+++ b/app/design/frontend/base/default/template/customer/form/register.phtml
@@ -192,7 +192,7 @@
     //getShowAddressFields()): ?>
-        new RegionUpdater('country', 'region', 'region_id', helper('directory')->getRegionJson() ?>, undefined, 'zip');
+        new RegionUpdater('country', 'region', 'region_id', getRegionJsonByStore() ?>, undefined, 'zip');
         
     //]]>
     
diff --git a/app/design/frontend/base/default/template/persistent/checkout/onepage/billing.phtml b/app/design/frontend/base/default/template/persistent/checkout/onepage/billing.phtml
index c90d696e92d..075cc35ee05 100644
--- a/app/design/frontend/base/default/template/persistent/checkout/onepage/billing.phtml
+++ b/app/design/frontend/base/default/template/persistent/checkout/onepage/billing.phtml
@@ -218,7 +218,7 @@
     //billingForm.setElementsRelation('billing:country_id', 'billing:region', 'getUrl('directory/json/childRegion') ?>', 'jsQuoteEscape($this->__('Select State/Province...')) ?>');
     $('billing-address-select') && billing.newAddress(!$('billing-address-select').value);
 
-    var billingRegionUpdater = new RegionUpdater('billing:country_id', 'billing:region', 'billing:region_id', helper('directory')->getRegionJson() ?>, undefined, 'billing:postcode');
+    var billingRegionUpdater = new RegionUpdater('billing:country_id', 'billing:region', 'billing:region_id', getRegionJsonByStore() ?>, undefined, 'billing:postcode');
     if ($('onepage-guest-register-button')) {
         Event.observe($('onepage-guest-register-button'), 'click', function(event) {
             var billingRememberMe = $('co-billing-form').select('#remember-me-box');
diff --git a/app/design/frontend/base/default/template/persistent/customer/form/register.phtml b/app/design/frontend/base/default/template/persistent/customer/form/register.phtml
index 91f9edf71e6..6fddd97d6f9 100644
--- a/app/design/frontend/base/default/template/persistent/customer/form/register.phtml
+++ b/app/design/frontend/base/default/template/persistent/customer/form/register.phtml
@@ -194,7 +194,7 @@
     //getShowAddressFields()): ?>
-        new RegionUpdater('country', 'region', 'region_id', helper('directory')->getRegionJson() ?>, undefined, 'zip');
+        new RegionUpdater('country', 'region', 'region_id', getRegionJsonByStore() ?>, undefined, 'zip');
         
     //]]>
     
diff --git a/app/design/frontend/rwd/default/template/checkout/cart/shipping.phtml b/app/design/frontend/rwd/default/template/checkout/cart/shipping.phtml
index 0eb7a83f92f..d3a7df3757b 100644
--- a/app/design/frontend/rwd/default/template/checkout/cart/shipping.phtml
+++ b/app/design/frontend/rwd/default/template/checkout/cart/shipping.phtml
@@ -82,7 +82,7 @@
         
         
 
diff --git a/app/design/frontend/rwd/default/template/checkout/onepage/shipping.phtml b/app/design/frontend/rwd/default/template/checkout/onepage/shipping.phtml
index 11cdab6adc3..28b902f4266 100644
--- a/app/design/frontend/rwd/default/template/checkout/onepage/shipping.phtml
+++ b/app/design/frontend/rwd/default/template/checkout/onepage/shipping.phtml
@@ -153,6 +153,6 @@
     //shippingForm.setElementsRelation('shipping:country_id', 'shipping:region', 'getUrl('directory/json/childRegion') ?>', 'jsQuoteEscape($this->__('Select State/Province...')) ?>');
     $('shipping-address-select') && shipping.newAddress(!$('shipping-address-select').value);
 
-    var shippingRegionUpdater = new RegionUpdater('shipping:country_id', 'shipping:region', 'shipping:region_id', helper('directory')->getRegionJson() ?>, undefined, 'shipping:postcode');
+    var shippingRegionUpdater = new RegionUpdater('shipping:country_id', 'shipping:region', 'shipping:region_id', getRegionJsonByStore() ?>, undefined, 'shipping:postcode');
 //]]>
 
diff --git a/app/design/frontend/rwd/default/template/customer/address/edit.phtml b/app/design/frontend/rwd/default/template/customer/address/edit.phtml
index 7a3826d6ad4..f441828b11b 100644
--- a/app/design/frontend/rwd/default/template/customer/address/edit.phtml
+++ b/app/design/frontend/rwd/default/template/customer/address/edit.phtml
@@ -161,6 +161,6 @@
 
diff --git a/app/design/frontend/rwd/default/template/customer/form/address.phtml b/app/design/frontend/rwd/default/template/customer/form/address.phtml
index 6744be2f804..6440ea5ea5c 100644
--- a/app/design/frontend/rwd/default/template/customer/form/address.phtml
+++ b/app/design/frontend/rwd/default/template/customer/form/address.phtml
@@ -24,7 +24,7 @@
  * @license     http://opensource.org/licenses/afl-3.0.php  Academic Free License (AFL 3.0)
  */
 ?>
-
+
 
 
     
getAddressId()): ?>__('Edit Address Entry') ?>__('New Address Entry') ?>
diff --git a/app/design/frontend/rwd/default/template/paypal/express/review/address.phtml b/app/design/frontend/rwd/default/template/paypal/express/review/address.phtml
index 2be64ae566b..76cd3b90eb6 100644
--- a/app/design/frontend/rwd/default/template/paypal/express/review/address.phtml
+++ b/app/design/frontend/rwd/default/template/paypal/express/review/address.phtml
@@ -146,7 +146,7 @@
 
 
diff --git a/app/design/frontend/rwd/default/template/persistent/checkout/onepage/billing.phtml b/app/design/frontend/rwd/default/template/persistent/checkout/onepage/billing.phtml
index 2266732e4cc..cb2d2a79eee 100644
--- a/app/design/frontend/rwd/default/template/persistent/checkout/onepage/billing.phtml
+++ b/app/design/frontend/rwd/default/template/persistent/checkout/onepage/billing.phtml
@@ -220,7 +220,7 @@
     //billingForm.setElementsRelation('billing:country_id', 'billing:region', 'getUrl('directory/json/childRegion') ?>', 'jsQuoteEscape($this->__('Select State/Province...')) ?>');
     $('billing-address-select') && billing.newAddress(!$('billing-address-select').value);
 
-    var billingRegionUpdater = new RegionUpdater('billing:country_id', 'billing:region', 'billing:region_id', helper('directory')->getRegionJson() ?>, undefined, 'billing:postcode');
+    var billingRegionUpdater = new RegionUpdater('billing:country_id', 'billing:region', 'billing:region_id', getRegionJsonByStore() ?>, undefined, 'billing:postcode');
     if ($('onepage-guest-register-button')) {
         Event.observe($('onepage-guest-register-button'), 'click', function(event) {
             var billingRememberMe = $('co-billing-form').select('#remember-me-box');
diff --git a/app/design/frontend/rwd/default/template/persistent/customer/form/register.phtml b/app/design/frontend/rwd/default/template/persistent/customer/form/register.phtml
index 73a698057f3..3205eaa4825 100644
--- a/app/design/frontend/rwd/default/template/persistent/customer/form/register.phtml
+++ b/app/design/frontend/rwd/default/template/persistent/customer/form/register.phtml
@@ -190,7 +190,7 @@
     //getShowAddressFields()): ?>
-        new RegionUpdater('country', 'region', 'region_id', helper('directory')->getRegionJson() ?>, undefined, 'zip');
+        new RegionUpdater('country', 'region', 'region_id', getRegionJsonByStore() ?>, undefined, 'zip');
         
     //]]>
     
From 0e74e2e782975110ba41b36a26912a01a1670480 Mon Sep 17 00:00:00 2001
From: Kevin Jakob 
Date: Mon, 8 Aug 2022 01:22:13 +0200
Subject: [PATCH 16/38] Replace remaining "sizeof" calls with "count" (#2369)
---
 .../default/default/template/dashboard/grid.phtml        | 2 +-
 .../default/default/template/dashboard/salebar.phtml     | 2 +-
 .../default/default/template/dashboard/totalbar.phtml    | 2 +-
 .../adminhtml/default/default/template/report/grid.phtml | 2 +-
 .../default/default/template/sales/order/totalbar.phtml  | 2 +-
 .../default/template/system/currency/rate/matrix.phtml   | 6 ++++--
 .../adminhtml/default/default/template/widget/grid.phtml | 2 +-
 .../base/default/template/catalog/product/list.phtml     | 5 +++--
 .../base/default/template/catalogsearch/term.phtml       | 2 +-
 .../base/default/template/sales/order/recent.phtml       | 4 ++--
 .../base/default/template/shipping/tracking/popup.phtml  | 9 +++++----
 .../frontend/base/default/template/tag/cloud.phtml       | 2 +-
 .../base/default/template/tag/customer/recent.phtml      | 6 ++++--
 .../base/default/template/tag/customer/view.phtml        | 2 +-
 .../rwd/default/template/catalog/product/list.phtml      | 5 +++--
 .../default/template/email/catalog/product/list.phtml    | 5 +++--
 .../rwd/default/template/sales/order/recent.phtml        | 4 ++--
 lib/Net/IDNA2.php                                        | 4 ++--
 lib/Varien/Convert/Container/Collection.php              | 2 +-
 lib/Varien/Convert/Parser/Xml/Excel.php                  | 2 +-
 lib/Varien/Event/Observer/Cron.php                       | 6 +++---
 lib/Varien/Simplexml/Element.php                         | 2 +-
 22 files changed, 43 insertions(+), 35 deletions(-)
diff --git a/app/design/adminhtml/default/default/template/dashboard/grid.phtml b/app/design/adminhtml/default/default/template/dashboard/grid.phtml
index 027b2b964c6..d432d701fc6 100644
--- a/app/design/adminhtml/default/default/template/dashboard/grid.phtml
+++ b/app/design/adminhtml/default/default/template/dashboard/grid.phtml
@@ -26,7 +26,7 @@
 ?>
 getColumns());
+$numColumns = count($this->getColumns());
 ?>
 getCollection()): ?>
 
diff --git a/app/design/adminhtml/default/default/template/dashboard/salebar.phtml b/app/design/adminhtml/default/default/template/dashboard/salebar.phtml
index c72cc501757..fcb6cd338e1 100644
--- a/app/design/adminhtml/default/default/template/dashboard/salebar.phtml
+++ b/app/design/adminhtml/default/default/template/dashboard/salebar.phtml
@@ -24,7 +24,7 @@
  * @license     http://opensource.org/licenses/afl-3.0.php  Academic Free License (AFL 3.0)
  */
 ?>
-getTotals()) > 0 ): ?>
+getTotals()) > 0): ?>
             getTotals() as $_total ): ?>
             
                 
diff --git a/app/design/adminhtml/default/default/template/dashboard/totalbar.phtml b/app/design/adminhtml/default/default/template/dashboard/totalbar.phtml
index c384687a2b8..b0510371af3 100644
--- a/app/design/adminhtml/default/default/template/dashboard/totalbar.phtml
+++ b/app/design/adminhtml/default/default/template/dashboard/totalbar.phtml
@@ -24,7 +24,7 @@
  * @license     http://opensource.org/licenses/afl-3.0.php  Academic Free License (AFL 3.0)
  */
 ?>
-getTotals()) > 0 ): ?>
+getTotals()) > 0): ?>
 
     
         
diff --git a/app/design/adminhtml/default/default/template/report/grid.phtml b/app/design/adminhtml/default/default/template/report/grid.phtml
index c1eaf1de5a7..5a3d9e79f0b 100644
--- a/app/design/adminhtml/default/default/template/report/grid.phtml
+++ b/app/design/adminhtml/default/default/template/report/grid.phtml
@@ -34,7 +34,7 @@
  *  getPagerVisibility()
  *  getVarNamePage()
  */
-$numColumns = sizeof($this->getColumns());
+$numColumns = count($this->getColumns());
 ?>
 getCollection()): ?>
     canDisplayContainer()): ?>
diff --git a/app/design/adminhtml/default/default/template/sales/order/totalbar.phtml b/app/design/adminhtml/default/default/template/sales/order/totalbar.phtml
index 7007c5591bb..478d5d26a52 100644
--- a/app/design/adminhtml/default/default/template/sales/order/totalbar.phtml
+++ b/app/design/adminhtml/default/default/template/sales/order/totalbar.phtml
@@ -24,7 +24,7 @@
  * @license     http://opensource.org/licenses/afl-3.0.php  Academic Free License (AFL 3.0)
  */
 ?>
-getTotals()) > 0 ): ?>
+getTotals()) > 0): ?>
 
     
         
diff --git a/app/design/adminhtml/default/default/template/system/currency/rate/matrix.phtml b/app/design/adminhtml/default/default/template/system/currency/rate/matrix.phtml
index 4799327d184..9f5f96d4513 100644
--- a/app/design/adminhtml/default/default/template/system/currency/rate/matrix.phtml
+++ b/app/design/adminhtml/default/default/template/system/currency/rate/matrix.phtml
@@ -37,8 +37,10 @@ $_rates = ( $_newRates ) ? $_newRates : $_oldRates;
         
             
                 |   | 
-                getAllowedCurrencies() as $_currencyCode ): ?>
-                    escapeHtml($_currencyCode) ?> | 
+                getAllowedCurrencies(); ?>
+                
+                
+                    escapeHtml($_currencyCode) ?> | 
                 
             
         
diff --git a/app/design/adminhtml/default/default/template/widget/grid.phtml b/app/design/adminhtml/default/default/template/widget/grid.phtml
index bfeefd45d4d..8bb8c75f177 100644
--- a/app/design/adminhtml/default/default/template/widget/grid.phtml
+++ b/app/design/adminhtml/default/default/template/widget/grid.phtml
@@ -35,7 +35,7 @@
  *  getPagerVisibility()
  *  getVarNamePage()
  */
-$numColumns = sizeof($this->getColumns());
+$numColumns = count($this->getColumns());
 ?>
 getCollection()): ?>
     canDisplayContainer()): ?>
diff --git a/app/design/frontend/base/default/template/catalog/product/list.phtml b/app/design/frontend/base/default/template/catalog/product/list.phtml
index 038538b47e8..6ca674aeb97 100644
--- a/app/design/frontend/base/default/template/catalog/product/list.phtml
+++ b/app/design/frontend/base/default/template/catalog/product/list.phtml
@@ -32,7 +32,8 @@
  */
 ?>
 getLoadedProductCollection();
+    $_productCollection = $this->getLoadedProductCollection();
+    $_productCollectionCount = count($_productCollection);
     $_helper = $this->helper('catalog/output');
     $_params = $this->escapeHtml(json_encode(array('form_key' => $this->getFormKey())));
 ?>
@@ -46,7 +47,7 @@
     
     
     
-        - 
+        
 - 
             
             
             
diff --git a/app/design/frontend/base/default/template/catalogsearch/term.phtml b/app/design/frontend/base/default/template/catalogsearch/term.phtml
index a3ab1232818..5e0dd1755e3 100644
--- a/app/design/frontend/base/default/template/catalogsearch/term.phtml
+++ b/app/design/frontend/base/default/template/catalogsearch/term.phtml
@@ -27,7 +27,7 @@
 
     
__('Popular Search Terms') ?>
 
-getTerms()) > 0 ): ?>
+getTerms()) > 0): ?>