From b45062b9d44fa45f5363bd468102682cc5f8969f Mon Sep 17 00:00:00 2001 From: Sven Reichel Date: Sat, 12 Jul 2025 02:45:39 +0200 Subject: [PATCH] rector: `IssetOnPropertyObjectToPropertyExistsRector` - see https://getrector.com/rule-detail/isset-on-property-object-to-property-exists-rector --- .rector.php | 1 - .../Adminhtml/Block/Report/Grid/Abstract.php | 2 +- .../Adminhtml/Block/System/Config/Form.php | 8 ++-- .../core/Mage/Adminhtml/Helper/Config.php | 4 +- app/code/core/Mage/Adminhtml/Model/Config.php | 10 ++--- .../Model/System/Config/Backend/Color.php | 4 +- app/code/core/Mage/Api/Model/Config.php | 4 +- .../Api/Model/Server/Handler/Abstract.php | 22 +++++------ .../Mage/Api2/Model/Acl/Global/Rule/Tree.php | 2 +- .../core/Mage/Catalog/Helper/Product/Flat.php | 2 +- .../core/Mage/CatalogSearch/Helper/Data.php | 2 +- app/code/core/Mage/Checkout/Model/Session.php | 2 +- .../Mage/Core/Controller/Varien/Front.php | 2 +- app/code/core/Mage/Core/Model/Config.php | 2 +- app/code/core/Mage/Core/Model/Layout.php | 2 +- app/code/core/Mage/Core/Model/Resource.php | 2 +- .../core/Mage/Core/Model/Resource/Setup.php | 4 +- .../Mage/Core/Model/Url/Rewrite/Request.php | 2 +- app/code/core/Mage/Cron/Model/Observer.php | 2 +- .../core/Mage/Customer/Model/Customer.php | 2 +- app/code/core/Mage/Eav/Model/Config.php | 4 +- .../Mage/Eav/Model/Convert/Adapter/Entity.php | 2 +- .../core/Mage/Install/Model/Installer/Db.php | 2 +- .../Install/Model/Installer/Db/Abstract.php | 2 +- .../core/Mage/Paygate/Model/Authorizenet.php | 12 +++--- .../Mage/Usa/Model/Shipping/Carrier/Dhl.php | 22 +++++------ .../Shipping/Carrier/Dhl/International.php | 38 +++++++++---------- .../Mage/Usa/Model/Shipping/Carrier/Fedex.php | 8 ++-- .../Mage/Usa/Model/Shipping/Carrier/Ups.php | 10 ++--- .../Mage/Usa/Model/Shipping/Carrier/Usps.php | 10 ++--- lib/Varien/Data/Collection/Db.php | 2 +- lib/Varien/Directory/Collection.php | 2 +- lib/Varien/File/Object.php | 2 +- lib/Varien/Image.php | 2 +- 34 files changed, 99 insertions(+), 100 deletions(-) diff --git a/.rector.php b/.rector.php index d06fe0126fe..7d427814299 100644 --- a/.rector.php +++ b/.rector.php @@ -65,7 +65,6 @@ CodeQuality\If_\SimplifyIfElseToTernaryRector::class, CodeQuality\If_\SimplifyIfReturnBoolRector::class, CodeQuality\Include_\AbsolutizeRequireAndIncludePathRector::class, # todo: TMP - CodeQuality\Isset_\IssetOnPropertyObjectToPropertyExistsRector::class, # todo: TMP CodeQuality\Ternary\SwitchNegatedTernaryRector::class, # todo: TMP CodeQuality\Ternary\TernaryEmptyArrayArrayDimFetchToCoalesceRector::class, # todo: TMP CodeQuality\Ternary\UnnecessaryTernaryExpressionRector::class, # todo: TMP diff --git a/app/code/core/Mage/Adminhtml/Block/Report/Grid/Abstract.php b/app/code/core/Mage/Adminhtml/Block/Report/Grid/Abstract.php index 20a9fc8cf5f..9f18fe6b153 100644 --- a/app/code/core/Mage/Adminhtml/Block/Report/Grid/Abstract.php +++ b/app/code/core/Mage/Adminhtml/Block/Report/Grid/Abstract.php @@ -33,7 +33,7 @@ public function __construct() $this->setFilterVisibility(false); $this->setPagerVisibility(false); $this->setUseAjax(false); - if (isset($this->_columnGroupBy)) { + if ($this->_columnGroupBy !== null) { $this->isColumnGrouped($this->_columnGroupBy, true); } $this->setEmptyCellLabel(Mage::helper('adminhtml')->__('No records found for this period.')); diff --git a/app/code/core/Mage/Adminhtml/Block/System/Config/Form.php b/app/code/core/Mage/Adminhtml/Block/System/Config/Form.php index 1343e752c20..932831bb655 100644 --- a/app/code/core/Mage/Adminhtml/Block/System/Config/Form.php +++ b/app/code/core/Mage/Adminhtml/Block/System/Config/Form.php @@ -305,7 +305,7 @@ public function initFields($fieldset, $group, $section, $fieldPrefix = '', $labe foreach ($element->depends->children() as $dependent) { /** @var Mage_Core_Model_Config_Element $dependent */ - if (isset($dependent->fieldset)) { + if ($dependent->fieldset !== null) { $dependentFieldGroupName = (string) $dependent->fieldset; if (!isset($this->_fieldsets[$dependentFieldGroupName])) { $dependentFieldGroupName = $group->getName(); @@ -387,13 +387,13 @@ public function initFields($fieldset, $group, $section, $fieldPrefix = '', $labe ]); $this->_prepareFieldOriginalData($field, $element); - if (isset($element->validate)) { + if ($element->validate !== null) { $field->addClass($element->validate); } - if (isset($element->frontend_type) + if ($element->frontend_type !== null && (string) $element->frontend_type === 'multiselect' - && isset($element->can_be_empty) + && $element->can_be_empty !== null ) { $field->setCanBeEmpty(true); } diff --git a/app/code/core/Mage/Adminhtml/Helper/Config.php b/app/code/core/Mage/Adminhtml/Helper/Config.php index f04d5415eb1..29152ea8c0e 100644 --- a/app/code/core/Mage/Adminhtml/Helper/Config.php +++ b/app/code/core/Mage/Adminhtml/Helper/Config.php @@ -54,10 +54,10 @@ public function getBackendModelByInputType(string $inputType): ?string */ public function getBackendModelByFieldConfig(Varien_Simplexml_Element $fieldConfig): ?string { - if (isset($fieldConfig->backend_model)) { + if ($fieldConfig->backend_model !== null) { return (string) $fieldConfig->backend_model; } - if (isset($fieldConfig->frontend_type)) { + if ($fieldConfig->frontend_type !== null) { return $this->getBackendModelByInputType((string) $fieldConfig->frontend_type); } return null; diff --git a/app/code/core/Mage/Adminhtml/Model/Config.php b/app/code/core/Mage/Adminhtml/Model/Config.php index 244e7990662..be60654cf6f 100644 --- a/app/code/core/Mage/Adminhtml/Model/Config.php +++ b/app/code/core/Mage/Adminhtml/Model/Config.php @@ -153,30 +153,30 @@ public function hasChildren($node, $websiteCode = null, $storeCode = null, $isFi { $showTab = false; if ($storeCode) { - if (isset($node->show_in_store)) { + if ($node->show_in_store !== null) { if ((int) $node->show_in_store) { $showTab = true; } } } elseif ($websiteCode) { - if (isset($node->show_in_website)) { + if ($node->show_in_website !== null) { if ((int) $node->show_in_website) { $showTab = true; } } - } elseif (isset($node->show_in_default)) { + } elseif ($node->show_in_default !== null) { if ((int) $node->show_in_default) { $showTab = true; } } if ($showTab) { - if (isset($node->groups)) { + if ($node->groups !== null) { foreach ($node->groups->children() as $children) { if ($this->hasChildren($children, $websiteCode, $storeCode)) { return true; } } - } elseif (isset($node->fields)) { + } elseif ($node->fields !== null) { foreach ($node->fields->children() as $children) { if ($this->hasChildren($children, $websiteCode, $storeCode, true)) { return true; diff --git a/app/code/core/Mage/Adminhtml/Model/System/Config/Backend/Color.php b/app/code/core/Mage/Adminhtml/Model/System/Config/Backend/Color.php index 1f161839bbf..1af111a556f 100644 --- a/app/code/core/Mage/Adminhtml/Model/System/Config/Backend/Color.php +++ b/app/code/core/Mage/Adminhtml/Model/System/Config/Backend/Color.php @@ -24,7 +24,7 @@ protected function _beforeSave() $config = $this->getFieldConfig(); $validate = []; - if (isset($config->validate)) { + if ($config->validate !== null) { $validate = array_map('trim', explode(' ', $config->validate)); } @@ -33,7 +33,7 @@ protected function _beforeSave() } $withHash = true; - if (isset($config->with_hash)) { + if ($config->with_hash !== null) { $withHash = $config->is('with_hash', true); } diff --git a/app/code/core/Mage/Api/Model/Config.php b/app/code/core/Mage/Api/Model/Config.php index dbe7029fbd8..aa579129bf7 100644 --- a/app/code/core/Mage/Api/Model/Config.php +++ b/app/code/core/Mage/Api/Model/Config.php @@ -79,7 +79,7 @@ public function getAdapters() $adapters = []; foreach ($this->getNode('adapters')->children() as $adapterName => $adapter) { /** @var Varien_Simplexml_Element $adapter */ - if (isset($adapter->use)) { + if ($adapter->use !== null) { $adapter = $this->getNode('adapters/' . (string) $adapter->use); } $adapters[$adapterName] = $adapter; @@ -215,7 +215,7 @@ public function getFaults($resourceName = null) { if (is_null($resourceName) || !isset($this->getResources()->$resourceName) - || !isset($this->getResources()->$resourceName->faults) + || (!property_exists($this->getResources()->$resourceName, 'faults') || $this->getResources()->$resourceName->faults === null) ) { $faultsNode = $this->getNode('faults'); } else { diff --git a/app/code/core/Mage/Api/Model/Server/Handler/Abstract.php b/app/code/core/Mage/Api/Model/Server/Handler/Abstract.php index 32cfb323fd9..78b0aedbf8d 100644 --- a/app/code/core/Mage/Api/Model/Server/Handler/Abstract.php +++ b/app/code/core/Mage/Api/Model/Server/Handler/Abstract.php @@ -257,8 +257,8 @@ public function call($sessionId, $apiPath, $args = []) return; } - if (!isset($resources->$resourceName->public) - && isset($resources->$resourceName->acl) + if ((!property_exists($resources->$resourceName, 'public') || $resources->$resourceName->public === null) + && (property_exists($resources->$resourceName, 'acl') && $resources->$resourceName->acl !== null) && !$this->_isAllowed((string) $resources->$resourceName->acl) ) { $this->_fault('access_denied'); @@ -276,7 +276,7 @@ public function call($sessionId, $apiPath, $args = []) $methodInfo = $resources->$resourceName->methods->$methodName; $method = (isset($methodInfo->method) ? (string) $methodInfo->method : $methodName); - if (!isset($resources->$resourceName->model)) { + if (!property_exists($resources->$resourceName, 'model') || $resources->$resourceName->model === null) { throw new Mage_Api_Exception('resource_path_not_callable'); } @@ -374,8 +374,8 @@ public function multiCall($sessionId, array $calls = [], $options = []) } } - if (!isset($resources->$resourceName->public) - && isset($resources->$resourceName->acl) + if ((!property_exists($resources->$resourceName, 'public') || $resources->$resourceName->public === null) + && (property_exists($resources->$resourceName, 'acl') && $resources->$resourceName->acl !== null) && !$this->_isAllowed((string) $resources->$resourceName->acl) ) { $result[] = $this->_faultAsArray('access_denied'); @@ -401,7 +401,7 @@ public function multiCall($sessionId, array $calls = [], $options = []) $methodInfo = $resources->$resourceName->methods->$methodName; $method = (isset($methodInfo->method) ? (string) $methodInfo->method : $methodName); - if (!isset($resources->$resourceName->model)) { + if (!property_exists($resources->$resourceName, 'model') || $resources->$resourceName->model === null) { throw new Mage_Api_Exception('resource_path_not_callable'); } @@ -471,13 +471,13 @@ public function resources($sessionId) } foreach ($this->_getConfig()->getResources() as $resourceName => $resource) { - if (isset($resource->acl) && !$this->_isAllowed((string) $resource->acl)) { + if (property_exists($resource, 'acl') && $resource->acl !== null && !$this->_isAllowed((string) $resource->acl)) { continue; } $methods = []; foreach ($resource->methods->children() as $methodName => $method) { - if (isset($method->acl) && !$this->_isAllowed((string) $method->acl)) { + if (property_exists($method, 'acl') && $method->acl !== null && !$this->_isAllowed((string) $method->acl)) { continue; } $methodAliases = []; @@ -489,7 +489,7 @@ public function resources($sessionId) $methods[] = [ 'title' => (string) $method->title, - 'description' => (isset($method->description) ? (string) $method->description : null), + 'description' => (property_exists($method, 'description') && $method->description !== null ? (string) $method->description : null), 'path' => $resourceName . '.' . $methodName, 'name' => $methodName, 'aliases' => $methodAliases, @@ -502,7 +502,7 @@ public function resources($sessionId) $resources[] = [ 'title' => (string) $resource->title, - 'description' => (isset($resource->description) ? (string) $resource->description : null), + 'description' => (property_exists($resource, 'description') && $resource->description !== null ? (string) $resource->description : null), 'name' => $resourceName, 'aliases' => $resourcesAlias[$resourceName] ?? [], 'methods' => $methods, @@ -543,7 +543,7 @@ public function resourceFaults($sessionId, $resourceName) return; } - if (isset($resources->$resourceName->acl) + if (property_exists($resources->$resourceName, 'acl') && $resources->$resourceName->acl !== null && !$this->_isAllowed((string) $resources->$resourceName->acl) ) { $this->_fault('access_denied'); diff --git a/app/code/core/Mage/Api2/Model/Acl/Global/Rule/Tree.php b/app/code/core/Mage/Api2/Model/Acl/Global/Rule/Tree.php index b3b6f80ee62..cafdaf4d45b 100644 --- a/app/code/core/Mage/Api2/Model/Acl/Global/Rule/Tree.php +++ b/app/code/core/Mage/Api2/Model/Acl/Global/Rule/Tree.php @@ -346,7 +346,7 @@ protected function _addPrivileges(&$item, Varien_Simplexml_Element $node, $name) { $roleConfigNodeName = $this->getRole()->getConfigNodeName(); $possibleList = []; - if (isset($node->privileges)) { + if ($node->privileges !== null) { $possibleRoles = $node->privileges->asArray(); if (isset($possibleRoles[$roleConfigNodeName])) { $possibleList = $possibleRoles[$roleConfigNodeName]; diff --git a/app/code/core/Mage/Catalog/Helper/Product/Flat.php b/app/code/core/Mage/Catalog/Helper/Product/Flat.php index 7d84e971b17..c1ce09d0320 100644 --- a/app/code/core/Mage/Catalog/Helper/Product/Flat.php +++ b/app/code/core/Mage/Catalog/Helper/Product/Flat.php @@ -190,7 +190,7 @@ public function disableFlatCollection($save = false) */ public function resetFlatCollection() { - if (isset($this->_forceFlatStatusOld)) { + if ($this->_forceFlatStatusOld !== null) { $this->_forceFlatStatus = $this->_forceFlatStatusOld; } else { $this->_forceFlatStatus = false; diff --git a/app/code/core/Mage/CatalogSearch/Helper/Data.php b/app/code/core/Mage/CatalogSearch/Helper/Data.php index 2e5a27cde06..bff1f916b25 100644 --- a/app/code/core/Mage/CatalogSearch/Helper/Data.php +++ b/app/code/core/Mage/CatalogSearch/Helper/Data.php @@ -105,7 +105,7 @@ public function isMinQueryLength() */ public function getQueryText() { - if (!isset($this->_queryText)) { + if ($this->_queryText === null) { $this->_queryText = $this->_getRequest()->getParam($this->getQueryParamName()); if ($this->_queryText === null) { $this->_queryText = ''; diff --git a/app/code/core/Mage/Checkout/Model/Session.php b/app/code/core/Mage/Checkout/Model/Session.php index 9552bf6b368..7a5ab10c34d 100644 --- a/app/code/core/Mage/Checkout/Model/Session.php +++ b/app/code/core/Mage/Checkout/Model/Session.php @@ -154,7 +154,7 @@ public function setCustomer($customer) */ public function hasQuote() { - return isset($this->_quote); + return $this->_quote !== null; } /** diff --git a/app/code/core/Mage/Core/Controller/Varien/Front.php b/app/code/core/Mage/Core/Controller/Varien/Front.php index ea096281788..763f3820385 100644 --- a/app/code/core/Mage/Core/Controller/Varien/Front.php +++ b/app/code/core/Mage/Core/Controller/Varien/Front.php @@ -280,7 +280,7 @@ public function rewrite() $pathInfo = preg_replace($from, $to, $request->getPathInfo()); - if (isset($rewrite->complete)) { + if ($rewrite->complete !== null) { $request->setPathInfo($pathInfo); } else { $request->rewritePathInfo($pathInfo); diff --git a/app/code/core/Mage/Core/Model/Config.php b/app/code/core/Mage/Core/Model/Config.php index 5e1090bcae4..dc813695727 100644 --- a/app/code/core/Mage/Core/Model/Config.php +++ b/app/code/core/Mage/Core/Model/Config.php @@ -1177,7 +1177,7 @@ public function getModuleSetup($module = '') if (is_string($module)) { $module = $this->getModuleConfig($module); } - if (isset($module->setup)) { + if ($module->setup !== null) { $moduleClassName = $module->setup->getClassName(); if (!empty($moduleClassName)) { $className = $moduleClassName; diff --git a/app/code/core/Mage/Core/Model/Layout.php b/app/code/core/Mage/Core/Model/Layout.php index 5cfb2657f83..d3ed8458a68 100644 --- a/app/code/core/Mage/Core/Model/Layout.php +++ b/app/code/core/Mage/Core/Model/Layout.php @@ -162,7 +162,7 @@ public function generateXml() if ($acl && Mage::getSingleton('admin/session')->isAllowed($acl)) { continue; } - if (!isset($block->attributes()->ignore)) { + if (!property_exists($block->attributes(), 'ignore') || $block->attributes()->ignore === null) { $block->addAttribute('ignore', '1'); } } diff --git a/app/code/core/Mage/Core/Model/Resource.php b/app/code/core/Mage/Core/Model/Resource.php index 23b2867b622..1cc32bce9e3 100644 --- a/app/code/core/Mage/Core/Model/Resource.php +++ b/app/code/core/Mage/Core/Model/Resource.php @@ -228,7 +228,7 @@ public function getEntity($model, $entity) * In MMDB release resource nodes <..._mysql4> were renamed to <..._resource>. So is left * to keep name of previously used nodes, that still may be used by non-updated extensions. */ - if (isset($modelsNode->$model->deprecatedNode)) { + if ($modelsNode->$model->deprecatedNode !== null) { $deprecatedNode = $modelsNode->$model->deprecatedNode; if (isset($modelsNode->$deprecatedNode->entities->$entity)) { $entityConfig = $modelsNode->$deprecatedNode->entities->$entity; diff --git a/app/code/core/Mage/Core/Model/Resource/Setup.php b/app/code/core/Mage/Core/Model/Resource/Setup.php index 55dbe6a80cd..8d0c8ee14cb 100644 --- a/app/code/core/Mage/Core/Model/Resource/Setup.php +++ b/app/code/core/Mage/Core/Model/Resource/Setup.php @@ -208,7 +208,7 @@ public static function applyAllUpdates() continue; } $className = self::class; - if (isset($resource->setup->class)) { + if ($resource->setup->class !== null) { $className = $resource->setup->getClassName(); } /** @var Mage_Core_Model_Resource_Setup $setupClass */ @@ -243,7 +243,7 @@ public static function applyAllDataUpdates() continue; } $className = self::class; - if (isset($resource->setup->class)) { + if ($resource->setup->class !== null) { $className = $resource->setup->getClassName(); } /** @var Mage_Core_Model_Resource_Setup $setupClass */ diff --git a/app/code/core/Mage/Core/Model/Url/Rewrite/Request.php b/app/code/core/Mage/Core/Model/Url/Rewrite/Request.php index cfbd2b4b690..3a0f2d0f69f 100644 --- a/app/code/core/Mage/Core/Model/Url/Rewrite/Request.php +++ b/app/code/core/Mage/Core/Model/Url/Rewrite/Request.php @@ -229,7 +229,7 @@ protected function _rewriteConfig() $to = $this->_processRewriteUrl($to); $pathInfo = preg_replace($from, $to, $this->_request->getPathInfo()); - if (isset($rewrite->complete)) { + if ($rewrite->complete !== null) { $this->_request->setPathInfo($pathInfo); } else { $this->_request->rewritePathInfo($pathInfo); diff --git a/app/code/core/Mage/Cron/Model/Observer.php b/app/code/core/Mage/Cron/Model/Observer.php index 2313924001c..be79e9fcf4a 100644 --- a/app/code/core/Mage/Cron/Model/Observer.php +++ b/app/code/core/Mage/Cron/Model/Observer.php @@ -239,7 +239,7 @@ protected function _processAlwaysTask($jobCode, $jobConfig) return; } - $cronExpr = isset($jobConfig->schedule->cron_expr) ? (string) $jobConfig->schedule->cron_expr : ''; + $cronExpr = property_exists($jobConfig->schedule, 'cron_expr') && $jobConfig->schedule->cron_expr !== null ? (string) $jobConfig->schedule->cron_expr : ''; if ($cronExpr != 'always') { return; } diff --git a/app/code/core/Mage/Customer/Model/Customer.php b/app/code/core/Mage/Customer/Model/Customer.php index 572e142c19f..2255d427492 100644 --- a/app/code/core/Mage/Customer/Model/Customer.php +++ b/app/code/core/Mage/Customer/Model/Customer.php @@ -1307,7 +1307,7 @@ public function importFromTextArray(array $row) */ public function unsetSubscription() { - if (isset($this->_isSubscribed)) { + if (property_exists($this, '_isSubscribed') && $this->_isSubscribed !== null) { unset($this->_isSubscribed); } return $this; diff --git a/app/code/core/Mage/Eav/Model/Config.php b/app/code/core/Mage/Eav/Model/Config.php index 93bfbad0958..719f1ac2406 100644 --- a/app/code/core/Mage/Eav/Model/Config.php +++ b/app/code/core/Mage/Eav/Model/Config.php @@ -124,7 +124,7 @@ public function setCurrentStoreId($storeId) */ protected function _storeId() { - if (isset($this->_currentStoreId) && $this->_currentStoreId !== false) { + if ($this->_currentStoreId !== null && $this->_currentStoreId !== false) { return $this->_currentStoreId; } return Mage::app()->getStore()->getId(); @@ -399,7 +399,7 @@ public function getEntityType($code, $field = null) } // initialize entity type cache - if (!isset($this->_entityTypes)) { + if ($this->_entityTypes === null) { $this->_initializeStore(); } diff --git a/app/code/core/Mage/Eav/Model/Convert/Adapter/Entity.php b/app/code/core/Mage/Eav/Model/Convert/Adapter/Entity.php index 03fa382aa0b..872bb14db43 100644 --- a/app/code/core/Mage/Eav/Model/Convert/Adapter/Entity.php +++ b/app/code/core/Mage/Eav/Model/Convert/Adapter/Entity.php @@ -256,7 +256,7 @@ public function load() try { $collection = $this->_getCollectionForLoad($entityType); - if (isset($this->_joinAttr) && is_array($this->_joinAttr)) { + if ($this->_joinAttr !== null && is_array($this->_joinAttr)) { foreach ($this->_joinAttr as $val) { $collection->joinAttribute( $val['alias'], diff --git a/app/code/core/Mage/Install/Model/Installer/Db.php b/app/code/core/Mage/Install/Model/Installer/Db.php index a8dd695adc0..2e3c83e296f 100644 --- a/app/code/core/Mage/Install/Model/Installer/Db.php +++ b/app/code/core/Mage/Install/Model/Installer/Db.php @@ -137,7 +137,7 @@ protected function _getCheckedData($data) */ protected function _getDbResource($model) { - if (!isset($this->_dbResource)) { + if ($this->_dbResource === null) { /** @var Mage_Install_Model_Installer_Db_Abstract $resource */ $resource = Mage::getSingleton(sprintf('install/installer_db_%s', $model)); if (!$resource) { diff --git a/app/code/core/Mage/Install/Model/Installer/Db/Abstract.php b/app/code/core/Mage/Install/Model/Installer/Db/Abstract.php index 2800156df1f..8ede1e9ef9f 100644 --- a/app/code/core/Mage/Install/Model/Installer/Db/Abstract.php +++ b/app/code/core/Mage/Install/Model/Installer/Db/Abstract.php @@ -102,7 +102,7 @@ public function supportEngine() */ protected function _getConnection() { - if (!isset($this->_connection)) { + if ($this->_connection === null) { $resource = Mage::getSingleton('core/resource'); $connection = $resource->createConnection('install', $this->getType(), $this->getConnectionData()); $this->_connection = $connection; diff --git a/app/code/core/Mage/Paygate/Model/Authorizenet.php b/app/code/core/Mage/Paygate/Model/Authorizenet.php index 625c85cca7c..1a82363edfd 100644 --- a/app/code/core/Mage/Paygate/Model/Authorizenet.php +++ b/app/code/core/Mage/Paygate/Model/Authorizenet.php @@ -1614,12 +1614,12 @@ protected function _parseTransactionDetailsXmlResponseToVarienObject(Varien_Simp ->setTransactionStatus((string) $responseTransactionXmlDocument->transactionStatus) ; //some additional fields: - isset($responseTransactionXmlDocument->responseReasonDescription) && $response->setResponseReasonDescription((string) $responseTransactionXmlDocument->responseReasonDescription); - isset($responseTransactionXmlDocument->FDSFilterAction) && $response->setFdsFilterAction((string) $responseTransactionXmlDocument->FDSFilterAction); - isset($responseTransactionXmlDocument->FDSFilters) && $response->setFdsFilters(serialize($responseTransactionXmlDocument->FDSFilters->asArray())); - isset($responseTransactionXmlDocument->transactionType) && $response->setTransactionType((string) $responseTransactionXmlDocument->transactionType); - isset($responseTransactionXmlDocument->submitTimeUTC) && $response->setSubmitTimeUtc((string) $responseTransactionXmlDocument->submitTimeUTC); - isset($responseTransactionXmlDocument->submitTimeLocal) && $response->setSubmitTimeLocal((string) $responseTransactionXmlDocument->submitTimeLocal); + $responseTransactionXmlDocument->responseReasonDescription !== null && $response->setResponseReasonDescription((string) $responseTransactionXmlDocument->responseReasonDescription); + $responseTransactionXmlDocument->FDSFilterAction !== null && $response->setFdsFilterAction((string) $responseTransactionXmlDocument->FDSFilterAction); + $responseTransactionXmlDocument->FDSFilters !== null && $response->setFdsFilters(serialize($responseTransactionXmlDocument->FDSFilters->asArray())); + $responseTransactionXmlDocument->transactionType !== null && $response->setTransactionType((string) $responseTransactionXmlDocument->transactionType); + $responseTransactionXmlDocument->submitTimeUTC !== null && $response->setSubmitTimeUtc((string) $responseTransactionXmlDocument->submitTimeUTC); + $responseTransactionXmlDocument->submitTimeLocal !== null && $response->setSubmitTimeLocal((string) $responseTransactionXmlDocument->submitTimeLocal); return $response; } 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 3b44ba2a5d4..5c44bb18c5d 100644 --- a/app/code/core/Mage/Usa/Model/Shipping/Carrier/Dhl.php +++ b/app/code/core/Mage/Usa/Model/Shipping/Carrier/Dhl.php @@ -1057,17 +1057,17 @@ protected function _parseXmlTrackingResponse($trackings, $response) * Code 0== airbill found */ $rArr['service'] = (string) $txml->Service->Desc; - if (isset($txml->Weight)) { + if (property_exists($txml, 'Weight') && $txml->Weight !== null) { $rArr['weight'] = (string) $txml->Weight . ' lbs'; } - if (isset($txml->Delivery)) { + if (property_exists($txml, 'Delivery') && $txml->Delivery !== null) { $rArr['deliverydate'] = (string) $txml->Delivery->Date; $rArr['deliverytime'] = (string) $txml->Delivery->Time . ':00'; $rArr['status'] = Mage::helper('usa')->__('Delivered'); - if (isset($txml->Delivery->Location->Desc)) { + if (property_exists($txml->Delivery->Location, 'Desc') && $txml->Delivery->Location->Desc !== null) { $rArr['deliverylocation'] = (string) $txml->Delivery->Location->Desc; } - } elseif (isset($txml->Pickup)) { + } elseif (property_exists($txml, 'Pickup') && $txml->Pickup !== null) { $rArr['deliverydate'] = (string) $txml->Pickup->Date; $rArr['deliverytime'] = (string) $txml->Pickup->Time . ':00'; $rArr['status'] = Mage::helper('usa')->__('Shipment picked up'); @@ -1077,20 +1077,20 @@ protected function _parseXmlTrackingResponse($trackings, $response) } $packageProgress = []; - if (isset($txml->TrackingHistory) && isset($txml->TrackingHistory->Status)) { + if (property_exists($txml, 'TrackingHistory') && $txml->TrackingHistory !== null && (property_exists($txml->TrackingHistory, 'Status') && $txml->TrackingHistory->Status !== null)) { foreach ($txml->TrackingHistory->Status as $thistory) { $tempArr = []; $tempArr['activity'] = (string) $thistory->StatusDesc; $tempArr['deliverydate'] = (string) $thistory->Date; //YYYY-MM-DD $tempArr['deliverytime'] = (string) $thistory->Time . ':00'; //HH:MM:ss $addArr = []; - if (isset($thistory->Location->City)) { + if (property_exists($thistory->Location, 'City') && $thistory->Location->City !== null) { $addArr[] = (string) $thistory->Location->City; } - if (isset($thistory->Location->State)) { + if (property_exists($thistory->Location, 'State') && $thistory->Location->State !== null) { $addArr[] = (string) $thistory->Location->State; } - if (isset($thistory->Location->CountryCode)) { + if (property_exists($thistory->Location, 'CountryCode') && $thistory->Location->CountryCode !== null) { $addArr[] = (string) $thistory->Location->Country; } if ($addArr) { @@ -1103,13 +1103,13 @@ protected function _parseXmlTrackingResponse($trackings, $response) * city, state and country */ $addArr = []; - if (isset($txml->Receiver->City)) { + if (property_exists($txml->Receiver, 'City') && $txml->Receiver->City !== null) { $addArr[] = (string) $txml->Receiver->City; } - if (isset($thistory->Receiver->State)) { + if (property_exists($thistory->Receiver, 'State') && $thistory->Receiver->State !== null) { $addArr[] = (string) $txml->Receiver->State; } - if (isset($thistory->Receiver->CountryCode)) { + if (property_exists($thistory->Receiver, 'CountryCode') && $thistory->Receiver->CountryCode !== null) { $addArr[] = (string) $txml->Receiver->Country; } $tempArr['deliverylocation'] = implode(', ', $addArr); diff --git a/app/code/core/Mage/Usa/Model/Shipping/Carrier/Dhl/International.php b/app/code/core/Mage/Usa/Model/Shipping/Carrier/Dhl/International.php index 300bba67966..44841dd9bed 100644 --- a/app/code/core/Mage/Usa/Model/Shipping/Carrier/Dhl/International.php +++ b/app/code/core/Mage/Usa/Model/Shipping/Carrier/Dhl/International.php @@ -907,28 +907,28 @@ protected function _parseResponse($response) $xml = simplexml_load_string($response); if (is_object($xml)) { if (in_array($xml->getName(), ['ErrorResponse', 'ShipmentValidateErrorResponse']) - || isset($xml->GetQuoteResponse->Note->Condition)) { + || property_exists($xml->GetQuoteResponse->Note, 'Condition') && $xml->GetQuoteResponse->Note->Condition !== null) { $code = null; $data = null; $nodeCondition = $xml->Response->Status->Condition ?? $xml->GetQuoteResponse->Note->Condition; if ($this->_isShippingLabelFlag) { foreach ($nodeCondition as $condition) { - $code = isset($condition->ConditionCode) ? (string) $condition->ConditionCode : 0; - $data = isset($condition->ConditionData) ? (string) $condition->ConditionData : ''; + $code = property_exists($condition, 'ConditionCode') && $condition->ConditionCode !== null ? (string) $condition->ConditionCode : 0; + $data = property_exists($condition, 'ConditionData') && $condition->ConditionData !== null ? (string) $condition->ConditionData : ''; if (!empty($code) && !empty($data)) { break; } } Mage::throwException(Mage::helper('usa')->__('Error #%s : %s', trim($code), trim($data))); } - $code = isset($nodeCondition->ConditionCode) ? (string) $nodeCondition->ConditionCode : 0; - $data = isset($nodeCondition->ConditionData) ? (string) $nodeCondition->ConditionData : ''; + $code = property_exists($nodeCondition, 'ConditionCode') && $nodeCondition->ConditionCode !== null ? (string) $nodeCondition->ConditionCode : 0; + $data = property_exists($nodeCondition, 'ConditionData') && $nodeCondition->ConditionData !== null ? (string) $nodeCondition->ConditionData : ''; $this->_errors[$code] = Mage::helper('usa')->__('Error #%s : %s', trim($code), trim($data)); - } elseif (isset($xml->GetQuoteResponse->BkgDetails->QtdShp)) { + } elseif (property_exists($xml->GetQuoteResponse->BkgDetails, 'QtdShp') && $xml->GetQuoteResponse->BkgDetails->QtdShp !== null) { foreach ($xml->GetQuoteResponse->BkgDetails->QtdShp as $quotedShipment) { $this->_addRate($quotedShipment); } - } elseif (isset($xml->AirwayBillNumber)) { + } elseif (property_exists($xml, 'AirwayBillNumber') && $xml->AirwayBillNumber !== null) { $result = new Varien_Object(); $result->setTrackingNumber((string) $xml->AirwayBillNumber); try { @@ -981,10 +981,10 @@ protected function _parseResponse($response) */ protected function _addRate(SimpleXMLElement $shipmentDetails) { - if (isset($shipmentDetails->ProductShortName) - && isset($shipmentDetails->ShippingCharge) - && isset($shipmentDetails->GlobalProductCode) - && isset($shipmentDetails->CurrencyCode) + if (property_exists($shipmentDetails, 'ProductShortName') && $shipmentDetails->ProductShortName !== null + && (property_exists($shipmentDetails, 'ShippingCharge') && $shipmentDetails->ShippingCharge !== null) + && (property_exists($shipmentDetails, 'GlobalProductCode') && $shipmentDetails->GlobalProductCode !== null) + && (property_exists($shipmentDetails, 'CurrencyCode') && $shipmentDetails->CurrencyCode !== null) && array_key_exists((string) $shipmentDetails->GlobalProductCode, $this->getAllowedMethods()) ) { // DHL product code, e.g. '3', 'A', 'Q', etc. @@ -1030,7 +1030,7 @@ protected function _addRate(SimpleXMLElement $shipmentDetails) } } else { $dhlProductDescription = false; - if (isset($shipmentDetails->GlobalProductCode)) { + if (property_exists($shipmentDetails, 'GlobalProductCode') && $shipmentDetails->GlobalProductCode !== null) { $dhlProductDescription = $this->getDhlProductTitle((string) $shipmentDetails->GlobalProductCode); } $dhlProductDescription = $dhlProductDescription ? $dhlProductDescription : Mage::helper('usa')->__('DHL'); @@ -1613,21 +1613,21 @@ protected function _parseXmlTrackingResponse($trackings, $response) if (!is_object($xml)) { $errorTitle = Mage::helper('usa')->__('Response is in the wrong format'); } - if (is_object($xml) && ((isset($xml->Response->Status->ActionStatus) + if (is_object($xml) && ((property_exists($xml->Response->Status, 'ActionStatus') && $xml->Response->Status->ActionStatus !== null && $xml->Response->Status->ActionStatus == 'Failure') - || isset($xml->GetQuoteResponse->Note->Condition)) + || property_exists($xml->GetQuoteResponse->Note, 'Condition') && $xml->GetQuoteResponse->Note->Condition !== null) ) { - if (isset($xml->Response->Status->Condition)) { + if (property_exists($xml->Response->Status, 'Condition') && $xml->Response->Status->Condition !== null) { $nodeCondition = $xml->Response->Status->Condition; } - $code = isset($nodeCondition->ConditionCode) ? (string) $nodeCondition->ConditionCode : 0; - $data = isset($nodeCondition->ConditionData) ? (string) $nodeCondition->ConditionData : ''; + $code = property_exists($nodeCondition, 'ConditionCode') && $nodeCondition->ConditionCode !== null ? (string) $nodeCondition->ConditionCode : 0; + $data = property_exists($nodeCondition, 'ConditionData') && $nodeCondition->ConditionData !== null ? (string) $nodeCondition->ConditionData : ''; $this->_errors[$code] = Mage::helper('usa')->__('Error #%s : %s', $code, $data); } elseif (is_object($xml) && is_object($xml->AWBInfo)) { foreach ($xml->AWBInfo as $awbinfo) { $awbinfoData = []; - $trackNum = isset($awbinfo->AWBNumber) ? (string) $awbinfo->AWBNumber : ''; + $trackNum = property_exists($awbinfo, 'AWBNumber') && $awbinfo->AWBNumber !== null ? (string) $awbinfo->AWBNumber : ''; if (!is_object($awbinfo) || !$awbinfo->ShipmentInfo) { $this->_errors[$trackNum] = Mage::helper('usa')->__('Unable to retrieve tracking'); continue; @@ -1641,7 +1641,7 @@ protected function _parseXmlTrackingResponse($trackings, $response) $awbinfoData['weight'] = (string) $shipmentInfo->Weight . ' ' . (string) $shipmentInfo->WeightUnit; $packageProgress = []; - if (isset($shipmentInfo->ShipmentEvent)) { + if (property_exists($shipmentInfo, 'ShipmentEvent') && $shipmentInfo->ShipmentEvent !== null) { foreach ($shipmentInfo->ShipmentEvent as $shipmentEvent) { $shipmentEventArray = []; $shipmentEventArray['activity'] = (string) $shipmentEvent->ServiceEvent->EventCode diff --git a/app/code/core/Mage/Usa/Model/Shipping/Carrier/Fedex.php b/app/code/core/Mage/Usa/Model/Shipping/Carrier/Fedex.php index c32a16a627b..4415616dd96 100644 --- a/app/code/core/Mage/Usa/Model/Shipping/Carrier/Fedex.php +++ b/app/code/core/Mage/Usa/Model/Shipping/Carrier/Fedex.php @@ -1161,20 +1161,20 @@ protected function _parseXmlTrackingResponse($trackingvalue, $response) $resultArr['weight'] = "{$weight} {$unit}"; $packageProgress = []; - if (isset($xml->Package->Event)) { + if (property_exists($xml->Package, 'Event') && $xml->Package->Event !== null) { foreach ($xml->Package->Event as $event) { $tempArr = []; $tempArr['activity'] = (string) $event->Description; $tempArr['deliverydate'] = (string) $event->Date;//YYYY-MM-DD $tempArr['deliverytime'] = (string) $event->Time;//HH:MM:ss $addArr = []; - if (isset($event->Address->City)) { + if (property_exists($event->Address, 'City') && $event->Address->City !== null) { $addArr[] = (string) $event->Address->City; } - if (isset($event->Address->StateProvinceCode)) { + if (property_exists($event->Address, 'StateProvinceCode') && $event->Address->StateProvinceCode !== null) { $addArr[] = (string) $event->Address->StateProvinceCode; } - if (isset($event->Address->CountryCode)) { + if (property_exists($event->Address, 'CountryCode') && $event->Address->CountryCode !== null) { $addArr[] = (string) $event->Address->CountryCode; } if ($addArr) { diff --git a/app/code/core/Mage/Usa/Model/Shipping/Carrier/Ups.php b/app/code/core/Mage/Usa/Model/Shipping/Carrier/Ups.php index 9878ab26eab..ee38585c43c 100644 --- a/app/code/core/Mage/Usa/Model/Shipping/Carrier/Ups.php +++ b/app/code/core/Mage/Usa/Model/Shipping/Carrier/Ups.php @@ -1059,13 +1059,13 @@ protected function _parseXmlTrackingResponse($trackingvalue, $xmlResponse) $i = 1; foreach ($activityTags as $activityTag) { $addArr = []; - if (isset($activityTag->ActivityLocation->Address->City)) { + if ($activityTag->ActivityLocation->Address->City !== null) { $addArr[] = (string) $activityTag->ActivityLocation->Address->City; } - if (isset($activityTag->ActivityLocation->Address->StateProvinceCode)) { + if ($activityTag->ActivityLocation->Address->StateProvinceCode !== null) { $addArr[] = (string) $activityTag->ActivityLocation->Address->StateProvinceCode; } - if (isset($activityTag->ActivityLocation->Address->CountryCode)) { + if ($activityTag->ActivityLocation->Address->CountryCode !== null) { $addArr[] = (string) $activityTag->ActivityLocation->Address->CountryCode; } $dateArr = []; @@ -1581,7 +1581,7 @@ protected function _sendShipmentAcceptRequest(SimpleXMLElement $shipmentConfirmR return $result; } - if (isset($response->Error)) { + if (property_exists($response, 'Error') && $response->Error !== null) { $result->setErrors((string) $response->Error->ErrorDescription); } else { $shippingLabelContent = (string) $response->ShipmentResults->PackageResults->LabelImage->GraphicImage; @@ -1989,7 +1989,7 @@ protected function _doShipmentRequestXML(Varien_Object $request): Varien_Object $result->setErrors($e->getMessage()); } - if (isset($response->Response->Error) + if (property_exists($response->Response, 'Error') && $response->Response->Error !== null && in_array($response->Response->Error->ErrorSeverity, ['Hard', 'Transient']) ) { $result->setErrors((string) $response->Response->Error->ErrorDescription); diff --git a/app/code/core/Mage/Usa/Model/Shipping/Carrier/Usps.php b/app/code/core/Mage/Usa/Model/Shipping/Carrier/Usps.php index bc313b885b2..bbc0c553caa 100644 --- a/app/code/core/Mage/Usa/Model/Shipping/Carrier/Usps.php +++ b/app/code/core/Mage/Usa/Model/Shipping/Carrier/Usps.php @@ -970,11 +970,11 @@ protected function _parseXmlTrackingResponse($trackingValue, $response) if (str_starts_with(trim($response), 'Number) && isset($xml->Description) && (string) $xml->Description != '') { + if (property_exists($xml, 'Number') && $xml->Number !== null && (property_exists($xml, 'Description') && $xml->Description !== null) && (string) $xml->Description != '') { $errorTitle = (string) $xml->Description; - } elseif (isset($xml->TrackInfo) - && isset($xml->TrackInfo->Error) - && isset($xml->TrackInfo->Error->Description) + } elseif (property_exists($xml, 'TrackInfo') && $xml->TrackInfo !== null + && (property_exists($xml->TrackInfo, 'Error') && $xml->TrackInfo->Error !== null) + && (property_exists($xml->TrackInfo->Error, 'Description') && $xml->TrackInfo->Error->Description !== null) && (string) $xml->TrackInfo->Error->Description != '' ) { $errorTitle = (string) $xml->TrackInfo->Error->Description; @@ -982,7 +982,7 @@ protected function _parseXmlTrackingResponse($trackingValue, $response) $errorTitle = Mage::helper('usa')->__('Unknown error'); } - if (isset($xml->TrackInfo) && isset($xml->TrackInfo->TrackSummary)) { + if (property_exists($xml, 'TrackInfo') && $xml->TrackInfo !== null && (property_exists($xml->TrackInfo, 'TrackSummary') && $xml->TrackInfo->TrackSummary !== null)) { $resultArr['tracksummary'] = (string) $xml->TrackInfo->TrackSummary; } } diff --git a/lib/Varien/Data/Collection/Db.php b/lib/Varien/Data/Collection/Db.php index 27ee9cbdd8e..53320a9ab80 100644 --- a/lib/Varien/Data/Collection/Db.php +++ b/lib/Varien/Data/Collection/Db.php @@ -472,7 +472,7 @@ protected function _getMappedField($field) */ protected function _getMapper() { - if (isset($this->_map)) { + if ($this->_map !== null) { return $this->_map; } else { return false; diff --git a/lib/Varien/Directory/Collection.php b/lib/Varien/Directory/Collection.php index 674678dbdc3..27269e95219 100644 --- a/lib/Varien/Directory/Collection.php +++ b/lib/Varien/Directory/Collection.php @@ -87,7 +87,7 @@ public function getPath() public function setPath($path, $isRecursion = '') { if (is_dir($path)) { - if (isset($this->_path) && $this->_path != $path && $this->_path != '') { + if ($this->_path !== null && $this->_path != $path && $this->_path != '') { $this->_path = $path; if ($isRecursion != '') { $this->_isRecursion = $isRecursion; diff --git a/lib/Varien/File/Object.php b/lib/Varien/File/Object.php index f14f51f4434..626e3bc5b7c 100644 --- a/lib/Varien/File/Object.php +++ b/lib/Varien/File/Object.php @@ -195,7 +195,7 @@ public function getName() */ public function renderFilter() { - if (isset($this->_filter) && count($this->_filter) > 0 && $this->filtered == false) { + if ($this->_filter !== null && count($this->_filter) > 0 && $this->filtered == false) { $this->filtered = true; if (isset($this->_filter['extension'])) { $filter = $this->_filter['extension']; diff --git a/lib/Varien/Image.php b/lib/Varien/Image.php index ae3ad66928a..268b982ed8c 100644 --- a/lib/Varien/Image.php +++ b/lib/Varien/Image.php @@ -285,7 +285,7 @@ public function setWatermarkHeigth($heigth) */ protected function _getAdapter($adapter = null) { - if (!isset($this->_adapter)) { + if ($this->_adapter === null) { $this->_adapter = Varien_Image_Adapter::factory($adapter); } return $this->_adapter;