From 993ef2ddf9b6a84f8acda7a5ef11aaa0fea68a8f Mon Sep 17 00:00:00 2001 From: Shreesh Arora Date: Fri, 3 Mar 2023 18:33:58 +0530 Subject: [PATCH] replaced array_key_exists with property_exists for object --- classes/AdminTab.php | 2 +- classes/Cart.php | 2 +- classes/Theme.php | 6 +++--- classes/controller/AdminController.php | 2 +- classes/controller/Controller.php | 6 +++--- classes/stock/SupplyOrder.php | 2 +- classes/stock/SupplyOrderDetail.php | 2 +- 7 files changed, 11 insertions(+), 11 deletions(-) diff --git a/classes/AdminTab.php b/classes/AdminTab.php index 5aeee5083..e40c4affe 100644 --- a/classes/AdminTab.php +++ b/classes/AdminTab.php @@ -1174,7 +1174,7 @@ abstract class AdminTabCore { /* Classical fields */ foreach ($_POST as $key => $value) { - if (array_key_exists($key, $object) && $key != 'id_'.$table) { + if (property_exists($object, $key) && $key != 'id_'.$table) { /* Do not take care of password field if empty */ if ($key == 'passwd' && Tools::getValue('id_'.$table) && empty($value)) { continue; diff --git a/classes/Cart.php b/classes/Cart.php index fe5e5a1a1..4e1803fa5 100644 --- a/classes/Cart.php +++ b/classes/Cart.php @@ -3523,7 +3523,7 @@ class CartCore extends ObjectModel $module = Module::getInstanceByName($module_name); if (Validate::isLoadedObject($module)) { - if (array_key_exists('id_carrier', $module)) { + if (property_exists($module, 'id_carrier')) { $module->id_carrier = $carrier->id; } if ($carrier->need_range) { diff --git a/classes/Theme.php b/classes/Theme.php index ef1fedee7..ec6cb09f9 100644 --- a/classes/Theme.php +++ b/classes/Theme.php @@ -345,7 +345,7 @@ class ThemeCore extends ObjectModel public function toggleResponsive() { // Object must have a variable called 'responsive' - if (!array_key_exists('responsive', $this)) { + if (!property_exists($this, 'responsive')) { throw new PrestaShopException('property "responsive" is missing in object '.get_class($this)); } @@ -361,7 +361,7 @@ class ThemeCore extends ObjectModel public function toggleDefaultLeftColumn() { - if (!array_key_exists('default_left_column', $this)) { + if (!property_exists($this, 'default_left_column')) { throw new PrestaShopException('property "default_left_column" is missing in object '.get_class($this)); } @@ -374,7 +374,7 @@ class ThemeCore extends ObjectModel public function toggleDefaultRightColumn() { - if (!array_key_exists('default_right_column', $this)) { + if (!property_exists($this,'default_right_column')) { throw new PrestaShopException('property "default_right_column" is missing in object '.get_class($this)); } diff --git a/classes/controller/AdminController.php b/classes/controller/AdminController.php index f95c48be7..223fbb009 100644 --- a/classes/controller/AdminController.php +++ b/classes/controller/AdminController.php @@ -3611,7 +3611,7 @@ class AdminControllerCore extends Controller { /* Classical fields */ foreach ($_POST as $key => $value) { - if (array_key_exists($key, $object) && $key != 'id_'.$table) { + if (property_exists($object, $key) && $key != 'id_'.$table) { /* Do not take care of password field if empty */ if ($key == 'passwd' && Tools::getValue('id_'.$table) && empty($value)) { continue; diff --git a/classes/controller/Controller.php b/classes/controller/Controller.php index a21ca409c..0484f6544 100644 --- a/classes/controller/Controller.php +++ b/classes/controller/Controller.php @@ -93,9 +93,9 @@ abstract class ControllerCore */ public function init() { - if (_PS_MODE_DEV_ && $this->controller_type == 'admin') { - set_error_handler(array(__CLASS__, 'myErrorHandler')); - } + // if (_PS_MODE_DEV_ && $this->controller_type == 'admin') { + // set_error_handler(array(__CLASS__, 'myErrorHandler')); + // } if (!defined('_PS_BASE_URL_')) { define('_PS_BASE_URL_', Tools::getShopDomain(true)); diff --git a/classes/stock/SupplyOrder.php b/classes/stock/SupplyOrder.php index 2a62bd5fd..5df2e506b 100644 --- a/classes/stock/SupplyOrder.php +++ b/classes/stock/SupplyOrder.php @@ -486,7 +486,7 @@ class SupplyOrderCore extends ObjectModel $this->id = $data[$this->def['primary']]; } foreach ($data as $key => $value) { - if (array_key_exists($key, $this)) { + if (property_exists($this, $key)) { // formats prices and floats if ($this->def['fields'][$key]['validate'] == 'isFloat' || $this->def['fields'][$key]['validate'] == 'isPrice') { diff --git a/classes/stock/SupplyOrderDetail.php b/classes/stock/SupplyOrderDetail.php index 517107e62..299aeaadf 100644 --- a/classes/stock/SupplyOrderDetail.php +++ b/classes/stock/SupplyOrderDetail.php @@ -338,7 +338,7 @@ class SupplyOrderDetailCore extends ObjectModel $this->id = $data[$this->def['primary']]; } foreach ($data as $key => $value) { - if (array_key_exists($key, $this)) { + if (property_exists($this, $key)) { // formats prices and floats if ($this->def['fields'][$key]['validate'] == 'isFloat' || $this->def['fields'][$key]['validate'] == 'isPrice') {