Skip to content
Merged
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
2 changes: 0 additions & 2 deletions .rector.php
Original file line number Diff line number Diff line change
Expand Up @@ -124,9 +124,7 @@
Php80\Class_\AnnotationToAttributeRector::class, # todo: wait for php80
Php80\Class_\ClassPropertyAssignToConstructorPromotionRector::class, # todo: wait for php80
Php80\Class_\StringableForToStringRector::class, # todo: wait for php80
Php80\ClassConstFetch\ClassOnThisVariableObjectRector::class, # todo: TMP
Php80\ClassMethod\AddParamBasedOnParentClassMethodRector::class, # todo: TMP
Php80\FuncCall\ClassOnObjectRector::class, # todo: TMP
Php81\Array_\FirstClassCallableRector::class, # todo: TMP
Php81\FuncCall\NullToStrictStringFuncCallArgRector::class, # todo: check later
Strict\Empty_\DisallowedEmptyRuleFixerRector::class, # todo: TMP
Expand Down
2 changes: 1 addition & 1 deletion app/code/core/Mage/Api2/Model/Resource.php
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,7 @@ public function setApiType($apiType)
public function getVersion()
{
if ($this->_version === null) {
if (preg_match('/^.+([1-9]\d*)$/', get_class($this), $matches)) {
if (preg_match('/^.+([1-9]\d*)$/', static::class, $matches)) {
$this->setVersion($matches[1]);
} else {
throw new Exception('Can not determine version from class name');
Expand Down
2 changes: 1 addition & 1 deletion app/code/core/Mage/Catalog/Model/Resource/Abstract.php
Original file line number Diff line number Diff line change
Expand Up @@ -441,7 +441,7 @@ protected function _deleteAttributes($object, $table, $info)
*/
protected function _getOrigObject($object)
{
$className = get_class($object);
$className = $object::class;
$origObject = new $className();
$origObject->setData([]);
$origObject->setStoreId($object->getStoreId());
Expand Down
2 changes: 1 addition & 1 deletion app/code/core/Mage/Cms/Block/Widget/Block.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ protected function _beforeToHtml()
{
parent::_beforeToHtml();
$blockId = $this->getData('block_id');
$blockHash = get_class($this) . $blockId;
$blockHash = static::class . $blockId;

if (isset(self::$_widgetUsageMap[$blockHash])) {
return $this;
Expand Down
2 changes: 1 addition & 1 deletion app/code/core/Mage/Core/Block/Abstract.php
Original file line number Diff line number Diff line change
Expand Up @@ -1153,7 +1153,7 @@ public function getModuleName()
{
$module = $this->getData('module_name');
if (is_null($module)) {
$class = get_class($this);
$class = static::class;
$module = substr($class, 0, strpos($class, '_Block'));
$this->setData('module_name', $module);
}
Expand Down
4 changes: 2 additions & 2 deletions app/code/core/Mage/Core/Block/Template.php
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ public function fetchView($fileName)
onmouseout="this.style.zIndex='998'" title="{$fileName}">{$fileName}</div>
HTML;
if (Mage::app()->getStore()->isAdmin() ? self::$_showTemplateHintsBlocksAdmin : self::$_showTemplateHintsBlocks) {
$thisClass = get_class($this);
$thisClass = static::class;
echo <<<HTML
<div style="position:absolute; right:0; top:0; padding:2px 5px; background:{$cacheHintStatusColor}; color:blue; font:normal 11px Arial;
text-align:left !important; z-index:998;text-transform: none;" onmouseover="this.style.zIndex='999'" onmouseout="this.style.zIndex='998'"
Expand All @@ -264,7 +264,7 @@ public function fetchView($fileName)
) {
include $this->_viewDir . DS . $fileName;
} else {
$thisClass = get_class($this);
$thisClass = static::class;
Mage::log('Not valid template file:' . $fileName . ' class: ' . $thisClass, Zend_Log::CRIT, null, true);
}
} catch (Throwable $e) {
Expand Down
2 changes: 1 addition & 1 deletion app/code/core/Mage/Core/Controller/Varien/Action.php
Original file line number Diff line number Diff line change
Expand Up @@ -813,7 +813,7 @@ protected function _isUrlInternal($url)
protected function _getRealModuleName()
{
if (empty($this->_realModuleName)) {
$class = get_class($this);
$class = static::class;
$this->_realModuleName = substr(
$class,
0,
Expand Down
2 changes: 1 addition & 1 deletion app/code/core/Mage/Core/Helper/Abstract.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ protected function _cleanCache($tags = [])
protected function _getModuleName()
{
if (!$this->_moduleName) {
$class = get_class($this);
$class = static::class;
$this->_moduleName = implode('_', array_slice(explode('_', $class), 0, 2));
}
return $this->_moduleName;
Expand Down
2 changes: 1 addition & 1 deletion app/code/core/Mage/Core/Helper/Security.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public function validateAgainstBlockMethodBlacklist(Mage_Core_Block_Abstract $bl
}
if ($block instanceof $action['block'] && strtolower($action['method']) === $calledMethod) {
Mage::throwException(
sprintf('Action with combination block %s and method %s is forbidden.', get_class($block), $method),
sprintf('Action with combination block %s and method %s is forbidden.', $block::class, $method),
);
}
}
Expand Down
2 changes: 1 addition & 1 deletion app/code/core/Mage/Core/Model/App.php
Original file line number Diff line number Diff line change
Expand Up @@ -1439,7 +1439,7 @@ protected function _callObserverMethod($object, $method, $observer, $observerNam
$object->$method($observer);
} elseif (Mage::getIsDeveloperMode()) {
if (is_object($object)) {
$message = 'Method "' . $method . '" is not defined in "' . get_class($object) . '"';
$message = 'Method "' . $method . '" is not defined in "' . $object::class . '"';
} else {
$message = 'Class from observer "' . $observerName . '" is not initialized';
}
Expand Down
2 changes: 1 addition & 1 deletion app/code/core/Mage/Core/Model/Convert.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class Mage_Core_Model_Convert extends Mage_Dataflow_Model_Convert_Profile_Collec
{
public function __construct()
{
$classArr = explode('_', get_class($this));
$classArr = explode('_', static::class);
$moduleName = $classArr[0] . '_' . $classArr[1];
$etcDir = Mage::getConfig()->getModuleDir('etc', $moduleName);

Expand Down
4 changes: 2 additions & 2 deletions app/code/core/Mage/Core/Model/Layout.php
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@ protected function validateAgainstBlacklist(Mage_Core_Block_Abstract $block, $me
foreach ($this->invalidActions as $action) {
if ($block instanceof $action['block'] && $action['method'] === strtolower($method)) {
Mage::throwException(
sprintf('Action with combination block %s and method %s is forbidden.', get_class($block), $method),
sprintf('Action with combination block %s and method %s is forbidden.', $block::class, $method),
);
}
}
Expand Down Expand Up @@ -502,7 +502,7 @@ protected function _getBlockInstance($block, array $attributes = [])
}
}
if (!$block instanceof Mage_Core_Block_Abstract) {
$block = is_object($block) ? get_class($block) : $block;
$block = is_object($block) ? $block::class : $block;
Mage::throwException(Mage::helper('core')->__('Invalid block type: %s (not instance of Mage_Core_Block_Abstract)', $block));
}
return $block;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ public function run(array $args = [])
);
}

$this->getContainer()->addException('Starting ' . get_class($this->getContainer()) . ' :: ' . $method);
$this->getContainer()->addException('Starting ' . $this->getContainer()::class . ' :: ' . $method);

if ($this->getParam('from')) {
$this->getContainer()->setData($this->getContainer($this->getParam('from'))->getData());
Expand Down
2 changes: 1 addition & 1 deletion app/code/core/Mage/Eav/Model/Entity/Abstract.php
Original file line number Diff line number Diff line change
Expand Up @@ -1088,7 +1088,7 @@ public function save(Varien_Object $object)
*/
protected function _getOrigObject($object)
{
$className = get_class($object);
$className = $object::class;
$origObject = new $className();
$origObject->setData([]);
$this->load($origObject, $object->getData($this->getEntityIdField()));
Expand Down
6 changes: 3 additions & 3 deletions app/code/core/Mage/Eav/Model/Entity/Collection/Abstract.php
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ public function getResource()
public function setObject($object = null)
{
if (is_object($object)) {
$this->setItemObjectClass(get_class($object));
$this->setItemObjectClass($object::class);
} else {
$this->setItemObjectClass($object);
}
Expand All @@ -240,7 +240,7 @@ public function setObject($object = null)
*/
public function addItem(Varien_Object $object)
{
if (get_class($object) !== $this->_itemObjectClass) {
if ($object::class !== $this->_itemObjectClass) {
throw Mage::exception('Mage_Eav', Mage::helper('eav')->__('Attempt to add an invalid object'));
}
return parent::addItem($object);
Expand Down Expand Up @@ -305,7 +305,7 @@ public function addAttributeToFilter($attribute, $condition = null, $joinType =
if (!empty($conditionSql)) {
$this->getSelect()->where($conditionSql, null, Varien_Db_Select::TYPE_CONDITION);
} else {
Mage::throwException('Invalid attribute identifier for filter (' . get_class($attribute) . ')');
Mage::throwException('Invalid attribute identifier for filter (' . $attribute::class . ')');
}

return $this;
Expand Down
2 changes: 1 addition & 1 deletion app/code/core/Mage/Index/Model/Event.php
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ public function cleanNewData()
if ($processStatus == Mage_Index_Model_Process::EVENT_STATUS_DONE) {
$process = Mage::getSingleton('index/indexer')->getProcessById($processId);
if ($process) {
$namespace = get_class($process->getIndexer());
$namespace = $process->getIndexer()::class;
if (array_key_exists($namespace, $newData)) {
unset($newData[$namespace]);
}
Expand Down
2 changes: 1 addition & 1 deletion app/code/core/Mage/Index/Model/Process.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ protected function _construct()
*/
protected function _setEventNamespace(Mage_Index_Model_Event $event)
{
$namespace = get_class($this->getIndexer());
$namespace = $this->getIndexer()::class;
$event->setDataNamespace($namespace);
$event->setProcess($this);
return $this;
Expand Down
2 changes: 1 addition & 1 deletion app/code/core/Mage/Paypal/Model/Express/Checkout.php
Original file line number Diff line number Diff line change
Expand Up @@ -839,7 +839,7 @@ protected function _prepareShippingOptions(

// Magento will transfer only first 10 cheapest shipping options if there are more than 10 available.
if (count($options) > 10) {
usort($options, [get_class($this),'cmpShippingOptions']);
usort($options, [static::class,'cmpShippingOptions']);
array_splice($options, 10);
// User selected option will be always included in options list
if (!is_null($userSelectedOption) && !in_array($userSelectedOption, $options)) {
Expand Down
2 changes: 1 addition & 1 deletion app/code/core/Mage/Paypal/Model/Payflow/Request.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public function __call($method, $args)
'set' => $this->setData($key, $args[0] ?? null),
'uns' => $this->unsetData($key),
'has' => isset($this->_data[$key]),
default => throw new Varien_Exception('Invalid method ' . get_class($this) . '::' . $method . '(' . print_r($args, true) . ')'),
default => throw new Varien_Exception('Invalid method ' . static::class . '::' . $method . '(' . print_r($args, true) . ')'),
};
}
}
2 changes: 1 addition & 1 deletion app/code/core/Mage/Persistent/Model/Observer.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public function applyBlockPersistentData($observer)
return $this;
}

$xPath = '//instances/blocks/*[block_type="' . get_class($block) . '"]';
$xPath = '//instances/blocks/*[block_type="' . $block::class . '"]';
$configFilePath = $observer->getEvent()->getConfigFilePath();

/** @var Mage_Persistent_Model_Persistent_Config $persistentConfig */
Expand Down
7 changes: 6 additions & 1 deletion app/code/core/Mage/Persistent/Model/Persistent/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ public function fire()
* @param array $info
* @param Mage_Core_Block_Abstract|false $instance
* @return $this
* @throws Mage_Core_Exception
*/
public function fireOne($info, $instance = false)
{
Expand All @@ -116,7 +117,11 @@ public function fireOne($info, $instance = false)
if (method_exists($object, $method)) {
$object->$method($instance);
} elseif (Mage::getIsDeveloperMode()) {
Mage::throwException('Method "' . $method . '" is not defined in "' . get_class($object) . '"');
if (!$object instanceof Mage_Core_Model_Abstract) {
Mage::throwException(sprintf('Model "%s" is not defined"', $info['class']));
} else {
Mage::throwException(sprintf('Method "%s" is not defined in "%s"', $method, $object::class));
}
}

return $this;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ public function getParentTransaction($shouldLoad = true)
$this->_parentTransaction = false;
$parentId = $this->getParentId();
if ($parentId) {
$class = get_class($this);
$class = static::class;
$this->_parentTransaction = new $class();
if ($shouldLoad) {
$this->_parentTransaction
Expand Down
2 changes: 1 addition & 1 deletion app/code/core/Mage/Uploader/Model/Config/Abstract.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public function __call($method, $args)
'set' => $this->setData($key, $args[0] ?? null),
'uns' => $this->unsetData($key),
'has' => isset($this->_data[$key]),
default => throw new Varien_Exception('Invalid method ' . get_class($this) . '::' . $method . '(' . print_r($args, true) . ')'),
default => throw new Varien_Exception('Invalid method ' . static::class . '::' . $method . '(' . print_r($args, true) . ')'),
};
}
}
2 changes: 1 addition & 1 deletion lib/Varien/Convert/Action/Abstract.php
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ public function run()
$this->addException('Unable to run action method: ' . $method, Varien_Convert_Exception::FATAL);
}

$this->getContainer()->addException('Starting ' . get_class($this->getContainer()) . ' :: ' . $method);
$this->getContainer()->addException('Starting ' . $this->getContainer()::class . ' :: ' . $method);

if ($this->getParam('from')) {
$this->getContainer()->setData($this->getContainer($this->getParam('from'))->getData());
Expand Down
2 changes: 1 addition & 1 deletion lib/Varien/Data/Collection.php
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@ public function addItem(Varien_Object $item)

if (!is_null($itemId)) {
if (isset($this->_items[$itemId])) {
throw new Exception('Item (' . get_class($item) . ') with the same id "' . $item->getId() . '" already exist');
throw new Exception('Item (' . $item::class . ') with the same id "' . $item->getId() . '" already exist');
}
$this->_items[$itemId] = $item;
} else {
Expand Down
2 changes: 1 addition & 1 deletion lib/Varien/Db/Adapter/Pdo/Mysql.php
Original file line number Diff line number Diff line change
Expand Up @@ -2170,7 +2170,7 @@ public function insertIgnore($table, array $bind)
/** @see Zend_Db_Adapter_Exception */
#require_once 'Zend/Db/Adapter/Exception.php';
throw new Zend_Db_Adapter_Exception(
get_class($this) . " doesn't support positional or named binding",
static::class . " doesn't support positional or named binding",
);
}
}
Expand Down
6 changes: 3 additions & 3 deletions lib/Varien/Debug.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,8 @@ public static function trace(array $trace, $return = false, $html = true, $withA
// prepare method's name
$methodName = '';
if (isset($data['class']) && isset($data['function'])) {
if (isset($data['object']) && get_class($data['object']) != $data['class']) {
$className = get_class($data['object']) . '[' . $data['class'] . ']';
if (isset($data['object']) && $data['object']::class != $data['class']) {
$className = $data['object']::class . '[' . $data['class'] . ']';
} else {
$className = $data['class'];
}
Expand Down Expand Up @@ -146,7 +146,7 @@ protected static function _formatCalledArgument($arg)
{
$out = '';
if (is_object($arg)) {
$out .= sprintf('&%s#%s#', get_class($arg), spl_object_hash($arg));
$out .= sprintf('&%s#%s#', $arg::class, spl_object_hash($arg));
} elseif (is_resource($arg)) {
$out .= '#[' . get_resource_type($arg) . ']';
} elseif (is_array($arg)) {
Expand Down
2 changes: 1 addition & 1 deletion lib/Varien/Event/Observer.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public function dispatch(Varien_Event $event)
$callback = $this->getCallback();
$this->setEvent($event);

$profilerKey = 'OBSERVER: ' . (is_object($callback[0]) ? get_class($callback[0]) : (string) $callback[0]) . ' -> ' . $callback[1];
$profilerKey = 'OBSERVER: ' . (is_object($callback[0]) ? $callback[0]::class : (string) $callback[0]) . ' -> ' . $callback[1];
Varien_Profiler::start($profilerKey);
call_user_func($callback, $this);
Varien_Profiler::stop($profilerKey);
Expand Down
2 changes: 1 addition & 1 deletion lib/Varien/Filter/Object.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public function filter($object)
if (!$object instanceof Varien_Object) {
throw new Exception('Expecting an instance of Varien_Object');
}
$class = get_class($object);
$class = $object::class;
$out = new $class();
foreach ($object->getData() as $column => $value) {
$value = parent::filter($value);
Expand Down
4 changes: 2 additions & 2 deletions lib/Varien/Object.php
Original file line number Diff line number Diff line change
Expand Up @@ -616,7 +616,7 @@ public function __call($method, $args)
return isset($this->_data[$key]);
}
throw new Varien_Exception(
'Invalid method ' . get_class($this) . '::' . $method . '(' . print_r($args, true) . ')',
'Invalid method ' . static::class . '::' . $method . '(' . print_r($args, true) . ')',
);
}

Expand Down Expand Up @@ -747,7 +747,7 @@ public function debug($data = null, &$objects = [])
} elseif (is_array($value)) {
$debug[$key] = $this->debug($value, $objects);
} elseif ($value instanceof Varien_Object) {
$debug[$key . ' (' . get_class($value) . ')'] = $value->debug(null, $objects);
$debug[$key . ' (' . $value::class . ')'] = $value->debug(null, $objects);
}
}
return $debug;
Expand Down
2 changes: 1 addition & 1 deletion lib/Varien/Object/Cache.php
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ public function save($object, $idx = null, $tags = null)
}

if (isset($this->_objects[$idx])) {
throw new Varien_Exception('Object already exists in registry (' . $idx . '). Old object class: ' . get_class($this->_objects[$idx]) . ', new object class: ' . get_class($object));
throw new Varien_Exception('Object already exists in registry (' . $idx . '). Old object class: ' . $this->_objects[$idx]::class . ', new object class: ' . $object::class);
}

$this->_objects[$idx] = $object;
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/Mage/Core/Helper/SecurityTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ public function testValidateAgainstBlockMethodBlacklistThrowsException(
string $method,
array $args
): void {
$this->expectExceptionMessage(sprintf('Action with combination block %s and method %s is forbidden.', get_class($block), $method));
$this->expectExceptionMessage(sprintf('Action with combination block %s and method %s is forbidden.', $block::class, $method));
self::$subject->validateAgainstBlockMethodBlacklist($block, $method, $args);
}
}
Loading