Skip to content

Prepare for updated phpstan plugin, ref #4411 #4471

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 8 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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 20 additions & 11 deletions app/Mage.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@
* @license https://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
*/

define('DS', DIRECTORY_SEPARATOR);
define('PS', PATH_SEPARATOR);
defined('DS') || define('DS', DIRECTORY_SEPARATOR);
defined('PS') || define('PS', PATH_SEPARATOR);

define('BP', dirname(__DIR__));

Mage::register('original_include_path', get_include_path());
Expand Down Expand Up @@ -278,7 +279,7 @@ public static function register($key, $value, $graceful = false)
if ($graceful) {
return;
}
self::throwException('Mage registry key "' . $key . '" already exists');
self::throwException("Mage registry key $key already exists");
}
self::$_registry[$key] = $value;
}
Expand Down Expand Up @@ -331,7 +332,7 @@ public static function setRoot($appRoot = '')
if (is_dir($appRoot) && is_readable($appRoot)) {
self::$_appRoot = $appRoot;
} else {
self::throwException($appRoot . ' is not a directory or not readable by this user');
self::throwException("$appRoot is not a directory or not readable by this user");
}
}

Expand Down Expand Up @@ -493,14 +494,18 @@ public static function getConfig()
* @param callback $callback
* @param array $data
* @param string $observerName
* @param string $observerClass
* @param class-string|'' $observerClass
* @return Varien_Event_Collection
* @throws Mage_Core_Exception
*/
public static function addObserver($eventName, $callback, $data = [], $observerName = '', $observerClass = '')
{
if ($observerClass == '') {
$observerClass = 'Varien_Event_Observer';
}
if (!class_exists($observerClass)) {
self::throwException("Invalid observer class: $observerClass");
}
$observer = new $observerClass();
$observer->setName($observerName)->addData($data)->setEventName($eventName)->setCallback($callback);
return self::getEvents()->addObserver($observer);
Expand Down Expand Up @@ -638,14 +643,17 @@ public static function getResourceHelper($moduleName)
/**
* Return new exception by module to be thrown
*
* @param string $module
* @param string $moduleName
* @param string $message
* @param integer $code
* @param int $code
* @return Mage_Core_Exception
*/
public static function exception($module = 'Mage_Core', $message = '', $code = 0)
public static function exception($moduleName = 'Mage_Core', $message = '', $code = 0)
{
$className = $module . '_Exception';
$className = $moduleName . '_Exception';
if (!class_exists($className)) {
$className = 'Mage_Core_Exception';
}
return new $className($message, $code);
}

Expand All @@ -654,6 +662,7 @@ public static function exception($module = 'Mage_Core', $message = '', $code = 0
*
* @param string $message
* @param string $messageStorage
* @return never
* @throws Mage_Core_Exception
*/
public static function throwException($message, $messageStorage = null)
Expand Down Expand Up @@ -784,8 +793,8 @@ public static function run($code = '', $type = 'store', $options = [])
*/
private static function _setIsInstalled($options = [])
{
if (isset($options['is_installed']) && $options['is_installed']) {
self::$_isInstalled = true;
if (isset($options['is_installed'])) {
self::$_isInstalled = (bool) $options['is_installed'];
}
}

Expand Down
24 changes: 12 additions & 12 deletions app/code/core/Mage/Core/Model/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -1333,17 +1333,17 @@ public function getPathVars($args = null)
* Retrieve class name by class group
*
* @param string $groupType currently supported model, block, helper
* @param string $classId slash separated class identifier, ex. group/class
* @param string $classAlias slash separated class identifier, ex. group/class
* @param string $groupRootNode optional config path for group config
* @return string
*/
public function getGroupedClassName($groupType, $classId, $groupRootNode = null)
public function getGroupedClassName($groupType, $classAlias, $groupRootNode = null)
{
if (empty($groupRootNode)) {
$groupRootNode = 'global/' . $groupType . 's';
}

$classArr = explode('/', trim($classId));
$classArr = explode('/', trim($classAlias));
$group = $classArr[0];
$class = !empty($classArr[1]) ? $classArr[1] : null;

Expand Down Expand Up @@ -1395,8 +1395,8 @@ public function getGroupedClassName($groupType, $classId, $groupRootNode = null)
/**
* Retrieve block class name
*
* @param string $blockType
* @return string
* @param string $blockType
* @return string
*/
public function getBlockClassName($blockType)
{
Expand All @@ -1409,15 +1409,15 @@ public function getBlockClassName($blockType)
/**
* Retrieve helper class name
*
* @param string $helperName
* @param string $helperAlias
* @return string
*/
public function getHelperClassName($helperName)
public function getHelperClassName($helperAlias)
{
if (!str_contains($helperName, '/')) {
$helperName .= '/data';
if (!str_contains($helperAlias, '/')) {
$helperAlias .= '/data';
}
return $this->getGroupedClassName('helper', $helperName);
return $this->getGroupedClassName('helper', $helperAlias);
}

/**
Expand Down Expand Up @@ -1445,8 +1445,8 @@ public function getResourceHelper($moduleName)
/**
* Retrieve module class name
*
* @param string $modelClass
* @return string
* @param string $modelClass
* @return string
*/
public function getModelClassName($modelClass)
{
Expand Down
3 changes: 2 additions & 1 deletion app/code/core/Mage/Core/Model/Layout.php
Original file line number Diff line number Diff line change
Expand Up @@ -595,12 +595,13 @@ public function getMessagesBlock()
/**
* @param string $type
* @return Mage_Core_Block_Abstract|object
* @throws Mage_Core_Exception
*/
public function getBlockSingleton($type)
{
if (!isset($this->_helpers[$type])) {
$className = Mage::getConfig()->getBlockClassName($type);
if (!$className) {
if (!$className || !class_exists($className)) {
Mage::throwException(Mage::helper('core')->__('Invalid block type: %s', $type));
}

Expand Down
Loading