From 3ad9da46ce492a9faa7b83b2b7352233239edf10 Mon Sep 17 00:00:00 2001 From: Hans Mackowiak Date: Tue, 2 Jun 2026 17:10:36 +0200 Subject: [PATCH 01/14] [Sales] add getMailer and Email-Queues --- app/code/core/Mage/Sales/Model/Abstract.php | 9 +++++ app/code/core/Mage/Sales/Model/Order.php | 6 ++-- .../Mage/Sales/Model/Order/Creditmemo.php | 34 ++++++++++++++++--- .../core/Mage/Sales/Model/Order/Invoice.php | 34 ++++++++++++++++--- .../core/Mage/Sales/Model/Order/Shipment.php | 34 ++++++++++++++++--- 5 files changed, 101 insertions(+), 16 deletions(-) diff --git a/app/code/core/Mage/Sales/Model/Abstract.php b/app/code/core/Mage/Sales/Model/Abstract.php index 1e15e287882..74b914c0200 100644 --- a/app/code/core/Mage/Sales/Model/Abstract.php +++ b/app/code/core/Mage/Sales/Model/Abstract.php @@ -74,4 +74,13 @@ public function getCreatedAtStoreDate() true, ); } + + protected function getMailer(): Mage_Core_Model_Email_Template_Mailer + { + /** + * @var Mage_Core_Model_Email_Template_Mailer $mailer + */ + $mailer = Mage::getModel('core/email_template_mailer'); + return $mailer; + } } diff --git a/app/code/core/Mage/Sales/Model/Order.php b/app/code/core/Mage/Sales/Model/Order.php index 6c27fa18837..6ac61795bf1 100644 --- a/app/code/core/Mage/Sales/Model/Order.php +++ b/app/code/core/Mage/Sales/Model/Order.php @@ -1441,8 +1441,7 @@ public function queueNewOrderEmail($forceMode = false) $customerName = $this->getCustomerName(); } - /** @var Mage_Core_Model_Email_Template_Mailer $mailer */ - $mailer = Mage::getModel('core/email_template_mailer'); + $mailer = $this->getMailer(); /** @var Mage_Core_Model_Email_Info $emailInfo */ $emailInfo = Mage::getModel('core/email_info'); $emailInfo->addTo($this->getCurrentCustomerEmail(), $customerName); @@ -1534,8 +1533,7 @@ public function queueOrderUpdateEmail($notifyCustomer = true, $comment = '', $fo $customerName = $this->getCustomerName(); } - /** @var Mage_Core_Model_Email_Template_Mailer $mailer */ - $mailer = Mage::getModel('core/email_template_mailer'); + $mailer = $this->getMailer(); if ($notifyCustomer) { /** @var Mage_Core_Model_Email_Info $emailInfo */ $emailInfo = Mage::getModel('core/email_info'); diff --git a/app/code/core/Mage/Sales/Model/Order/Creditmemo.php b/app/code/core/Mage/Sales/Model/Order/Creditmemo.php index 52111ca9440..febb93fc244 100644 --- a/app/code/core/Mage/Sales/Model/Order/Creditmemo.php +++ b/app/code/core/Mage/Sales/Model/Order/Creditmemo.php @@ -125,6 +125,16 @@ */ class Mage_Sales_Model_Order_Creditmemo extends Mage_Sales_Model_Abstract { + + public const ENTITY = 'creditmemo'; + + /** + * Event type names for order emails + */ + public const EMAIL_EVENT_NAME_NEW_CREDITMEMO = 'new_creditmemo'; + + public const EMAIL_EVENT_NAME_UPDATE_CREDITMEMO = 'update_creditmemo'; + public const STATE_OPEN = 1; public const STATE_REFUNDED = 2; @@ -821,7 +831,7 @@ public function sendEmail($notifyCustomer = true, $comment = '') $customerName = $order->getCustomerName(); } - $mailer = Mage::getModel('core/email_template_mailer'); + $mailer = $this->getMailer(); if ($notifyCustomer) { $emailInfo = Mage::getModel('core/email_info'); $emailInfo->addTo($order->getCurrentCustomerEmail(), $customerName); @@ -855,7 +865,15 @@ public function sendEmail($notifyCustomer = true, $comment = '') 'billing' => $order->getBillingAddress(), 'payment_html' => $paymentBlockHtml, ]); - $mailer->send(); + + /** @var Mage_Core_Model_Email_Queue $emailQueue */ + $emailQueue = Mage::getModel('core/email_queue'); + $emailQueue->setEntityId($this->getId()) + ->setEntityType(self::ENTITY) + ->setEventType(self::EMAIL_EVENT_NAME_NEW_CREDITMEMO) + ->setIsForceCheck(true); + + $mailer->setQueue($emailQueue)->send(); if ($notifyCustomer) { $this->setEmailSent(true); @@ -899,7 +917,7 @@ public function sendUpdateEmail($notifyCustomer = true, $comment = '') $customerName = $order->getCustomerName(); } - $mailer = Mage::getModel('core/email_template_mailer'); + $mailer = $this->getMailer(); if ($notifyCustomer) { $emailInfo = Mage::getModel('core/email_info'); $emailInfo->addTo($order->getCurrentCustomerEmail(), $customerName); @@ -932,7 +950,15 @@ public function sendUpdateEmail($notifyCustomer = true, $comment = '') 'comment' => $comment, 'billing' => $order->getBillingAddress(), ]); - $mailer->send(); + + /** @var Mage_Core_Model_Email_Queue $emailQueue */ + $emailQueue = Mage::getModel('core/email_queue'); + $emailQueue->setEntityId($this->getId()) + ->setEntityType(self::ENTITY) + ->setEventType(self::EMAIL_EVENT_NAME_UPDATE_CREDITMEMO) + ->setIsForceCheck(true); + + $mailer->setQueue($emailQueue)->send(); return $this; } diff --git a/app/code/core/Mage/Sales/Model/Order/Invoice.php b/app/code/core/Mage/Sales/Model/Order/Invoice.php index f88a7337d73..3ac7314befe 100644 --- a/app/code/core/Mage/Sales/Model/Order/Invoice.php +++ b/app/code/core/Mage/Sales/Model/Order/Invoice.php @@ -105,6 +105,16 @@ */ class Mage_Sales_Model_Order_Invoice extends Mage_Sales_Model_Abstract { + + public const ENTITY = 'invoice'; + + /** + * Event type names for order emails + */ + public const EMAIL_EVENT_NAME_NEW_INVOICE = 'new_invoice'; + + public const EMAIL_EVENT_NAME_UPDATE_INVOICE = 'update_invoice'; + /** * Invoice states */ @@ -850,7 +860,7 @@ public function sendEmail($notifyCustomer = true, $comment = '') $customerName = $order->getCustomerName(); } - $mailer = Mage::getModel('core/email_template_mailer'); + $mailer = $this->getMailer(); if ($notifyCustomer) { $emailInfo = Mage::getModel('core/email_info'); $emailInfo->addTo($order->getCurrentCustomerEmail(), $customerName); @@ -884,7 +894,15 @@ public function sendEmail($notifyCustomer = true, $comment = '') 'billing' => $order->getBillingAddress(), 'payment_html' => $paymentBlockHtml, ]); - $mailer->send(); + + /** @var Mage_Core_Model_Email_Queue $emailQueue */ + $emailQueue = Mage::getModel('core/email_queue'); + $emailQueue->setEntityId($this->getId()) + ->setEntityType(self::ENTITY) + ->setEventType(self::EMAIL_EVENT_NAME_NEW_INVOICE) + ->setIsForceCheck(true); + + $mailer->setQueue($emailQueue)->send(); if ($notifyCustomer) { $this->setEmailSent(true); @@ -927,7 +945,7 @@ public function sendUpdateEmail($notifyCustomer = true, $comment = '') $customerName = $order->getCustomerName(); } - $mailer = Mage::getModel('core/email_template_mailer'); + $mailer = $this->getMailer(); if ($notifyCustomer) { $emailInfo = Mage::getModel('core/email_info'); $emailInfo->addTo($order->getCurrentCustomerEmail(), $customerName); @@ -960,7 +978,15 @@ public function sendUpdateEmail($notifyCustomer = true, $comment = '') 'comment' => $comment, 'billing' => $order->getBillingAddress(), ]); - $mailer->send(); + + /** @var Mage_Core_Model_Email_Queue $emailQueue */ + $emailQueue = Mage::getModel('core/email_queue'); + $emailQueue->setEntityId($this->getId()) + ->setEntityType(self::ENTITY) + ->setEventType(self::EMAIL_EVENT_NAME_UPDATE_INVOICE) + ->setIsForceCheck(true); + + $mailer->setQueue($emailQueue)->send(); return $this; } diff --git a/app/code/core/Mage/Sales/Model/Order/Shipment.php b/app/code/core/Mage/Sales/Model/Order/Shipment.php index b9fcd70a238..b5d769e50af 100644 --- a/app/code/core/Mage/Sales/Model/Order/Shipment.php +++ b/app/code/core/Mage/Sales/Model/Order/Shipment.php @@ -41,6 +41,16 @@ */ class Mage_Sales_Model_Order_Shipment extends Mage_Sales_Model_Abstract { + + public const ENTITY = 'shipment'; + + /** + * Event type names for order emails + */ + public const EMAIL_EVENT_NAME_NEW_SHIPMENT = 'new_shipment'; + + public const EMAIL_EVENT_NAME_UPDATE_SHIPMENT = 'update_shipment'; + public const STATUS_NEW = 1; public const XML_PATH_EMAIL_TEMPLATE = 'sales_email/shipment/template'; @@ -482,7 +492,7 @@ public function sendEmail($notifyCustomer = true, $comment = '') $customerName = $order->getCustomerName(); } - $mailer = Mage::getModel('core/email_template_mailer'); + $mailer = $this->getMailer(); if ($notifyCustomer) { $emailInfo = Mage::getModel('core/email_info'); $emailInfo->addTo($order->getCurrentCustomerEmail(), $customerName); @@ -516,7 +526,15 @@ public function sendEmail($notifyCustomer = true, $comment = '') 'billing' => $order->getBillingAddress(), 'payment_html' => $paymentBlockHtml, ]); - $mailer->send(); + + /** @var Mage_Core_Model_Email_Queue $emailQueue */ + $emailQueue = Mage::getModel('core/email_queue'); + $emailQueue->setEntityId($this->getId()) + ->setEntityType(self::ENTITY) + ->setEventType(self::EMAIL_EVENT_NAME_NEW_SHIPMENT) + ->setIsForceCheck(true); + + $mailer->setQueue($emailQueue)->send(); return $this; } @@ -554,7 +572,7 @@ public function sendUpdateEmail($notifyCustomer = true, $comment = '') $customerName = $order->getCustomerName(); } - $mailer = Mage::getModel('core/email_template_mailer'); + $mailer = $this->getMailer(); if ($notifyCustomer) { $emailInfo = Mage::getModel('core/email_info'); $emailInfo->addTo($order->getCurrentCustomerEmail(), $customerName); @@ -587,7 +605,15 @@ public function sendUpdateEmail($notifyCustomer = true, $comment = '') 'comment' => $comment, 'billing' => $order->getBillingAddress(), ]); - $mailer->send(); + + /** @var Mage_Core_Model_Email_Queue $emailQueue */ + $emailQueue = Mage::getModel('core/email_queue'); + $emailQueue->setEntityId($this->getId()) + ->setEntityType(self::ENTITY) + ->setEventType(self::EMAIL_EVENT_NAME_UPDATE_SHIPMENT) + ->setIsForceCheck(true); + + $mailer->setQueue($emailQueue)->send(); return $this; } From c865fada4600510b4ddcd4bfd35ed4014c166839 Mon Sep 17 00:00:00 2001 From: Hans Mackowiak Date: Tue, 2 Jun 2026 17:22:30 +0200 Subject: [PATCH 02/14] ~cs fixer --- app/code/core/Mage/Sales/Model/Order/Creditmemo.php | 1 - app/code/core/Mage/Sales/Model/Order/Invoice.php | 1 - app/code/core/Mage/Sales/Model/Order/Shipment.php | 1 - 3 files changed, 3 deletions(-) diff --git a/app/code/core/Mage/Sales/Model/Order/Creditmemo.php b/app/code/core/Mage/Sales/Model/Order/Creditmemo.php index febb93fc244..a4b8f40891d 100644 --- a/app/code/core/Mage/Sales/Model/Order/Creditmemo.php +++ b/app/code/core/Mage/Sales/Model/Order/Creditmemo.php @@ -125,7 +125,6 @@ */ class Mage_Sales_Model_Order_Creditmemo extends Mage_Sales_Model_Abstract { - public const ENTITY = 'creditmemo'; /** diff --git a/app/code/core/Mage/Sales/Model/Order/Invoice.php b/app/code/core/Mage/Sales/Model/Order/Invoice.php index 3ac7314befe..0185ae247a9 100644 --- a/app/code/core/Mage/Sales/Model/Order/Invoice.php +++ b/app/code/core/Mage/Sales/Model/Order/Invoice.php @@ -105,7 +105,6 @@ */ class Mage_Sales_Model_Order_Invoice extends Mage_Sales_Model_Abstract { - public const ENTITY = 'invoice'; /** diff --git a/app/code/core/Mage/Sales/Model/Order/Shipment.php b/app/code/core/Mage/Sales/Model/Order/Shipment.php index b5d769e50af..a1efa699596 100644 --- a/app/code/core/Mage/Sales/Model/Order/Shipment.php +++ b/app/code/core/Mage/Sales/Model/Order/Shipment.php @@ -41,7 +41,6 @@ */ class Mage_Sales_Model_Order_Shipment extends Mage_Sales_Model_Abstract { - public const ENTITY = 'shipment'; /** From 811ee711617b2d98612bef10e86cc2c2ad7f0e8e Mon Sep 17 00:00:00 2001 From: Hans Mackowiak Date: Tue, 2 Jun 2026 17:42:48 +0200 Subject: [PATCH 03/14] ~ move duplicated _getEmails to Mage_Sales_Model_Abstract --- app/code/core/Mage/Sales/Model/Abstract.php | 16 ++++++++++++++++ app/code/core/Mage/Sales/Model/Order.php | 16 ---------------- .../core/Mage/Sales/Model/Order/Creditmemo.php | 15 --------------- app/code/core/Mage/Sales/Model/Order/Invoice.php | 16 ---------------- .../core/Mage/Sales/Model/Order/Shipment.php | 16 ---------------- 5 files changed, 16 insertions(+), 63 deletions(-) diff --git a/app/code/core/Mage/Sales/Model/Abstract.php b/app/code/core/Mage/Sales/Model/Abstract.php index 74b914c0200..6819a96344f 100644 --- a/app/code/core/Mage/Sales/Model/Abstract.php +++ b/app/code/core/Mage/Sales/Model/Abstract.php @@ -17,8 +17,10 @@ * @method bool getForceUpdateGridRecords() * @method Mage_Sales_Model_Resource_Order_Abstract getResource() * @method Mage_Customer_Model_Address_Abstract getShippingAddress() + * @method int getStoreId() * @method $this setBillingAddress(Mage_Customer_Model_Address_Abstract $address) * @method $this setShippingAddress(Mage_Customer_Model_Address_Abstract $address) + * @method $this setStoreId(int $value) * @method $this setTransactionId(int $value) */ abstract class Mage_Sales_Model_Abstract extends Mage_Core_Model_Abstract @@ -83,4 +85,18 @@ protected function getMailer(): Mage_Core_Model_Email_Template_Mailer $mailer = Mage::getModel('core/email_template_mailer'); return $mailer; } + + /** + * @param string $configPath + * @return array|bool + */ + protected function _getEmails($configPath) + { + $data = Mage::getStoreConfig($configPath, $this->getStoreId()); + if (!empty($data)) { + return explode(',', $data); + } + + return false; + } } diff --git a/app/code/core/Mage/Sales/Model/Order.php b/app/code/core/Mage/Sales/Model/Order.php index 6ac61795bf1..f0491e3a377 100644 --- a/app/code/core/Mage/Sales/Model/Order.php +++ b/app/code/core/Mage/Sales/Model/Order.php @@ -153,7 +153,6 @@ * @method string getState() * @method string getStatus() * @method string getStoreCurrencyCode() - * @method int getStoreId() * @method string getStoreName() * @method float getStoreToBaseRate() * @method float getStoreToOrderRate() @@ -302,7 +301,6 @@ * @method $this setShippingTaxRefunded(float $value) * @method $this setStatus(string $value) * @method $this setStoreCurrencyCode(string $value) - * @method $this setStoreId(int $value) * @method $this setStoreName(string $value) * @method $this setStoreToBaseRate(float $value) * @method $this setStoreToOrderRate(float $value) @@ -1593,20 +1591,6 @@ public function sendOrderUpdateEmail($notifyCustomer = true, $comment = '') return $this; } - /** - * @param string $configPath - * @return array|false - */ - protected function _getEmails($configPath) - { - $data = Mage::getStoreConfig($configPath, $this->getStoreId()); - if (!empty($data)) { - return explode(',', $data); - } - - return false; - } - /*********************** ADDRESSES ***************************/ /** diff --git a/app/code/core/Mage/Sales/Model/Order/Creditmemo.php b/app/code/core/Mage/Sales/Model/Order/Creditmemo.php index a4b8f40891d..00634d40e16 100644 --- a/app/code/core/Mage/Sales/Model/Order/Creditmemo.php +++ b/app/code/core/Mage/Sales/Model/Order/Creditmemo.php @@ -114,7 +114,6 @@ * @method $this setShippingTaxAmount(float $value) * @method $this setState(int $value) * @method $this setStoreCurrencyCode(string $value) - * @method $this setStoreId(int $value) * @method $this setStoreToBaseRate(float $value) * @method $this setStoreToOrderRate(float $value) * @method $this setSubtotal(float $value) @@ -962,20 +961,6 @@ public function sendUpdateEmail($notifyCustomer = true, $comment = '') return $this; } - /** - * @param string $configPath - * @return array|bool - */ - protected function _getEmails($configPath) - { - $data = Mage::getStoreConfig($configPath, $this->getStoreId()); - if (!empty($data)) { - return explode(',', $data); - } - - return false; - } - /** * @return $this * @throws Mage_Core_Exception diff --git a/app/code/core/Mage/Sales/Model/Order/Invoice.php b/app/code/core/Mage/Sales/Model/Order/Invoice.php index 0185ae247a9..3f240ddacb1 100644 --- a/app/code/core/Mage/Sales/Model/Order/Invoice.php +++ b/app/code/core/Mage/Sales/Model/Order/Invoice.php @@ -50,7 +50,6 @@ * @method float getShippingTaxAmount() * @method int getState() * @method string getStoreCurrencyCode() - * @method int getStoreId() * @method float getStoreToBaseRate() * @method float getStoreToOrderRate() * @method float getSubtotal() @@ -94,7 +93,6 @@ * @method $this setShippingTaxAmount(float $value) * @method $this setState(int $value) * @method $this setStoreCurrencyCode(string $value) - * @method $this setStoreId(int $value) * @method $this setStoreToBaseRate(float $value) * @method $this setStoreToOrderRate(float $value) * @method $this setSubtotal(float $value) @@ -990,20 +988,6 @@ public function sendUpdateEmail($notifyCustomer = true, $comment = '') return $this; } - /** - * @param string $configPath - * @return array|bool - */ - protected function _getEmails($configPath) - { - $data = Mage::getStoreConfig($configPath, $this->getStoreId()); - if (!empty($data)) { - return explode(',', $data); - } - - return false; - } - /** * @return $this * @throws Mage_Core_Exception diff --git a/app/code/core/Mage/Sales/Model/Order/Shipment.php b/app/code/core/Mage/Sales/Model/Order/Shipment.php index a1efa699596..7e36718a3b5 100644 --- a/app/code/core/Mage/Sales/Model/Order/Shipment.php +++ b/app/code/core/Mage/Sales/Model/Order/Shipment.php @@ -24,7 +24,6 @@ * @method Mage_Sales_Model_Resource_Order_Shipment_Collection getResourceCollection() * @method int getShipmentStatus() * @method int getShippingAddressId() - * @method int getStoreId() * @method float getTotalQty() * @method float getTotalWeight() * @method $this setBillingAddressId(int $value) @@ -35,7 +34,6 @@ * @method $this setPackages(string $value) * @method $this setShipmentStatus(int $value) * @method $this setShippingAddressId(int $value) - * @method $this setStoreId(int $value) * @method $this setTotalQty(float $value) * @method $this setTotalWeight(float $value) */ @@ -617,20 +615,6 @@ public function sendUpdateEmail($notifyCustomer = true, $comment = '') return $this; } - /** - * @param string $configPath - * @return array|false - */ - protected function _getEmails($configPath) - { - $data = Mage::getStoreConfig($configPath, $this->getStoreId()); - if (!empty($data)) { - return explode(',', $data); - } - - return false; - } - /** * Before object save * From 7236ed634fb6d3eb9fdd9805364170f16473b0a8 Mon Sep 17 00:00:00 2001 From: Hans Mackowiak Date: Tue, 2 Jun 2026 18:00:42 +0200 Subject: [PATCH 04/14] ~ phpstan --- app/code/core/Mage/Sales/Model/Abstract.php | 2 +- app/code/core/Mage/Sales/Model/Order.php | 10 +++++----- app/code/core/Mage/Sales/Model/Order/Creditmemo.php | 12 ++++++------ app/code/core/Mage/Sales/Model/Order/Invoice.php | 12 ++++++------ app/code/core/Mage/Sales/Model/Order/Shipment.php | 12 ++++++------ 5 files changed, 24 insertions(+), 24 deletions(-) diff --git a/app/code/core/Mage/Sales/Model/Abstract.php b/app/code/core/Mage/Sales/Model/Abstract.php index 6819a96344f..385fb460d19 100644 --- a/app/code/core/Mage/Sales/Model/Abstract.php +++ b/app/code/core/Mage/Sales/Model/Abstract.php @@ -88,7 +88,7 @@ protected function getMailer(): Mage_Core_Model_Email_Template_Mailer /** * @param string $configPath - * @return array|bool + * @return list|false */ protected function _getEmails($configPath) { diff --git a/app/code/core/Mage/Sales/Model/Order.php b/app/code/core/Mage/Sales/Model/Order.php index f0491e3a377..9bb8024c535 100644 --- a/app/code/core/Mage/Sales/Model/Order.php +++ b/app/code/core/Mage/Sales/Model/Order.php @@ -1443,7 +1443,7 @@ public function queueNewOrderEmail($forceMode = false) /** @var Mage_Core_Model_Email_Info $emailInfo */ $emailInfo = Mage::getModel('core/email_info'); $emailInfo->addTo($this->getCurrentCustomerEmail(), $customerName); - if ($copyTo && $copyMethod == 'bcc') { + if (is_array($copyTo) && $copyMethod == 'bcc') { // Add bcc to customer email foreach ($copyTo as $email) { $emailInfo->addBcc($email); @@ -1453,7 +1453,7 @@ public function queueNewOrderEmail($forceMode = false) $mailer->addEmailInfo($emailInfo); // Email copies are sent as separated emails if their copy method is 'copy' - if ($copyTo && $copyMethod == 'copy') { + if (is_array($copyTo) && $copyMethod == 'copy') { foreach ($copyTo as $email) { $emailInfo = Mage::getModel('core/email_info'); $emailInfo->addTo($email); @@ -1518,7 +1518,7 @@ public function queueOrderUpdateEmail($notifyCustomer = true, $comment = '', $fo $copyTo = $this->_getEmails(self::XML_PATH_UPDATE_EMAIL_COPY_TO); $copyMethod = Mage::getStoreConfig(self::XML_PATH_UPDATE_EMAIL_COPY_METHOD, $storeId); // Check if at least one recipient is found - if (!$notifyCustomer && !$copyTo) { + if (!$notifyCustomer && $copyTo === false) { return $this; } @@ -1536,7 +1536,7 @@ public function queueOrderUpdateEmail($notifyCustomer = true, $comment = '', $fo /** @var Mage_Core_Model_Email_Info $emailInfo */ $emailInfo = Mage::getModel('core/email_info'); $emailInfo->addTo($this->getCurrentCustomerEmail(), $customerName); - if ($copyTo && $copyMethod == 'bcc') { + if (is_array($copyTo) && $copyMethod == 'bcc') { // Add bcc to customer email foreach ($copyTo as $email) { $emailInfo->addBcc($email); @@ -1548,7 +1548,7 @@ public function queueOrderUpdateEmail($notifyCustomer = true, $comment = '', $fo // Email copies are sent as separated emails if their copy method is // 'copy' or a customer should not be notified - if ($copyTo && ($copyMethod == 'copy' || !$notifyCustomer)) { + if (is_array($copyTo) && ($copyMethod == 'copy' || !$notifyCustomer)) { foreach ($copyTo as $email) { $emailInfo = Mage::getModel('core/email_info'); $emailInfo->addTo($email); diff --git a/app/code/core/Mage/Sales/Model/Order/Creditmemo.php b/app/code/core/Mage/Sales/Model/Order/Creditmemo.php index 00634d40e16..747cb23008d 100644 --- a/app/code/core/Mage/Sales/Model/Order/Creditmemo.php +++ b/app/code/core/Mage/Sales/Model/Order/Creditmemo.php @@ -790,7 +790,7 @@ public function sendEmail($notifyCustomer = true, $comment = '') $copyTo = $this->_getEmails(self::XML_PATH_EMAIL_COPY_TO); $copyMethod = Mage::getStoreConfig(self::XML_PATH_EMAIL_COPY_METHOD, $storeId); // Check if at least one recipient is found - if (!$notifyCustomer && !$copyTo) { + if (!$notifyCustomer && $copyTo === false) { return $this; } @@ -833,7 +833,7 @@ public function sendEmail($notifyCustomer = true, $comment = '') if ($notifyCustomer) { $emailInfo = Mage::getModel('core/email_info'); $emailInfo->addTo($order->getCurrentCustomerEmail(), $customerName); - if ($copyTo && $copyMethod === 'bcc') { + if (is_array($copyTo) && $copyMethod === 'bcc') { // Add bcc to customer email foreach ($copyTo as $email) { $emailInfo->addBcc($email); @@ -844,7 +844,7 @@ public function sendEmail($notifyCustomer = true, $comment = '') } // Email copies are sent as separated emails if their copy method is 'copy' or a customer should not be notified - if ($copyTo && ($copyMethod === 'copy' || !$notifyCustomer)) { + if (is_array($copyTo) && ($copyMethod === 'copy' || !$notifyCustomer)) { foreach ($copyTo as $email) { $emailInfo = Mage::getModel('core/email_info'); $emailInfo->addTo($email); @@ -902,7 +902,7 @@ public function sendUpdateEmail($notifyCustomer = true, $comment = '') $copyTo = $this->_getEmails(self::XML_PATH_UPDATE_EMAIL_COPY_TO); $copyMethod = Mage::getStoreConfig(self::XML_PATH_UPDATE_EMAIL_COPY_METHOD, $storeId); // Check if at least one recipient is found - if (!$notifyCustomer && !$copyTo) { + if (!$notifyCustomer && $copyTo === false) { return $this; } @@ -919,7 +919,7 @@ public function sendUpdateEmail($notifyCustomer = true, $comment = '') if ($notifyCustomer) { $emailInfo = Mage::getModel('core/email_info'); $emailInfo->addTo($order->getCurrentCustomerEmail(), $customerName); - if ($copyTo && $copyMethod === 'bcc') { + if (is_array($copyTo) && $copyMethod === 'bcc') { // Add bcc to customer email foreach ($copyTo as $email) { $emailInfo->addBcc($email); @@ -930,7 +930,7 @@ public function sendUpdateEmail($notifyCustomer = true, $comment = '') } // Email copies are sent as separated emails if their copy method is 'copy' or a customer should not be notified - if ($copyTo && ($copyMethod === 'copy' || !$notifyCustomer)) { + if (is_array($copyTo) && ($copyMethod === 'copy' || !$notifyCustomer)) { foreach ($copyTo as $email) { $emailInfo = Mage::getModel('core/email_info'); $emailInfo->addTo($email); diff --git a/app/code/core/Mage/Sales/Model/Order/Invoice.php b/app/code/core/Mage/Sales/Model/Order/Invoice.php index 3f240ddacb1..2403964d63a 100644 --- a/app/code/core/Mage/Sales/Model/Order/Invoice.php +++ b/app/code/core/Mage/Sales/Model/Order/Invoice.php @@ -818,7 +818,7 @@ public function sendEmail($notifyCustomer = true, $comment = '') $copyTo = $this->_getEmails(self::XML_PATH_EMAIL_COPY_TO); $copyMethod = Mage::getStoreConfig(self::XML_PATH_EMAIL_COPY_METHOD, $storeId); // Check if at least one recipient is found - if (!$notifyCustomer && !$copyTo) { + if (!$notifyCustomer && $copyTo === false) { return $this; } @@ -861,7 +861,7 @@ public function sendEmail($notifyCustomer = true, $comment = '') if ($notifyCustomer) { $emailInfo = Mage::getModel('core/email_info'); $emailInfo->addTo($order->getCurrentCustomerEmail(), $customerName); - if ($copyTo && $copyMethod == 'bcc') { + if (is_array($copyTo) && $copyMethod == 'bcc') { // Add bcc to customer email foreach ($copyTo as $email) { $emailInfo->addBcc($email); @@ -872,7 +872,7 @@ public function sendEmail($notifyCustomer = true, $comment = '') } // Email copies are sent as separated emails if their copy method is 'copy' or a customer should not be notified - if ($copyTo && ($copyMethod == 'copy' || !$notifyCustomer)) { + if (is_array($copyTo) && ($copyMethod == 'copy' || !$notifyCustomer)) { foreach ($copyTo as $email) { $emailInfo = Mage::getModel('core/email_info'); $emailInfo->addTo($email); @@ -929,7 +929,7 @@ public function sendUpdateEmail($notifyCustomer = true, $comment = '') $copyTo = $this->_getEmails(self::XML_PATH_UPDATE_EMAIL_COPY_TO); $copyMethod = Mage::getStoreConfig(self::XML_PATH_UPDATE_EMAIL_COPY_METHOD, $storeId); // Check if at least one recipient is found - if (!$notifyCustomer && !$copyTo) { + if (!$notifyCustomer && $copyTo === false) { return $this; } @@ -946,7 +946,7 @@ public function sendUpdateEmail($notifyCustomer = true, $comment = '') if ($notifyCustomer) { $emailInfo = Mage::getModel('core/email_info'); $emailInfo->addTo($order->getCurrentCustomerEmail(), $customerName); - if ($copyTo && $copyMethod == 'bcc') { + if (is_array($copyTo) && $copyMethod == 'bcc') { // Add bcc to customer email foreach ($copyTo as $email) { $emailInfo->addBcc($email); @@ -957,7 +957,7 @@ public function sendUpdateEmail($notifyCustomer = true, $comment = '') } // Email copies are sent as separated emails if their copy method is 'copy' or a customer should not be notified - if ($copyTo && ($copyMethod == 'copy' || !$notifyCustomer)) { + if (is_array($copyTo) && ($copyMethod == 'copy' || !$notifyCustomer)) { foreach ($copyTo as $email) { $emailInfo = Mage::getModel('core/email_info'); $emailInfo->addTo($email); diff --git a/app/code/core/Mage/Sales/Model/Order/Shipment.php b/app/code/core/Mage/Sales/Model/Order/Shipment.php index 7e36718a3b5..21595557a2b 100644 --- a/app/code/core/Mage/Sales/Model/Order/Shipment.php +++ b/app/code/core/Mage/Sales/Model/Order/Shipment.php @@ -450,7 +450,7 @@ public function sendEmail($notifyCustomer = true, $comment = '') $copyTo = $this->_getEmails(self::XML_PATH_EMAIL_COPY_TO); $copyMethod = Mage::getStoreConfig(self::XML_PATH_EMAIL_COPY_METHOD, $storeId); // Check if at least one recipient is found - if (!$notifyCustomer && !$copyTo) { + if (!$notifyCustomer && $copyTo === false) { return $this; } @@ -493,7 +493,7 @@ public function sendEmail($notifyCustomer = true, $comment = '') if ($notifyCustomer) { $emailInfo = Mage::getModel('core/email_info'); $emailInfo->addTo($order->getCurrentCustomerEmail(), $customerName); - if ($copyTo && $copyMethod == 'bcc') { + if (is_array($copyTo) && $copyMethod == 'bcc') { // Add bcc to customer email foreach ($copyTo as $email) { $emailInfo->addBcc($email); @@ -504,7 +504,7 @@ public function sendEmail($notifyCustomer = true, $comment = '') } // Email copies are sent as separated emails if their copy method is 'copy' or a customer should not be notified - if ($copyTo && ($copyMethod == 'copy' || !$notifyCustomer)) { + if (is_array($copyTo) && ($copyMethod == 'copy' || !$notifyCustomer)) { foreach ($copyTo as $email) { $emailInfo = Mage::getModel('core/email_info'); $emailInfo->addTo($email); @@ -556,7 +556,7 @@ public function sendUpdateEmail($notifyCustomer = true, $comment = '') $copyTo = $this->_getEmails(self::XML_PATH_UPDATE_EMAIL_COPY_TO); $copyMethod = Mage::getStoreConfig(self::XML_PATH_UPDATE_EMAIL_COPY_METHOD, $storeId); // Check if at least one recipient is found - if (!$notifyCustomer && !$copyTo) { + if (!$notifyCustomer && $copyTo === false) { return $this; } @@ -573,7 +573,7 @@ public function sendUpdateEmail($notifyCustomer = true, $comment = '') if ($notifyCustomer) { $emailInfo = Mage::getModel('core/email_info'); $emailInfo->addTo($order->getCurrentCustomerEmail(), $customerName); - if ($copyTo && $copyMethod == 'bcc') { + if (is_array($copyTo) && $copyMethod == 'bcc') { // Add bcc to customer email foreach ($copyTo as $email) { $emailInfo->addBcc($email); @@ -584,7 +584,7 @@ public function sendUpdateEmail($notifyCustomer = true, $comment = '') } // Email copies are sent as separated emails if their copy method is 'copy' or a customer should not be notified - if ($copyTo && ($copyMethod == 'copy' || !$notifyCustomer)) { + if (is_array($copyTo) && ($copyMethod == 'copy' || !$notifyCustomer)) { foreach ($copyTo as $email) { $emailInfo = Mage::getModel('core/email_info'); $emailInfo->addTo($email); From ab1b5e2511f1f75aa82b63f0bcc77478638a87c7 Mon Sep 17 00:00:00 2001 From: Hans Mackowiak Date: Wed, 3 Jun 2026 10:02:40 +0200 Subject: [PATCH 05/14] ~ use finally for stopEnvironmentEmulation --- app/code/core/Mage/Payment/Block/Info.php | 6 ++++-- app/code/core/Mage/Payment/Helper/Data.php | 4 ++-- app/code/core/Mage/Sales/Model/Abstract.php | 6 +++--- app/code/core/Mage/Sales/Model/Order.php | 11 ++--------- app/code/core/Mage/Sales/Model/Order/Creditmemo.php | 13 +++---------- app/code/core/Mage/Sales/Model/Order/Invoice.php | 13 +++---------- app/code/core/Mage/Sales/Model/Order/Shipment.php | 13 +++---------- 7 files changed, 20 insertions(+), 46 deletions(-) diff --git a/app/code/core/Mage/Payment/Block/Info.php b/app/code/core/Mage/Payment/Block/Info.php index 29c181a34bf..22c61530ee1 100644 --- a/app/code/core/Mage/Payment/Block/Info.php +++ b/app/code/core/Mage/Payment/Block/Info.php @@ -8,11 +8,13 @@ */ /** - * Base payment iformation block + * Base payment information block * * @package Mage_Payment * - * @method bool hasIsSecureMode() + * @method bool hasIsSecureMode() + * @method $this setIsSecureMode(bool $val) + * @method $this setInfo(Mage_Payment_Model_Info $info) */ class Mage_Payment_Block_Info extends Mage_Core_Block_Template { diff --git a/app/code/core/Mage/Payment/Helper/Data.php b/app/code/core/Mage/Payment/Helper/Data.php index 3db90cf190b..18427bf5817 100644 --- a/app/code/core/Mage/Payment/Helper/Data.php +++ b/app/code/core/Mage/Payment/Helper/Data.php @@ -125,7 +125,7 @@ public function getMethodFormBlock(Mage_Payment_Model_Method_Abstract $method) /** * Retrieve payment information block * - * @return Mage_Core_Block_Abstract + * @return Mage_Payment_Block_Info * @throws Mage_Core_Exception */ public function getInfoBlock(Mage_Payment_Model_Info $info) @@ -138,7 +138,7 @@ public function getInfoBlock(Mage_Payment_Model_Info $info) $block = new $className(); } - /** @var Mage_Core_Block_Abstract $block */ + /** @var Mage_Payment_Block_Info $block */ $block->setInfo($info); return $block; } diff --git a/app/code/core/Mage/Sales/Model/Abstract.php b/app/code/core/Mage/Sales/Model/Abstract.php index 385fb460d19..992147da3b9 100644 --- a/app/code/core/Mage/Sales/Model/Abstract.php +++ b/app/code/core/Mage/Sales/Model/Abstract.php @@ -87,13 +87,13 @@ protected function getMailer(): Mage_Core_Model_Email_Template_Mailer } /** - * @param string $configPath - * @return list|false + * @param string $configPath + * @return false|list */ protected function _getEmails($configPath) { $data = Mage::getStoreConfig($configPath, $this->getStoreId()); - if (!empty($data)) { + if (is_string($data) && $data !== '') { return explode(',', $data); } diff --git a/app/code/core/Mage/Sales/Model/Order.php b/app/code/core/Mage/Sales/Model/Order.php index 9bb8024c535..49a3c3eb1a9 100644 --- a/app/code/core/Mage/Sales/Model/Order.php +++ b/app/code/core/Mage/Sales/Model/Order.php @@ -1416,18 +1416,11 @@ public function queueNewOrderEmail($forceMode = false) ->setIsSecureMode(true); $paymentBlock->getMethod()->setStore($storeId); $paymentBlockHtml = $paymentBlock->toHtml(); - } catch (Exception $exception) { + } finally { // Stop store emulation process if (isset($appEmulation, $initialEnvironmentInfo)) { $appEmulation->stopEnvironmentEmulation($initialEnvironmentInfo); } - - throw $exception; - } - - // Stop store emulation process - if (isset($appEmulation, $initialEnvironmentInfo)) { - $appEmulation->stopEnvironmentEmulation($initialEnvironmentInfo); } // Retrieve corresponding email template id and customer name @@ -1518,7 +1511,7 @@ public function queueOrderUpdateEmail($notifyCustomer = true, $comment = '', $fo $copyTo = $this->_getEmails(self::XML_PATH_UPDATE_EMAIL_COPY_TO); $copyMethod = Mage::getStoreConfig(self::XML_PATH_UPDATE_EMAIL_COPY_METHOD, $storeId); // Check if at least one recipient is found - if (!$notifyCustomer && $copyTo === false) { + if (!$notifyCustomer && !is_array($copyTo)) { return $this; } diff --git a/app/code/core/Mage/Sales/Model/Order/Creditmemo.php b/app/code/core/Mage/Sales/Model/Order/Creditmemo.php index 747cb23008d..9bd05ece76a 100644 --- a/app/code/core/Mage/Sales/Model/Order/Creditmemo.php +++ b/app/code/core/Mage/Sales/Model/Order/Creditmemo.php @@ -790,7 +790,7 @@ public function sendEmail($notifyCustomer = true, $comment = '') $copyTo = $this->_getEmails(self::XML_PATH_EMAIL_COPY_TO); $copyMethod = Mage::getStoreConfig(self::XML_PATH_EMAIL_COPY_METHOD, $storeId); // Check if at least one recipient is found - if (!$notifyCustomer && $copyTo === false) { + if (!$notifyCustomer && !is_array($copyTo)) { return $this; } @@ -806,18 +806,11 @@ public function sendEmail($notifyCustomer = true, $comment = '') ->setIsSecureMode(true); $paymentBlock->getMethod()->setStore($storeId); $paymentBlockHtml = $paymentBlock->toHtml(); - } catch (Exception $exception) { + } finally { // Stop store emulation process if (isset($appEmulation, $initialEnvironmentInfo)) { $appEmulation->stopEnvironmentEmulation($initialEnvironmentInfo); } - - throw $exception; - } - - // Stop store emulation process - if (isset($appEmulation, $initialEnvironmentInfo)) { - $appEmulation->stopEnvironmentEmulation($initialEnvironmentInfo); } // Retrieve corresponding email template id and customer name @@ -902,7 +895,7 @@ public function sendUpdateEmail($notifyCustomer = true, $comment = '') $copyTo = $this->_getEmails(self::XML_PATH_UPDATE_EMAIL_COPY_TO); $copyMethod = Mage::getStoreConfig(self::XML_PATH_UPDATE_EMAIL_COPY_METHOD, $storeId); // Check if at least one recipient is found - if (!$notifyCustomer && $copyTo === false) { + if (!$notifyCustomer && !is_array($copyTo)) { return $this; } diff --git a/app/code/core/Mage/Sales/Model/Order/Invoice.php b/app/code/core/Mage/Sales/Model/Order/Invoice.php index 2403964d63a..f5c1835d381 100644 --- a/app/code/core/Mage/Sales/Model/Order/Invoice.php +++ b/app/code/core/Mage/Sales/Model/Order/Invoice.php @@ -818,7 +818,7 @@ public function sendEmail($notifyCustomer = true, $comment = '') $copyTo = $this->_getEmails(self::XML_PATH_EMAIL_COPY_TO); $copyMethod = Mage::getStoreConfig(self::XML_PATH_EMAIL_COPY_METHOD, $storeId); // Check if at least one recipient is found - if (!$notifyCustomer && $copyTo === false) { + if (!$notifyCustomer && !is_array($copyTo)) { return $this; } @@ -834,18 +834,11 @@ public function sendEmail($notifyCustomer = true, $comment = '') ->setIsSecureMode(true); $paymentBlock->getMethod()->setStore($storeId); $paymentBlockHtml = $paymentBlock->toHtml(); - } catch (Exception $exception) { + } finally { // Stop store emulation process if (isset($appEmulation, $initialEnvironmentInfo)) { $appEmulation->stopEnvironmentEmulation($initialEnvironmentInfo); } - - throw $exception; - } - - // Stop store emulation process - if (isset($appEmulation, $initialEnvironmentInfo)) { - $appEmulation->stopEnvironmentEmulation($initialEnvironmentInfo); } // Retrieve corresponding email template id and customer name @@ -929,7 +922,7 @@ public function sendUpdateEmail($notifyCustomer = true, $comment = '') $copyTo = $this->_getEmails(self::XML_PATH_UPDATE_EMAIL_COPY_TO); $copyMethod = Mage::getStoreConfig(self::XML_PATH_UPDATE_EMAIL_COPY_METHOD, $storeId); // Check if at least one recipient is found - if (!$notifyCustomer && $copyTo === false) { + if (!$notifyCustomer && !is_array($copyTo)) { return $this; } diff --git a/app/code/core/Mage/Sales/Model/Order/Shipment.php b/app/code/core/Mage/Sales/Model/Order/Shipment.php index 21595557a2b..7b5bdccc3b4 100644 --- a/app/code/core/Mage/Sales/Model/Order/Shipment.php +++ b/app/code/core/Mage/Sales/Model/Order/Shipment.php @@ -450,7 +450,7 @@ public function sendEmail($notifyCustomer = true, $comment = '') $copyTo = $this->_getEmails(self::XML_PATH_EMAIL_COPY_TO); $copyMethod = Mage::getStoreConfig(self::XML_PATH_EMAIL_COPY_METHOD, $storeId); // Check if at least one recipient is found - if (!$notifyCustomer && $copyTo === false) { + if (!$notifyCustomer && !is_array($copyTo)) { return $this; } @@ -466,18 +466,11 @@ public function sendEmail($notifyCustomer = true, $comment = '') ->setIsSecureMode(true); $paymentBlock->getMethod()->setStore($storeId); $paymentBlockHtml = $paymentBlock->toHtml(); - } catch (Exception $exception) { + } finally { // Stop store emulation process if (isset($appEmulation, $initialEnvironmentInfo)) { $appEmulation->stopEnvironmentEmulation($initialEnvironmentInfo); } - - throw $exception; - } - - // Stop store emulation process - if (isset($appEmulation, $initialEnvironmentInfo)) { - $appEmulation->stopEnvironmentEmulation($initialEnvironmentInfo); } // Retrieve corresponding email template id and customer name @@ -556,7 +549,7 @@ public function sendUpdateEmail($notifyCustomer = true, $comment = '') $copyTo = $this->_getEmails(self::XML_PATH_UPDATE_EMAIL_COPY_TO); $copyMethod = Mage::getStoreConfig(self::XML_PATH_UPDATE_EMAIL_COPY_METHOD, $storeId); // Check if at least one recipient is found - if (!$notifyCustomer && $copyTo === false) { + if (!$notifyCustomer && !is_array($copyTo)) { return $this; } From 80618b05298c07f9933b56a5df5f6135dc62e9e4 Mon Sep 17 00:00:00 2001 From: Hans Mackowiak Date: Wed, 3 Jun 2026 10:32:20 +0200 Subject: [PATCH 06/14] ~ phpstan --- .../booleanAnd.leftNotBoolean.php | 20 --------------- .../booleanNot.exprNotBoolean.php | 20 --------------- .phpstan.dist.baselines/empty.notAllowed.php | 17 +------------ .../foreach.nonIterable.php | 5 ---- .../missingType.iterableValue.php | 25 ------------------- app/code/core/Mage/Checkout/Helper/Data.php | 13 +++++----- app/code/core/Mage/Payment/Block/Info.php | 2 +- .../core/Mage/Sales/Model/Order/Invoice.php | 4 +-- .../core/Mage/Sales/Model/Order/Shipment.php | 2 +- 9 files changed, 12 insertions(+), 96 deletions(-) diff --git a/.phpstan.dist.baselines/booleanAnd.leftNotBoolean.php b/.phpstan.dist.baselines/booleanAnd.leftNotBoolean.php index 501368db3a1..586337b6179 100644 --- a/.phpstan.dist.baselines/booleanAnd.leftNotBoolean.php +++ b/.phpstan.dist.baselines/booleanAnd.leftNotBoolean.php @@ -1916,31 +1916,16 @@ 'count' => 2, 'path' => __DIR__ . '/../app/code/core/Mage/Sales/Model/Order.php', ]; -$ignoreErrors[] = [ - 'rawMessage' => 'Only booleans are allowed in &&, array|false given on the left side.', - 'count' => 4, - 'path' => __DIR__ . '/../app/code/core/Mage/Sales/Model/Order.php', -]; $ignoreErrors[] = [ 'rawMessage' => 'Only booleans are allowed in &&, null given on the left side.', 'count' => 1, 'path' => __DIR__ . '/../app/code/core/Mage/Sales/Model/Order/Config.php', ]; -$ignoreErrors[] = [ - 'rawMessage' => 'Only booleans are allowed in &&, array|bool given on the left side.', - 'count' => 4, - 'path' => __DIR__ . '/../app/code/core/Mage/Sales/Model/Order/Creditmemo.php', -]; $ignoreErrors[] = [ 'rawMessage' => 'Only booleans are allowed in &&, float given on the left side.', 'count' => 1, 'path' => __DIR__ . '/../app/code/core/Mage/Sales/Model/Order/Creditmemo/Total/Discount.php', ]; -$ignoreErrors[] = [ - 'rawMessage' => 'Only booleans are allowed in &&, array|bool given on the left side.', - 'count' => 4, - 'path' => __DIR__ . '/../app/code/core/Mage/Sales/Model/Order/Invoice.php', -]; $ignoreErrors[] = [ 'rawMessage' => 'Only booleans are allowed in &&, float given on the left side.', 'count' => 1, @@ -1991,11 +1976,6 @@ 'count' => 1, 'path' => __DIR__ . '/../app/code/core/Mage/Sales/Model/Order/Payment/Transaction.php', ]; -$ignoreErrors[] = [ - 'rawMessage' => 'Only booleans are allowed in &&, array|false given on the left side.', - 'count' => 4, - 'path' => __DIR__ . '/../app/code/core/Mage/Sales/Model/Order/Shipment.php', -]; $ignoreErrors[] = [ 'rawMessage' => 'Only booleans are allowed in &&, int|string|null given on the left side.', 'count' => 1, diff --git a/.phpstan.dist.baselines/booleanNot.exprNotBoolean.php b/.phpstan.dist.baselines/booleanNot.exprNotBoolean.php index 0977686bf4f..a85de1e0b66 100644 --- a/.phpstan.dist.baselines/booleanNot.exprNotBoolean.php +++ b/.phpstan.dist.baselines/booleanNot.exprNotBoolean.php @@ -5751,11 +5751,6 @@ 'count' => 1, 'path' => __DIR__ . '/../app/code/core/Mage/Sales/Model/Order.php', ]; -$ignoreErrors[] = [ - 'rawMessage' => 'Only booleans are allowed in a negated boolean, array|false given.', - 'count' => 1, - 'path' => __DIR__ . '/../app/code/core/Mage/Sales/Model/Order.php', -]; $ignoreErrors[] = [ 'rawMessage' => 'Only booleans are allowed in a negated boolean, int|string|null given.', 'count' => 8, @@ -5776,11 +5771,6 @@ 'count' => 1, 'path' => __DIR__ . '/../app/code/core/Mage/Sales/Model/Order/Api.php', ]; -$ignoreErrors[] = [ - 'rawMessage' => 'Only booleans are allowed in a negated boolean, array|bool given.', - 'count' => 2, - 'path' => __DIR__ . '/../app/code/core/Mage/Sales/Model/Order/Creditmemo.php', -]; $ignoreErrors[] = [ 'rawMessage' => 'Only booleans are allowed in a negated boolean, int|string|null given.', 'count' => 1, @@ -5796,11 +5786,6 @@ 'count' => 1, 'path' => __DIR__ . '/../app/code/core/Mage/Sales/Model/Order/Creditmemo/Item.php', ]; -$ignoreErrors[] = [ - 'rawMessage' => 'Only booleans are allowed in a negated boolean, array|bool given.', - 'count' => 2, - 'path' => __DIR__ . '/../app/code/core/Mage/Sales/Model/Order/Invoice.php', -]; $ignoreErrors[] = [ 'rawMessage' => 'Only booleans are allowed in a negated boolean, int|string|null given.', 'count' => 1, @@ -5896,11 +5881,6 @@ 'count' => 3, 'path' => __DIR__ . '/../app/code/core/Mage/Sales/Model/Order/Payment/Transaction.php', ]; -$ignoreErrors[] = [ - 'rawMessage' => 'Only booleans are allowed in a negated boolean, array|false given.', - 'count' => 2, - 'path' => __DIR__ . '/../app/code/core/Mage/Sales/Model/Order/Shipment.php', -]; $ignoreErrors[] = [ 'rawMessage' => 'Only booleans are allowed in a negated boolean, int<0, max> given.', 'count' => 1, diff --git a/.phpstan.dist.baselines/empty.notAllowed.php b/.phpstan.dist.baselines/empty.notAllowed.php index f19a68924cd..f208a1bad18 100644 --- a/.phpstan.dist.baselines/empty.notAllowed.php +++ b/.phpstan.dist.baselines/empty.notAllowed.php @@ -2648,7 +2648,7 @@ ]; $ignoreErrors[] = [ 'rawMessage' => 'Construct empty() is not allowed. Use more strict comparison.', - 'count' => 8, + 'count' => 7, 'path' => __DIR__ . '/../app/code/core/Mage/Sales/Model/Order.php', ]; $ignoreErrors[] = [ @@ -2656,21 +2656,11 @@ 'count' => 1, 'path' => __DIR__ . '/../app/code/core/Mage/Sales/Model/Order/Config.php', ]; -$ignoreErrors[] = [ - 'rawMessage' => 'Construct empty() is not allowed. Use more strict comparison.', - 'count' => 1, - 'path' => __DIR__ . '/../app/code/core/Mage/Sales/Model/Order/Creditmemo.php', -]; $ignoreErrors[] = [ 'rawMessage' => 'Construct empty() is not allowed. Use more strict comparison.', 'count' => 1, 'path' => __DIR__ . '/../app/code/core/Mage/Sales/Model/Order/Creditmemo/Api.php', ]; -$ignoreErrors[] = [ - 'rawMessage' => 'Construct empty() is not allowed. Use more strict comparison.', - 'count' => 3, - 'path' => __DIR__ . '/../app/code/core/Mage/Sales/Model/Order/Invoice.php', -]; $ignoreErrors[] = [ 'rawMessage' => 'Construct empty() is not allowed. Use more strict comparison.', 'count' => 3, @@ -2696,11 +2686,6 @@ 'count' => 1, 'path' => __DIR__ . '/../app/code/core/Mage/Sales/Model/Order/Pdf/Shipment.php', ]; -$ignoreErrors[] = [ - 'rawMessage' => 'Construct empty() is not allowed. Use more strict comparison.', - 'count' => 2, - 'path' => __DIR__ . '/../app/code/core/Mage/Sales/Model/Order/Shipment.php', -]; $ignoreErrors[] = [ 'rawMessage' => 'Construct empty() is not allowed. Use more strict comparison.', 'count' => 1, diff --git a/.phpstan.dist.baselines/foreach.nonIterable.php b/.phpstan.dist.baselines/foreach.nonIterable.php index ae5aed2efd2..b5cae857a0e 100644 --- a/.phpstan.dist.baselines/foreach.nonIterable.php +++ b/.phpstan.dist.baselines/foreach.nonIterable.php @@ -516,11 +516,6 @@ 'count' => 4, 'path' => __DIR__ . '/../app/code/core/Mage/Sales/Model/Order/Creditmemo.php', ]; -$ignoreErrors[] = [ - 'rawMessage' => 'Argument of an invalid type array|true supplied for foreach, only iterables are supported.', - 'count' => 4, - 'path' => __DIR__ . '/../app/code/core/Mage/Sales/Model/Order/Invoice.php', -]; $ignoreErrors[] = [ 'rawMessage' => 'Argument of an invalid type (iterable&Mage_Sales_Model_Resource_Order_Creditmemo_Collection)|false supplied for foreach, only iterables are supported.', 'count' => 1, diff --git a/.phpstan.dist.baselines/missingType.iterableValue.php b/.phpstan.dist.baselines/missingType.iterableValue.php index cc25fc2958c..984423fdeaa 100644 --- a/.phpstan.dist.baselines/missingType.iterableValue.php +++ b/.phpstan.dist.baselines/missingType.iterableValue.php @@ -10486,11 +10486,6 @@ 'count' => 1, 'path' => __DIR__ . '/../app/code/core/Mage/Checkout/Helper/Cart.php', ]; -$ignoreErrors[] = [ - 'rawMessage' => 'Method Mage_Checkout_Helper_Data::_getEmails() return type has no value type specified in iterable type array.', - 'count' => 1, - 'path' => __DIR__ . '/../app/code/core/Mage/Checkout/Helper/Data.php', -]; $ignoreErrors[] = [ 'rawMessage' => 'Method Mage_Checkout_Helper_Data::getRequiredAgreementIds() return type has no value type specified in iterable type array.', 'count' => 1, @@ -21836,11 +21831,6 @@ 'count' => 1, 'path' => __DIR__ . '/../app/code/core/Mage/Sales/Model/Order.php', ]; -$ignoreErrors[] = [ - 'rawMessage' => 'Method Mage_Sales_Model_Order::_getEmails() return type has no value type specified in iterable type array.', - 'count' => 1, - 'path' => __DIR__ . '/../app/code/core/Mage/Sales/Model/Order.php', -]; $ignoreErrors[] = [ 'rawMessage' => 'Method Mage_Sales_Model_Order::getItemsCollection() has parameter $filterByTypes with no value type specified in iterable type array.', 'count' => 1, @@ -21921,11 +21911,6 @@ 'count' => 1, 'path' => __DIR__ . '/../app/code/core/Mage/Sales/Model/Order/Config.php', ]; -$ignoreErrors[] = [ - 'rawMessage' => 'Method Mage_Sales_Model_Order_Creditmemo::_getEmails() return type has no value type specified in iterable type array.', - 'count' => 1, - 'path' => __DIR__ . '/../app/code/core/Mage/Sales/Model/Order/Creditmemo.php', -]; $ignoreErrors[] = [ 'rawMessage' => 'Method Mage_Sales_Model_Order_Creditmemo::getFilteredCollectionItems() has parameter $filter with no value type specified in iterable type array.', 'count' => 1, @@ -21991,11 +21976,6 @@ 'count' => 1, 'path' => __DIR__ . '/../app/code/core/Mage/Sales/Model/Order/Creditmemo/Api/V2.php', ]; -$ignoreErrors[] = [ - 'rawMessage' => 'Method Mage_Sales_Model_Order_Invoice::_getEmails() return type has no value type specified in iterable type array.', - 'count' => 1, - 'path' => __DIR__ . '/../app/code/core/Mage/Sales/Model/Order/Invoice.php', -]; $ignoreErrors[] = [ 'rawMessage' => 'Method Mage_Sales_Model_Order_Invoice::getStates() return type has no value type specified in iterable type array.', 'count' => 1, @@ -22246,11 +22226,6 @@ 'count' => 1, 'path' => __DIR__ . '/../app/code/core/Mage/Sales/Model/Order/Pdf/Total/Default.php', ]; -$ignoreErrors[] = [ - 'rawMessage' => 'Method Mage_Sales_Model_Order_Shipment::_getEmails() return type has no value type specified in iterable type array.', - 'count' => 1, - 'path' => __DIR__ . '/../app/code/core/Mage/Sales/Model/Order/Shipment.php', -]; $ignoreErrors[] = [ 'rawMessage' => 'Method Mage_Sales_Model_Order_Shipment_Api::_getCarriers() return type has no value type specified in iterable type array.', 'count' => 1, diff --git a/app/code/core/Mage/Checkout/Helper/Data.php b/app/code/core/Mage/Checkout/Helper/Data.php index 294bf962ffd..a12df9d7915 100644 --- a/app/code/core/Mage/Checkout/Helper/Data.php +++ b/app/code/core/Mage/Checkout/Helper/Data.php @@ -11,6 +11,7 @@ * Checkout default helper * * @package Mage_Checkout + * @phpstan-import-type ConfigStoreId from Mage */ class Mage_Checkout_Helper_Data extends Mage_Core_Helper_Abstract { @@ -186,7 +187,7 @@ public function sendPaymentFailedEmail($checkout, $message, $checkoutType = 'one $copyTo = $this->_getEmails('checkout/payment_failed/copy_to', $checkout->getStoreId()); $copyMethod = Mage::getStoreConfig('checkout/payment_failed/copy_method', $checkout->getStoreId()); - if ($copyTo && $copyMethod == 'bcc') { + if (is_array($copyTo) && $copyMethod == 'bcc') { $mailTemplate->addBcc($copyTo); } @@ -198,7 +199,7 @@ public function sendPaymentFailedEmail($checkout, $message, $checkoutType = 'one ], ]; - if ($copyTo && $copyMethod == 'copy') { + if (is_array($copyTo) && $copyMethod == 'copy') { foreach ($copyTo as $email) { $sendTo[] = [ 'email' => $email, @@ -257,14 +258,14 @@ public function sendPaymentFailedEmail($checkout, $message, $checkoutType = 'one } /** - * @param string $configPath - * @param int $storeId - * @return array|false + * @param string $configPath + * @param ConfigStoreId $storeId + * @return false|list */ protected function _getEmails($configPath, $storeId) { $data = Mage::getStoreConfig($configPath, $storeId); - if (!empty($data)) { + if (is_string($data) && $data !== '') { return explode(',', $data); } diff --git a/app/code/core/Mage/Payment/Block/Info.php b/app/code/core/Mage/Payment/Block/Info.php index 22c61530ee1..977a0704112 100644 --- a/app/code/core/Mage/Payment/Block/Info.php +++ b/app/code/core/Mage/Payment/Block/Info.php @@ -13,8 +13,8 @@ * @package Mage_Payment * * @method bool hasIsSecureMode() - * @method $this setIsSecureMode(bool $val) * @method $this setInfo(Mage_Payment_Model_Info $info) + * @method $this setIsSecureMode(bool $val) */ class Mage_Payment_Block_Info extends Mage_Core_Block_Template { diff --git a/app/code/core/Mage/Sales/Model/Order/Invoice.php b/app/code/core/Mage/Sales/Model/Order/Invoice.php index f5c1835d381..8b266aa87f9 100644 --- a/app/code/core/Mage/Sales/Model/Order/Invoice.php +++ b/app/code/core/Mage/Sales/Model/Order/Invoice.php @@ -236,7 +236,7 @@ public function loadByIncrementId($incrementId) ->addAttributeToFilter('increment_id', $incrementId) ->getAllIds(); - if (!empty($ids)) { + if ($ids !== []) { reset($ids); $this->load(current($ids)); } @@ -553,7 +553,7 @@ public function roundPrice($price, $type = 'regular', $negative = false) */ public function getItemsCollection() { - if (empty($this->_items)) { + if (is_null($this->_items)) { $this->_items = Mage::getResourceModel('sales/order_invoice_item_collection') ->setInvoiceFilter($this->getId()); diff --git a/app/code/core/Mage/Sales/Model/Order/Shipment.php b/app/code/core/Mage/Sales/Model/Order/Shipment.php index 7b5bdccc3b4..e7add240ee9 100644 --- a/app/code/core/Mage/Sales/Model/Order/Shipment.php +++ b/app/code/core/Mage/Sales/Model/Order/Shipment.php @@ -137,7 +137,7 @@ public function loadByIncrementId($incrementId) ->addAttributeToFilter('increment_id', $incrementId) ->getAllIds(); - if (!empty($ids)) { + if ($ids !== []) { reset($ids); $this->load(current($ids)); } From 92f15a69a9f3cf86a7b7d04a9f9ec8f30166ff72 Mon Sep 17 00:00:00 2001 From: Hans Mackowiak Date: Wed, 3 Jun 2026 10:39:10 +0200 Subject: [PATCH 07/14] ~ phpstan --- .phpstan.dist.baselines/booleanAnd.leftNotBoolean.php | 5 ----- .phpstan.dist.baselines/empty.notAllowed.php | 5 ----- .phpstan.dist.baselines/foreach.nonIterable.php | 5 ----- 3 files changed, 15 deletions(-) diff --git a/.phpstan.dist.baselines/booleanAnd.leftNotBoolean.php b/.phpstan.dist.baselines/booleanAnd.leftNotBoolean.php index 586337b6179..5c9cc588b31 100644 --- a/.phpstan.dist.baselines/booleanAnd.leftNotBoolean.php +++ b/.phpstan.dist.baselines/booleanAnd.leftNotBoolean.php @@ -996,11 +996,6 @@ 'count' => 1, 'path' => __DIR__ . '/../app/code/core/Mage/Checkout/Controller/Action.php', ]; -$ignoreErrors[] = [ - 'rawMessage' => 'Only booleans are allowed in &&, array|false given on the left side.', - 'count' => 2, - 'path' => __DIR__ . '/../app/code/core/Mage/Checkout/Helper/Data.php', -]; $ignoreErrors[] = [ 'rawMessage' => 'Only booleans are allowed in &&, Mage_Sales_Model_Quote_Address|null given on the left side.', 'count' => 3, diff --git a/.phpstan.dist.baselines/empty.notAllowed.php b/.phpstan.dist.baselines/empty.notAllowed.php index f208a1bad18..85e73ce1228 100644 --- a/.phpstan.dist.baselines/empty.notAllowed.php +++ b/.phpstan.dist.baselines/empty.notAllowed.php @@ -1326,11 +1326,6 @@ 'count' => 1, 'path' => __DIR__ . '/../app/code/core/Mage/Checkout/Helper/Cart.php', ]; -$ignoreErrors[] = [ - 'rawMessage' => 'Construct empty() is not allowed. Use more strict comparison.', - 'count' => 1, - 'path' => __DIR__ . '/../app/code/core/Mage/Checkout/Helper/Data.php', -]; $ignoreErrors[] = [ 'rawMessage' => 'Construct empty() is not allowed. Use more strict comparison.', 'count' => 2, diff --git a/.phpstan.dist.baselines/foreach.nonIterable.php b/.phpstan.dist.baselines/foreach.nonIterable.php index b5cae857a0e..35897645162 100644 --- a/.phpstan.dist.baselines/foreach.nonIterable.php +++ b/.phpstan.dist.baselines/foreach.nonIterable.php @@ -511,11 +511,6 @@ 'count' => 1, 'path' => __DIR__ . '/../app/code/core/Mage/Sales/Block/Order/Totals.php', ]; -$ignoreErrors[] = [ - 'rawMessage' => 'Argument of an invalid type array|true supplied for foreach, only iterables are supported.', - 'count' => 4, - 'path' => __DIR__ . '/../app/code/core/Mage/Sales/Model/Order/Creditmemo.php', -]; $ignoreErrors[] = [ 'rawMessage' => 'Argument of an invalid type (iterable&Mage_Sales_Model_Resource_Order_Creditmemo_Collection)|false supplied for foreach, only iterables are supported.', 'count' => 1, From 5f64268d4f1264c738233e5bced33ee5de278279 Mon Sep 17 00:00:00 2001 From: Hans Mackowiak Date: Wed, 3 Jun 2026 14:35:32 +0200 Subject: [PATCH 08/14] add getPaymentBlockHtml method --- app/code/core/Mage/Sales/Model/Abstract.php | 30 +++++++++++++++++++ app/code/core/Mage/Sales/Model/Order.php | 20 +------------ .../Mage/Sales/Model/Order/Creditmemo.php | 19 +----------- .../core/Mage/Sales/Model/Order/Invoice.php | 19 +----------- .../core/Mage/Sales/Model/Order/Shipment.php | 19 +----------- 5 files changed, 34 insertions(+), 73 deletions(-) diff --git a/app/code/core/Mage/Sales/Model/Abstract.php b/app/code/core/Mage/Sales/Model/Abstract.php index 992147da3b9..12b5a7cc57b 100644 --- a/app/code/core/Mage/Sales/Model/Abstract.php +++ b/app/code/core/Mage/Sales/Model/Abstract.php @@ -86,6 +86,36 @@ protected function getMailer(): Mage_Core_Model_Email_Template_Mailer return $mailer; } + /** + * @throws Mage_Core_Exception + * @throws Mage_Core_Model_Store_Exception + */ + protected function getPaymentBlockHtml(Mage_Sales_Model_Order $order): ?string + { + $storeId = $order->getStore()->getId(); + $payment = $order->getPayment(); + if (!is_null($storeId) && $payment instanceof Mage_Payment_Model_Info) { + // Start store emulation process + if ($storeId != Mage::app()->getStore()->getId()) { + $appEmulation = Mage::getSingleton('core/app_emulation'); + $initialEnvironmentInfo = $appEmulation->startEnvironmentEmulation($storeId); + } + try { + // Retrieve specified view block from appropriate design package (depends on emulated store) + $paymentBlock = Mage::helper('payment')->getInfoBlock($payment) + ->setIsSecureMode(true); + $paymentBlock->getMethod()->setStore($storeId); + return $paymentBlock->toHtml(); + } finally { + // Stop store emulation process + if (isset($appEmulation, $initialEnvironmentInfo)) { + $appEmulation->stopEnvironmentEmulation($initialEnvironmentInfo); + } + } + } + return null; + } + /** * @param string $configPath * @return false|list diff --git a/app/code/core/Mage/Sales/Model/Order.php b/app/code/core/Mage/Sales/Model/Order.php index 49a3c3eb1a9..925e25130f5 100644 --- a/app/code/core/Mage/Sales/Model/Order.php +++ b/app/code/core/Mage/Sales/Model/Order.php @@ -1403,25 +1403,7 @@ public function queueNewOrderEmail($forceMode = false) $copyTo = $this->_getEmails(self::XML_PATH_EMAIL_COPY_TO); $copyMethod = Mage::getStoreConfig(self::XML_PATH_EMAIL_COPY_METHOD, $storeId); - // Start store emulation process - if ($storeId != Mage::app()->getStore()->getId()) { - /** @var Mage_Core_Model_App_Emulation $appEmulation */ - $appEmulation = Mage::getSingleton('core/app_emulation'); - $initialEnvironmentInfo = $appEmulation->startEnvironmentEmulation($storeId); - } - - try { - // Retrieve specified view block from appropriate design package (depends on emulated store) - $paymentBlock = Mage::helper('payment')->getInfoBlock($this->getPayment()) - ->setIsSecureMode(true); - $paymentBlock->getMethod()->setStore($storeId); - $paymentBlockHtml = $paymentBlock->toHtml(); - } finally { - // Stop store emulation process - if (isset($appEmulation, $initialEnvironmentInfo)) { - $appEmulation->stopEnvironmentEmulation($initialEnvironmentInfo); - } - } + $paymentBlockHtml = $this->getPaymentBlockHtml($this); // Retrieve corresponding email template id and customer name if ($this->getCustomerIsGuest()) { diff --git a/app/code/core/Mage/Sales/Model/Order/Creditmemo.php b/app/code/core/Mage/Sales/Model/Order/Creditmemo.php index 9bd05ece76a..b8527072a53 100644 --- a/app/code/core/Mage/Sales/Model/Order/Creditmemo.php +++ b/app/code/core/Mage/Sales/Model/Order/Creditmemo.php @@ -794,24 +794,7 @@ public function sendEmail($notifyCustomer = true, $comment = '') return $this; } - // Start store emulation process - if ($storeId != Mage::app()->getStore()->getId()) { - $appEmulation = Mage::getSingleton('core/app_emulation'); - $initialEnvironmentInfo = $appEmulation->startEnvironmentEmulation($storeId); - } - - try { - // Retrieve specified view block from appropriate design package (depends on emulated store) - $paymentBlock = Mage::helper('payment')->getInfoBlock($order->getPayment()) - ->setIsSecureMode(true); - $paymentBlock->getMethod()->setStore($storeId); - $paymentBlockHtml = $paymentBlock->toHtml(); - } finally { - // Stop store emulation process - if (isset($appEmulation, $initialEnvironmentInfo)) { - $appEmulation->stopEnvironmentEmulation($initialEnvironmentInfo); - } - } + $paymentBlockHtml = $this->getPaymentBlockHtml($order); // Retrieve corresponding email template id and customer name if ($order->getCustomerIsGuest()) { diff --git a/app/code/core/Mage/Sales/Model/Order/Invoice.php b/app/code/core/Mage/Sales/Model/Order/Invoice.php index 8b266aa87f9..8a62a54b3c0 100644 --- a/app/code/core/Mage/Sales/Model/Order/Invoice.php +++ b/app/code/core/Mage/Sales/Model/Order/Invoice.php @@ -822,24 +822,7 @@ public function sendEmail($notifyCustomer = true, $comment = '') return $this; } - // Start store emulation process - if ($storeId != Mage::app()->getStore()->getId()) { - $appEmulation = Mage::getSingleton('core/app_emulation'); - $initialEnvironmentInfo = $appEmulation->startEnvironmentEmulation($storeId); - } - - try { - // Retrieve specified view block from appropriate design package (depends on emulated store) - $paymentBlock = Mage::helper('payment')->getInfoBlock($order->getPayment()) - ->setIsSecureMode(true); - $paymentBlock->getMethod()->setStore($storeId); - $paymentBlockHtml = $paymentBlock->toHtml(); - } finally { - // Stop store emulation process - if (isset($appEmulation, $initialEnvironmentInfo)) { - $appEmulation->stopEnvironmentEmulation($initialEnvironmentInfo); - } - } + $paymentBlockHtml = $this->getPaymentBlockHtml($order); // Retrieve corresponding email template id and customer name if ($order->getCustomerIsGuest()) { diff --git a/app/code/core/Mage/Sales/Model/Order/Shipment.php b/app/code/core/Mage/Sales/Model/Order/Shipment.php index e7add240ee9..b19886c7207 100644 --- a/app/code/core/Mage/Sales/Model/Order/Shipment.php +++ b/app/code/core/Mage/Sales/Model/Order/Shipment.php @@ -454,24 +454,7 @@ public function sendEmail($notifyCustomer = true, $comment = '') return $this; } - // Start store emulation process - if ($storeId != Mage::app()->getStore()->getId()) { - $appEmulation = Mage::getSingleton('core/app_emulation'); - $initialEnvironmentInfo = $appEmulation->startEnvironmentEmulation($storeId); - } - - try { - // Retrieve specified view block from appropriate design package (depends on emulated store) - $paymentBlock = Mage::helper('payment')->getInfoBlock($order->getPayment()) - ->setIsSecureMode(true); - $paymentBlock->getMethod()->setStore($storeId); - $paymentBlockHtml = $paymentBlock->toHtml(); - } finally { - // Stop store emulation process - if (isset($appEmulation, $initialEnvironmentInfo)) { - $appEmulation->stopEnvironmentEmulation($initialEnvironmentInfo); - } - } + $paymentBlockHtml = $this->getPaymentBlockHtml($order); // Retrieve corresponding email template id and customer name if ($order->getCustomerIsGuest()) { From a0c29afa35b5ed2f602dc3e7d5a6757e9d3cc6a9 Mon Sep 17 00:00:00 2001 From: Hans Mackowiak Date: Wed, 3 Jun 2026 14:45:49 +0200 Subject: [PATCH 09/14] ~ phpstan --- .phpstan.dist.baselines/argument.type.php | 40 ------------------- .../notEqual.notAllowed.php | 20 ---------- app/code/core/Mage/Sales/Model/Abstract.php | 2 +- 3 files changed, 1 insertion(+), 61 deletions(-) diff --git a/.phpstan.dist.baselines/argument.type.php b/.phpstan.dist.baselines/argument.type.php index 0287e245aeb..f8ce0bb34e5 100644 --- a/.phpstan.dist.baselines/argument.type.php +++ b/.phpstan.dist.baselines/argument.type.php @@ -5826,11 +5826,6 @@ 'count' => 1, 'path' => __DIR__ . '/../app/code/core/Mage/Sales/Model/Observer.php', ]; -$ignoreErrors[] = [ - 'rawMessage' => 'Parameter #1 $info of method Mage_Payment_Helper_Data::getInfoBlock() expects Mage_Payment_Model_Info, Mage_Sales_Model_Order_Payment|false given.', - 'count' => 1, - 'path' => __DIR__ . '/../app/code/core/Mage/Sales/Model/Order.php', -]; $ignoreErrors[] = [ 'rawMessage' => 'Parameter #1 $item of method Mage_Sales_Model_Order_Item::setParentItem() expects Mage_Sales_Model_Order_Item, Mage_Sales_Model_Order_Item|null given.', 'count' => 1, @@ -5841,11 +5836,6 @@ 'count' => 1, 'path' => __DIR__ . '/../app/code/core/Mage/Sales/Model/Order.php', ]; -$ignoreErrors[] = [ - 'rawMessage' => 'Parameter #1 $storeId of method Mage_Core_Model_App_Emulation::startEnvironmentEmulation() expects int, int|null given.', - 'count' => 1, - 'path' => __DIR__ . '/../app/code/core/Mage/Sales/Model/Order.php', -]; $ignoreErrors[] = [ 'rawMessage' => 'Parameter #1 $storeId of method Mage_Core_Model_Email_Template_Mailer::setStoreId() expects int, int|null given.', 'count' => 2, @@ -5886,16 +5876,6 @@ 'count' => 1, 'path' => __DIR__ . '/../app/code/core/Mage/Sales/Model/Order/Creditmemo.php', ]; -$ignoreErrors[] = [ - 'rawMessage' => 'Parameter #1 $info of method Mage_Payment_Helper_Data::getInfoBlock() expects Mage_Payment_Model_Info, Mage_Sales_Model_Order_Payment|false given.', - 'count' => 1, - 'path' => __DIR__ . '/../app/code/core/Mage/Sales/Model/Order/Creditmemo.php', -]; -$ignoreErrors[] = [ - 'rawMessage' => 'Parameter #1 $storeId of method Mage_Core_Model_App_Emulation::startEnvironmentEmulation() expects int, int|null given.', - 'count' => 1, - 'path' => __DIR__ . '/../app/code/core/Mage/Sales/Model/Order/Creditmemo.php', -]; $ignoreErrors[] = [ 'rawMessage' => 'Parameter #1 $storeId of method Mage_Core_Model_Email_Template_Mailer::setStoreId() expects int, int|null given.', 'count' => 2, @@ -5911,11 +5891,6 @@ 'count' => 1, 'path' => __DIR__ . '/../app/code/core/Mage/Sales/Model/Order/Creditmemo/Config.php', ]; -$ignoreErrors[] = [ - 'rawMessage' => 'Parameter #1 $info of method Mage_Payment_Helper_Data::getInfoBlock() expects Mage_Payment_Model_Info, Mage_Sales_Model_Order_Payment|false given.', - 'count' => 1, - 'path' => __DIR__ . '/../app/code/core/Mage/Sales/Model/Order/Invoice.php', -]; $ignoreErrors[] = [ 'rawMessage' => 'Parameter #1 $invoiceId of method Mage_Sales_Model_Resource_Order_Invoice_Comment_Collection::setInvoiceFilter() expects int, int|string|null given.', 'count' => 1, @@ -5926,11 +5901,6 @@ 'count' => 1, 'path' => __DIR__ . '/../app/code/core/Mage/Sales/Model/Order/Invoice.php', ]; -$ignoreErrors[] = [ - 'rawMessage' => 'Parameter #1 $storeId of method Mage_Core_Model_App_Emulation::startEnvironmentEmulation() expects int, int|null given.', - 'count' => 1, - 'path' => __DIR__ . '/../app/code/core/Mage/Sales/Model/Order/Invoice.php', -]; $ignoreErrors[] = [ 'rawMessage' => 'Parameter #1 $storeId of method Mage_Core_Model_Email_Template_Mailer::setStoreId() expects int, int|null given.', 'count' => 2, @@ -6066,11 +6036,6 @@ 'count' => 1, 'path' => __DIR__ . '/../app/code/core/Mage/Sales/Model/Order/Pdf/Total/Default.php', ]; -$ignoreErrors[] = [ - 'rawMessage' => 'Parameter #1 $info of method Mage_Payment_Helper_Data::getInfoBlock() expects Mage_Payment_Model_Info, Mage_Sales_Model_Order_Payment|false given.', - 'count' => 1, - 'path' => __DIR__ . '/../app/code/core/Mage/Sales/Model/Order/Shipment.php', -]; $ignoreErrors[] = [ 'rawMessage' => 'Parameter #1 $shipmentId of method Mage_Sales_Model_Resource_Order_Shipment_Comment_Collection::setShipmentFilter() expects int, int|string|null given.', 'count' => 1, @@ -6086,11 +6051,6 @@ 'count' => 1, 'path' => __DIR__ . '/../app/code/core/Mage/Sales/Model/Order/Shipment.php', ]; -$ignoreErrors[] = [ - 'rawMessage' => 'Parameter #1 $storeId of method Mage_Core_Model_App_Emulation::startEnvironmentEmulation() expects int, int|null given.', - 'count' => 1, - 'path' => __DIR__ . '/../app/code/core/Mage/Sales/Model/Order/Shipment.php', -]; $ignoreErrors[] = [ 'rawMessage' => 'Parameter #1 $storeId of method Mage_Core_Model_Email_Template_Mailer::setStoreId() expects int, int|null given.', 'count' => 2, diff --git a/.phpstan.dist.baselines/notEqual.notAllowed.php b/.phpstan.dist.baselines/notEqual.notAllowed.php index 110e4072b65..0422b94613b 100644 --- a/.phpstan.dist.baselines/notEqual.notAllowed.php +++ b/.phpstan.dist.baselines/notEqual.notAllowed.php @@ -2046,11 +2046,6 @@ 'count' => 1, 'path' => __DIR__ . '/../app/code/core/Mage/Sales/Model/Observer.php', ]; -$ignoreErrors[] = [ - 'rawMessage' => 'Loose comparison via "!=" between int|null and int|null is not allowed.', - 'count' => 1, - 'path' => __DIR__ . '/../app/code/core/Mage/Sales/Model/Order.php', -]; $ignoreErrors[] = [ 'rawMessage' => 'Loose comparison via "!=" between mixed and int|string|null is not allowed.', 'count' => 2, @@ -2071,11 +2066,6 @@ 'count' => 1, 'path' => __DIR__ . '/../app/code/core/Mage/Sales/Model/Order/Creditmemo.php', ]; -$ignoreErrors[] = [ - 'rawMessage' => 'Loose comparison via "!=" between int|null and int|null is not allowed.', - 'count' => 1, - 'path' => __DIR__ . '/../app/code/core/Mage/Sales/Model/Order/Creditmemo.php', -]; $ignoreErrors[] = [ 'rawMessage' => 'Loose comparison via "!=" between iterable&Mage_Sales_Model_Resource_Order_Creditmemo_Item_Collection and null is not allowed.', 'count' => 1, @@ -2096,11 +2086,6 @@ 'count' => 3, 'path' => __DIR__ . '/../app/code/core/Mage/Sales/Model/Order/Creditmemo/Total/Shipping.php', ]; -$ignoreErrors[] = [ - 'rawMessage' => 'Loose comparison via "!=" between int|null and int|null is not allowed.', - 'count' => 1, - 'path' => __DIR__ . '/../app/code/core/Mage/Sales/Model/Order/Invoice.php', -]; $ignoreErrors[] = [ 'rawMessage' => 'Loose comparison via "!=" between mixed and int is not allowed.', 'count' => 3, @@ -2141,11 +2126,6 @@ 'count' => 1, 'path' => __DIR__ . '/../app/code/core/Mage/Sales/Model/Order/Pdf/Total/Default.php', ]; -$ignoreErrors[] = [ - 'rawMessage' => 'Loose comparison via "!=" between int|null and int|null is not allowed.', - 'count' => 1, - 'path' => __DIR__ . '/../app/code/core/Mage/Sales/Model/Order/Shipment.php', -]; $ignoreErrors[] = [ 'rawMessage' => 'Loose comparison via "!=" between mixed and int|string|null is not allowed.', 'count' => 1, diff --git a/app/code/core/Mage/Sales/Model/Abstract.php b/app/code/core/Mage/Sales/Model/Abstract.php index 12b5a7cc57b..cbca3e0e56b 100644 --- a/app/code/core/Mage/Sales/Model/Abstract.php +++ b/app/code/core/Mage/Sales/Model/Abstract.php @@ -96,7 +96,7 @@ protected function getPaymentBlockHtml(Mage_Sales_Model_Order $order): ?string $payment = $order->getPayment(); if (!is_null($storeId) && $payment instanceof Mage_Payment_Model_Info) { // Start store emulation process - if ($storeId != Mage::app()->getStore()->getId()) { + if ($storeId !== Mage::app()->getStore()->getId()) { $appEmulation = Mage::getSingleton('core/app_emulation'); $initialEnvironmentInfo = $appEmulation->startEnvironmentEmulation($storeId); } From cd6916fe4cb07f1ba2369b9b303551d869b93204 Mon Sep 17 00:00:00 2001 From: Hans Mackowiak Date: Wed, 3 Jun 2026 15:15:05 +0200 Subject: [PATCH 10/14] ~rector --- app/code/core/Mage/Sales/Model/Abstract.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/code/core/Mage/Sales/Model/Abstract.php b/app/code/core/Mage/Sales/Model/Abstract.php index cbca3e0e56b..0702b6cbd03 100644 --- a/app/code/core/Mage/Sales/Model/Abstract.php +++ b/app/code/core/Mage/Sales/Model/Abstract.php @@ -100,6 +100,7 @@ protected function getPaymentBlockHtml(Mage_Sales_Model_Order $order): ?string $appEmulation = Mage::getSingleton('core/app_emulation'); $initialEnvironmentInfo = $appEmulation->startEnvironmentEmulation($storeId); } + try { // Retrieve specified view block from appropriate design package (depends on emulated store) $paymentBlock = Mage::helper('payment')->getInfoBlock($payment) @@ -113,6 +114,7 @@ protected function getPaymentBlockHtml(Mage_Sales_Model_Order $order): ?string } } } + return null; } From 3cbadbad80cb94fd50f26e9b80e8ba28cf52b28e Mon Sep 17 00:00:00 2001 From: Hans Mackowiak Date: Wed, 3 Jun 2026 16:18:02 +0200 Subject: [PATCH 11/14] ~ add Mage_Sales_Model_Order_Comment_Abstract as base class --- .../missingType.generics.php | 25 ----------------- .../core/Mage/Sales/Block/Order/Comments.php | 6 ++-- .../Sales/Model/Order/Comment/Abstract.php | 28 +++++++++++++++++++ .../Mage/Sales/Model/Order/Creditmemo.php | 2 +- .../Sales/Model/Order/Creditmemo/Comment.php | 11 +------- .../core/Mage/Sales/Model/Order/Invoice.php | 2 +- .../Sales/Model/Order/Invoice/Comment.php | 11 +------- .../Sales/Model/Order/Shipment/Comment.php | 11 +------- .../Order/Comment/Collection/Abstract.php | 2 +- 9 files changed, 37 insertions(+), 61 deletions(-) create mode 100644 app/code/core/Mage/Sales/Model/Order/Comment/Abstract.php diff --git a/.phpstan.dist.baselines/missingType.generics.php b/.phpstan.dist.baselines/missingType.generics.php index 4109f7d7bc8..43142f37bbe 100644 --- a/.phpstan.dist.baselines/missingType.generics.php +++ b/.phpstan.dist.baselines/missingType.generics.php @@ -726,21 +726,6 @@ 'count' => 1, 'path' => __DIR__ . '/../app/code/core/Mage/Rule/Model/Resource/Rule/Collection/Abstract.php', ]; -$ignoreErrors[] = [ - 'rawMessage' => 'Method Mage_Sales_Block_Order_Comments::getComments() return type with generic class Mage_Sales_Model_Resource_Order_Comment_Collection_Abstract does not specify its types: T', - 'count' => 1, - 'path' => __DIR__ . '/../app/code/core/Mage/Sales/Block/Order/Comments.php', -]; -$ignoreErrors[] = [ - 'rawMessage' => 'PHPDoc tag @var for variable $commentCollection contains generic class Mage_Sales_Model_Resource_Order_Comment_Collection_Abstract but does not specify its types: T', - 'count' => 1, - 'path' => __DIR__ . '/../app/code/core/Mage/Sales/Block/Order/Comments.php', -]; -$ignoreErrors[] = [ - 'rawMessage' => 'Property Mage_Sales_Block_Order_Comments::$_commentCollection with generic class Mage_Sales_Model_Resource_Order_Comment_Collection_Abstract does not specify its types: T', - 'count' => 1, - 'path' => __DIR__ . '/../app/code/core/Mage/Sales/Block/Order/Comments.php', -]; $ignoreErrors[] = [ 'rawMessage' => 'Method Mage_Sales_Block_Order_Details::getInvoices() return type with generic class Mage_Sales_Model_Resource_Order_Collection_Abstract does not specify its types: T', 'count' => 1, @@ -856,16 +841,6 @@ 'count' => 1, 'path' => __DIR__ . '/../app/code/core/Mage/Sales/Model/Entity/Sale/Collection.php', ]; -$ignoreErrors[] = [ - 'rawMessage' => 'Method Mage_Sales_Model_Order_Creditmemo::getCommentsCollection() return type with generic class Mage_Sales_Model_Resource_Order_Comment_Collection_Abstract does not specify its types: T', - 'count' => 1, - 'path' => __DIR__ . '/../app/code/core/Mage/Sales/Model/Order/Creditmemo.php', -]; -$ignoreErrors[] = [ - 'rawMessage' => 'Method Mage_Sales_Model_Order_Invoice::getCommentsCollection() return type with generic class Mage_Sales_Model_Resource_Order_Comment_Collection_Abstract does not specify its types: T', - 'count' => 1, - 'path' => __DIR__ . '/../app/code/core/Mage/Sales/Model/Order/Invoice.php', -]; $ignoreErrors[] = [ 'rawMessage' => 'Method Mage_Sales_Model_Resource_Order_Collection::addAddressFields() return type with generic class Mage_Sales_Model_Resource_Collection_Abstract does not specify its types: T', 'count' => 1, diff --git a/app/code/core/Mage/Sales/Block/Order/Comments.php b/app/code/core/Mage/Sales/Block/Order/Comments.php index 6e28ed4cca1..10b88704b78 100644 --- a/app/code/core/Mage/Sales/Block/Order/Comments.php +++ b/app/code/core/Mage/Sales/Block/Order/Comments.php @@ -22,7 +22,7 @@ class Mage_Sales_Block_Order_Comments extends Mage_Core_Block_Template /** * Current comments collection * - * @var null|Mage_Sales_Model_Resource_Order_Comment_Collection_Abstract + * @var null|Mage_Sales_Model_Resource_Order_Comment_Collection_Abstract */ protected $_commentCollection; @@ -52,7 +52,7 @@ public function getEntity() /** * Initialize model comments and return comment collection * - * @return Mage_Sales_Model_Resource_Order_Comment_Collection_Abstract + * @return Mage_Sales_Model_Resource_Order_Comment_Collection_Abstract */ public function getComments() { @@ -68,7 +68,7 @@ public function getComments() Mage::throwException(Mage::helper('sales')->__('Invalid entity model')); } - /** @var Mage_Sales_Model_Resource_Order_Comment_Collection_Abstract $commentCollection */ + /** @var Mage_Sales_Model_Resource_Order_Comment_Collection_Abstract $commentCollection */ $commentCollection = Mage::getResourceModel($collectionClass); $this->_commentCollection = $commentCollection; $this->_commentCollection->setParentFilter($entity) diff --git a/app/code/core/Mage/Sales/Model/Order/Comment/Abstract.php b/app/code/core/Mage/Sales/Model/Order/Comment/Abstract.php new file mode 100644 index 00000000000..c5c6a4ec141 --- /dev/null +++ b/app/code/core/Mage/Sales/Model/Order/Comment/Abstract.php @@ -0,0 +1,28 @@ + */ abstract class Mage_Sales_Model_Resource_Order_Comment_Collection_Abstract extends Mage_Sales_Model_Resource_Collection_Abstract From 5854cc5e4934fb8a34c9d0611e1912431d7fc6be Mon Sep 17 00:00:00 2001 From: Hans Mackowiak Date: Wed, 3 Jun 2026 16:22:46 +0200 Subject: [PATCH 12/14] ~ cs fix --- app/code/core/Mage/Sales/Model/Order/Comment/Abstract.php | 5 +---- app/code/core/Mage/Sales/Model/Order/Creditmemo.php | 2 +- app/code/core/Mage/Sales/Model/Order/Invoice.php | 2 +- 3 files changed, 3 insertions(+), 6 deletions(-) diff --git a/app/code/core/Mage/Sales/Model/Order/Comment/Abstract.php b/app/code/core/Mage/Sales/Model/Order/Comment/Abstract.php index c5c6a4ec141..f9372199101 100644 --- a/app/code/core/Mage/Sales/Model/Order/Comment/Abstract.php +++ b/app/code/core/Mage/Sales/Model/Order/Comment/Abstract.php @@ -22,7 +22,4 @@ * @method $this setParentId(int $value) * @method $this setStoreId(int $value) */ -abstract class Mage_Sales_Model_Order_Comment_Abstract extends Mage_Sales_Model_Abstract -{ - -} +abstract class Mage_Sales_Model_Order_Comment_Abstract extends Mage_Sales_Model_Abstract {} diff --git a/app/code/core/Mage/Sales/Model/Order/Creditmemo.php b/app/code/core/Mage/Sales/Model/Order/Creditmemo.php index c20105443ff..504e112e358 100644 --- a/app/code/core/Mage/Sales/Model/Order/Creditmemo.php +++ b/app/code/core/Mage/Sales/Model/Order/Creditmemo.php @@ -742,7 +742,7 @@ public function addComment($comment, $notify = false, $visibleOnFront = false) } /** - * @param bool $reload + * @param bool $reload * @return Mage_Sales_Model_Resource_Order_Creditmemo_Comment_Collection * @throws Mage_Core_Exception */ diff --git a/app/code/core/Mage/Sales/Model/Order/Invoice.php b/app/code/core/Mage/Sales/Model/Order/Invoice.php index c72fd79bdf0..70a72405e8e 100644 --- a/app/code/core/Mage/Sales/Model/Order/Invoice.php +++ b/app/code/core/Mage/Sales/Model/Order/Invoice.php @@ -773,7 +773,7 @@ public function addComment($comment, $notify = false, $visibleOnFront = false) } /** - * @param bool $reload + * @param bool $reload * @return Mage_Sales_Model_Resource_Order_Invoice_Comment_Collection */ public function getCommentsCollection($reload = false) From a1155b25cbe35747555334a5b9ddcc1e4e75a71a Mon Sep 17 00:00:00 2001 From: Hans Mackowiak Date: Wed, 3 Jun 2026 16:37:19 +0200 Subject: [PATCH 13/14] ~ rector add strict_types --- app/code/core/Mage/Sales/Model/Order/Shipment/Comment.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/code/core/Mage/Sales/Model/Order/Shipment/Comment.php b/app/code/core/Mage/Sales/Model/Order/Shipment/Comment.php index 7a0e76131ef..792691687a6 100644 --- a/app/code/core/Mage/Sales/Model/Order/Shipment/Comment.php +++ b/app/code/core/Mage/Sales/Model/Order/Shipment/Comment.php @@ -1,5 +1,7 @@ Date: Wed, 3 Jun 2026 17:04:18 +0200 Subject: [PATCH 14/14] ~ rector add strict_types --- app/code/core/Mage/Sales/Model/Order/Comment/Abstract.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/code/core/Mage/Sales/Model/Order/Comment/Abstract.php b/app/code/core/Mage/Sales/Model/Order/Comment/Abstract.php index f9372199101..20d95dbaeb7 100644 --- a/app/code/core/Mage/Sales/Model/Order/Comment/Abstract.php +++ b/app/code/core/Mage/Sales/Model/Order/Comment/Abstract.php @@ -1,5 +1,7 @@