Skip to content

PHP-CS-Fixer: ordered class elements #4483

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
20 changes: 11 additions & 9 deletions .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
<?php
/*
* This document has been generated with
* https://mlocati.github.io/php-cs-fixer-configurator/#version:3.4.0|configurator
* you can change this configuration by importing this file.
*/

declare(strict_types=1);

$config = new PhpCsFixer\Config();
return $config
->setRiskyAllowed(true)
Expand All @@ -16,6 +14,8 @@
'modernize_types_casting' => true,
// PHP84: Adds or removes ? before single type declarations or |null at the end of union types when parameters have a default null value.
'nullable_type_declaration_for_default_null_value' => true,
// Orders the elements of classes/interfaces/traits/enums.
'ordered_class_elements' => true,
// Convert double quotes to single quotes for simple strings.
'single_quote' => true,
// Arguments lists, array destructuring lists, arrays that are multi-line, match-lines and parameters lists must have a trailing comma.
Expand All @@ -29,11 +29,13 @@
__DIR__,
])
->exclude([
'lib/3Dsecure/',
'lib/LinLibertineFont/',
'lib/Unserialize/',
__DIR__ . 'lib/3Dsecure/',
__DIR__ . 'lib/LinLibertineFont/',
__DIR__ . 'lib/Unserialize/',
__DIR__ . '/shell/translations.php',
__DIR__ . '/shell/update-copyright.php',
])
->name('*.php')
->ignoreDotFiles(true)
->ignoreVCS(true)
->ignoreVCS(true),
);
97 changes: 48 additions & 49 deletions app/Mage.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,20 @@
*/
final class Mage
{
/**
* Magento edition constants
*/
public const EDITION_COMMUNITY = 'Community';
public const EDITION_ENTERPRISE = 'Enterprise';
public const EDITION_PROFESSIONAL = 'Professional';
public const EDITION_GO = 'Go';

/**
* Is allow throw Exception about headers already sent
*
* @var bool
*/
public static $headersSentThrowsException = true;
/**
* Registry collection
*
Expand Down Expand Up @@ -113,28 +127,13 @@ final class Mage
*/
private static $_isDeveloperMode = false;

/**
* Is allow throw Exception about headers already sent
*
* @var bool
*/
public static $headersSentThrowsException = true;

/**
* Is installed flag
*
* @var bool|null
*/
private static $_isInstalled;

/**
* Magento edition constants
*/
public const EDITION_COMMUNITY = 'Community';
public const EDITION_ENTERPRISE = 'Enterprise';
public const EDITION_PROFESSIONAL = 'Professional';
public const EDITION_GO = 'Go';

/**
* Current Magento edition.
*
Expand Down Expand Up @@ -777,40 +776,6 @@ public static function run($code = '', $type = 'store', $options = [])
}
}

/**
* Set application isInstalled flag based on given options
*
* @param array $options
*/
private static function _setIsInstalled($options = [])
{
if (isset($options['is_installed']) && $options['is_installed']) {
self::$_isInstalled = true;
}
}

/**
* Set application Config model
*
* @param array $options
*/
private static function _setConfigModel($options = [])
{
if (isset($options['config_model']) && class_exists($options['config_model'])) {
$alternativeConfigModelName = $options['config_model'];
unset($options['config_model']);
$alternativeConfigModel = new $alternativeConfigModelName($options);
} else {
$alternativeConfigModel = null;
}

if (!is_null($alternativeConfigModel) && ($alternativeConfigModel instanceof Mage_Core_Model_Config)) {
self::$_config = $alternativeConfigModel;
} else {
self::$_config = new Mage_Core_Model_Config($options);
}
}

/**
* Retrieve application installation flag
*
Expand Down Expand Up @@ -1059,4 +1024,38 @@ public static function getScriptSystemUrl($folder, $exitIfNot = false)

return $baseUrl;
}

/**
* Set application isInstalled flag based on given options
*
* @param array $options
*/
private static function _setIsInstalled($options = [])
{
if (isset($options['is_installed']) && $options['is_installed']) {
self::$_isInstalled = true;
}
}

/**
* Set application Config model
*
* @param array $options
*/
private static function _setConfigModel($options = [])
{
if (isset($options['config_model']) && class_exists($options['config_model'])) {
$alternativeConfigModelName = $options['config_model'];
unset($options['config_model']);
$alternativeConfigModel = new $alternativeConfigModelName($options);
} else {
$alternativeConfigModel = null;
}

if (!is_null($alternativeConfigModel) && ($alternativeConfigModel instanceof Mage_Core_Model_Config)) {
self::$_config = $alternativeConfigModel;
} else {
self::$_config = new Mage_Core_Model_Config($options);
}
}
}
3 changes: 1 addition & 2 deletions app/code/core/Mage/Admin/Helper/Data.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,12 @@
*/
class Mage_Admin_Helper_Data extends Mage_Core_Helper_Abstract
{
protected $_moduleName = 'Mage_Admin';

/**
* Configuration path to expiration period of reset password link
*/
public const XML_PATH_ADMIN_RESET_PASSWORD_LINK_EXPIRATION_PERIOD
= 'default/admin/emails/password_reset_link_expiration_period';
protected $_moduleName = 'Mage_Admin';

/**
* Generate unique token for reset password confirmation link
Expand Down
25 changes: 12 additions & 13 deletions app/code/core/Mage/Admin/Helper/Rules/Fallback.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,6 @@
*/
class Mage_Admin_Helper_Rules_Fallback extends Mage_Core_Helper_Abstract
{
/**
* Fallback to resource parent node
* @param string $resourceId
*
* @return string
*/
protected function _getParentResourceId($resourceId)
{
$resourcePathInfo = explode('/', $resourceId);
array_pop($resourcePathInfo);
return implode('/', $resourcePathInfo);
}

/**
* Fallback resource permissions similarly to zend_acl
* @param array $resources
Expand All @@ -58,4 +45,16 @@ public function fallbackResourcePermissions(

return $resources[$resourceId];
}
/**
* Fallback to resource parent node
* @param string $resourceId
*
* @return string
*/
protected function _getParentResourceId($resourceId)
{
$resourcePathInfo = explode('/', $resourceId);
array_pop($resourcePathInfo);
return implode('/', $resourcePathInfo);
}
}
26 changes: 13 additions & 13 deletions app/code/core/Mage/Admin/Model/Acl.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,19 +57,6 @@ class Mage_Admin_Model_Acl extends Zend_Acl
*/
public const RULE_PERM_ALLOW = 2;

/**
* Get role registry object or create one
*
* @return Mage_Admin_Model_Acl_Role_Registry
*/
protected function _getRoleRegistry()
{
if ($this->_roleRegistry === null) {
$this->_roleRegistry = Mage::getModel('admin/acl_role_registry');
}
return $this->_roleRegistry;
}

/**
* Add parent to role object
*
Expand All @@ -82,4 +69,17 @@ public function addRoleParent($role, $parent)
$this->_getRoleRegistry()->addParent($role, $parent);
return $this;
}

/**
* Get role registry object or create one
*
* @return Mage_Admin_Model_Acl_Role_Registry
*/
protected function _getRoleRegistry()
{
if ($this->_roleRegistry === null) {
$this->_roleRegistry = Mage::getModel('admin/acl_role_registry');
}
return $this->_roleRegistry;
}
}
15 changes: 7 additions & 8 deletions app/code/core/Mage/Admin/Model/Block.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,6 @@
*/
class Mage_Admin_Model_Block extends Mage_Core_Model_Abstract
{
/**
* Initialize variable model
*/
protected function _construct()
{
$this->_init('admin/block');
}

/**
* @return array|true
* @throws Exception
Expand Down Expand Up @@ -77,4 +69,11 @@ public function isTypeAllowed($type)
{
return Mage::helper('admin/block')->isTypeAllowed($type);
}
/**
* Initialize variable model
*/
protected function _construct()
{
$this->_init('admin/block');
}
}
18 changes: 9 additions & 9 deletions app/code/core/Mage/Admin/Model/Resource/Acl.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,6 @@ class Mage_Admin_Model_Resource_Acl extends Mage_Core_Model_Resource_Db_Abstract
{
public const ACL_ALL_RULES = 'all';

/**
* Initialize resource
*
*/
protected function _construct()
{
$this->_init('admin/role', 'role_id');
}

/**
* Load ACL for the user
*
Expand Down Expand Up @@ -152,4 +143,13 @@ public function loadRules(Mage_Admin_Model_Acl $acl, array $rulesArr)

return $this;
}

/**
* Initialize resource
*
*/
protected function _construct()
{
$this->_init('admin/role', 'role_id');
}
}
30 changes: 15 additions & 15 deletions app/code/core/Mage/Admin/Model/Resource/Block.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,6 @@ class Mage_Admin_Model_Resource_Block extends Mage_Core_Model_Resource_Db_Abstra
*/
protected $disallowedBlockNames = ['install/end'];

protected function _construct()
{
$this->_init('admin/permission_block', 'block_id');
}

/**
* Get allowed types
*
Expand All @@ -54,6 +49,21 @@ public function getAllowedTypes()
return Mage::helper('core')->jsonDecode($data);
}

/**
* Get disallowed names for block
*
* @return array
*/
public function getDisallowedBlockNames()
{
return $this->disallowedBlockNames;
}

protected function _construct()
{
$this->_init('admin/permission_block', 'block_id');
}

/**
* Regenerate cache
*/
Expand Down Expand Up @@ -92,14 +102,4 @@ protected function _afterDelete(Mage_Core_Model_Abstract $object)
$this->_generateCache();
return parent::_afterDelete($object);
}

/**
* Get disallowed names for block
*
* @return array
*/
public function getDisallowedBlockNames()
{
return $this->disallowedBlockNames;
}
}
9 changes: 4 additions & 5 deletions app/code/core/Mage/Admin/Model/Resource/Role/Collection.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,6 @@
*/
class Mage_Admin_Model_Resource_Role_Collection extends Mage_Core_Model_Resource_Db_Collection_Abstract
{
protected function _construct()
{
$this->_init('admin/role');
}

/**
* Add user filter
*
Expand All @@ -52,4 +47,8 @@ public function setRolesFilter()
$this->addFieldToFilter('role_type', 'G');
return $this;
}
protected function _construct()
{
$this->_init('admin/role');
}
}
Loading
Loading