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/booleanAnd.leftNotBoolean.php b/.phpstan.dist.baselines/booleanAnd.leftNotBoolean.php index 501368db3a1..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, @@ -1916,31 +1911,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 +1971,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..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, @@ -2648,7 +2643,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 +2651,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 +2681,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..35897645162 100644 --- a/.phpstan.dist.baselines/foreach.nonIterable.php +++ b/.phpstan.dist.baselines/foreach.nonIterable.php @@ -511,16 +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 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.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/.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/.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/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 29c181a34bf..977a0704112 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 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/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/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/Abstract.php b/app/code/core/Mage/Sales/Model/Abstract.php index 1e15e287882..0702b6cbd03 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 @@ -74,4 +76,59 @@ 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; + } + + /** + * @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 + */ + protected function _getEmails($configPath) + { + $data = Mage::getStoreConfig($configPath, $this->getStoreId()); + if (is_string($data) && $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 6c27fa18837..925e25130f5 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) @@ -1405,32 +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(); - } catch (Exception $exception) { - // Stop store emulation process - if (isset($appEmulation, $initialEnvironmentInfo)) { - $appEmulation->stopEnvironmentEmulation($initialEnvironmentInfo); - } - - throw $exception; - } - - // 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()) { @@ -1441,12 +1414,11 @@ 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); - if ($copyTo && $copyMethod == 'bcc') { + if (is_array($copyTo) && $copyMethod == 'bcc') { // Add bcc to customer email foreach ($copyTo as $email) { $emailInfo->addBcc($email); @@ -1456,7 +1428,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); @@ -1521,7 +1493,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 && !is_array($copyTo)) { return $this; } @@ -1534,13 +1506,12 @@ 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'); $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); @@ -1552,7 +1523,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); @@ -1595,20 +1566,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/Comment/Abstract.php b/app/code/core/Mage/Sales/Model/Order/Comment/Abstract.php new file mode 100644 index 00000000000..20d95dbaeb7 --- /dev/null +++ b/app/code/core/Mage/Sales/Model/Order/Comment/Abstract.php @@ -0,0 +1,27 @@ +_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 && !is_array($copyTo)) { 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(); - } catch (Exception $exception) { - // Stop store emulation process - if (isset($appEmulation, $initialEnvironmentInfo)) { - $appEmulation->stopEnvironmentEmulation($initialEnvironmentInfo); - } - - throw $exception; - } - - // 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()) { @@ -821,11 +805,11 @@ 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); - if ($copyTo && $copyMethod === 'bcc') { + if (is_array($copyTo) && $copyMethod === 'bcc') { // Add bcc to customer email foreach ($copyTo as $email) { $emailInfo->addBcc($email); @@ -836,7 +820,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); @@ -855,7 +839,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); @@ -886,7 +878,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 && !is_array($copyTo)) { return $this; } @@ -899,11 +891,11 @@ 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); - if ($copyTo && $copyMethod === 'bcc') { + if (is_array($copyTo) && $copyMethod === 'bcc') { // Add bcc to customer email foreach ($copyTo as $email) { $emailInfo->addBcc($email); @@ -914,7 +906,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); @@ -932,23 +924,17 @@ public function sendUpdateEmail($notifyCustomer = true, $comment = '') 'comment' => $comment, 'billing' => $order->getBillingAddress(), ]); - $mailer->send(); - return $this; - } + /** @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); - /** - * @param string $configPath - * @return array|bool - */ - protected function _getEmails($configPath) - { - $data = Mage::getStoreConfig($configPath, $this->getStoreId()); - if (!empty($data)) { - return explode(',', $data); - } + $mailer->setQueue($emailQueue)->send(); - return false; + return $this; } /** diff --git a/app/code/core/Mage/Sales/Model/Order/Creditmemo/Comment.php b/app/code/core/Mage/Sales/Model/Order/Creditmemo/Comment.php index 3104ca00c03..492c475d23b 100644 --- a/app/code/core/Mage/Sales/Model/Order/Creditmemo/Comment.php +++ b/app/code/core/Mage/Sales/Model/Order/Creditmemo/Comment.php @@ -12,19 +12,10 @@ * * @method Mage_Sales_Model_Resource_Order_Creditmemo_Comment _getResource() * @method Mage_Sales_Model_Resource_Order_Creditmemo_Comment_Collection getCollection() - * @method string getComment() - * @method int getIsCustomerNotified() - * @method int getIsVisibleOnFront() - * @method int getParentId() * @method Mage_Sales_Model_Resource_Order_Creditmemo_Comment getResource() * @method Mage_Sales_Model_Resource_Order_Creditmemo_Comment_Collection getResourceCollection() - * @method $this setComment(string $value) - * @method $this setIsCustomerNotified(int $value) - * @method $this setIsVisibleOnFront(int $value) - * @method $this setParentId(int $value) - * @method $this setStoreId(int $value) */ -class Mage_Sales_Model_Order_Creditmemo_Comment extends Mage_Sales_Model_Abstract +class Mage_Sales_Model_Order_Creditmemo_Comment extends Mage_Sales_Model_Order_Comment_Abstract { /** * Creditmemo instance diff --git a/app/code/core/Mage/Sales/Model/Order/Invoice.php b/app/code/core/Mage/Sales/Model/Order/Invoice.php index f88a7337d73..70a72405e8e 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) @@ -105,6 +103,15 @@ */ 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 */ @@ -229,7 +236,7 @@ public function loadByIncrementId($incrementId) ->addAttributeToFilter('increment_id', $incrementId) ->getAllIds(); - if (!empty($ids)) { + if ($ids !== []) { reset($ids); $this->load(current($ids)); } @@ -546,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()); @@ -766,8 +773,8 @@ public function addComment($comment, $notify = false, $visibleOnFront = false) } /** - * @param bool $reload - * @return Mage_Sales_Model_Resource_Order_Comment_Collection_Abstract + * @param bool $reload + * @return Mage_Sales_Model_Resource_Order_Invoice_Comment_Collection */ public function getCommentsCollection($reload = false) { @@ -811,35 +818,11 @@ 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 && !is_array($copyTo)) { 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(); - } catch (Exception $exception) { - // Stop store emulation process - if (isset($appEmulation, $initialEnvironmentInfo)) { - $appEmulation->stopEnvironmentEmulation($initialEnvironmentInfo); - } - - throw $exception; - } - - // 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()) { @@ -850,11 +833,11 @@ 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); - if ($copyTo && $copyMethod == 'bcc') { + if (is_array($copyTo) && $copyMethod == 'bcc') { // Add bcc to customer email foreach ($copyTo as $email) { $emailInfo->addBcc($email); @@ -865,7 +848,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); @@ -884,7 +867,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); @@ -914,7 +905,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 && !is_array($copyTo)) { return $this; } @@ -927,11 +918,11 @@ 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); - if ($copyTo && $copyMethod == 'bcc') { + if (is_array($copyTo) && $copyMethod == 'bcc') { // Add bcc to customer email foreach ($copyTo as $email) { $emailInfo->addBcc($email); @@ -942,7 +933,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); @@ -960,23 +951,17 @@ public function sendUpdateEmail($notifyCustomer = true, $comment = '') 'comment' => $comment, 'billing' => $order->getBillingAddress(), ]); - $mailer->send(); - return $this; - } + /** @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); - /** - * @param string $configPath - * @return array|bool - */ - protected function _getEmails($configPath) - { - $data = Mage::getStoreConfig($configPath, $this->getStoreId()); - if (!empty($data)) { - return explode(',', $data); - } + $mailer->setQueue($emailQueue)->send(); - return false; + return $this; } /** diff --git a/app/code/core/Mage/Sales/Model/Order/Invoice/Comment.php b/app/code/core/Mage/Sales/Model/Order/Invoice/Comment.php index cb23bbc0823..eb6b1bd2054 100644 --- a/app/code/core/Mage/Sales/Model/Order/Invoice/Comment.php +++ b/app/code/core/Mage/Sales/Model/Order/Invoice/Comment.php @@ -12,19 +12,10 @@ * * @method Mage_Sales_Model_Resource_Order_Invoice_Comment _getResource() * @method Mage_Sales_Model_Resource_Order_Invoice_Comment_Collection getCollection() - * @method string getComment() - * @method int getIsCustomerNotified() - * @method int getIsVisibleOnFront() - * @method int getParentId() * @method Mage_Sales_Model_Resource_Order_Invoice_Comment getResource() * @method Mage_Sales_Model_Resource_Order_Invoice_Comment_Collection getResourceCollection() - * @method $this setComment(string $value) - * @method $this setIsCustomerNotified(int $value) - * @method $this setIsVisibleOnFront(int $value) - * @method $this setParentId(int $value) - * @method $this setStoreId(int $value) */ -class Mage_Sales_Model_Order_Invoice_Comment extends Mage_Sales_Model_Abstract +class Mage_Sales_Model_Order_Invoice_Comment extends Mage_Sales_Model_Order_Comment_Abstract { /** * Invoice instance diff --git a/app/code/core/Mage/Sales/Model/Order/Shipment.php b/app/code/core/Mage/Sales/Model/Order/Shipment.php index b9fcd70a238..b19886c7207 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,12 +34,20 @@ * @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) */ 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'; @@ -130,7 +137,7 @@ public function loadByIncrementId($incrementId) ->addAttributeToFilter('increment_id', $incrementId) ->getAllIds(); - if (!empty($ids)) { + if ($ids !== []) { reset($ids); $this->load(current($ids)); } @@ -443,35 +450,11 @@ 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 && !is_array($copyTo)) { 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(); - } catch (Exception $exception) { - // Stop store emulation process - if (isset($appEmulation, $initialEnvironmentInfo)) { - $appEmulation->stopEnvironmentEmulation($initialEnvironmentInfo); - } - - throw $exception; - } - - // 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()) { @@ -482,11 +465,11 @@ 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); - if ($copyTo && $copyMethod == 'bcc') { + if (is_array($copyTo) && $copyMethod == 'bcc') { // Add bcc to customer email foreach ($copyTo as $email) { $emailInfo->addBcc($email); @@ -497,7 +480,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); @@ -516,7 +499,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; } @@ -541,7 +532,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 && !is_array($copyTo)) { return $this; } @@ -554,11 +545,11 @@ 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); - if ($copyTo && $copyMethod == 'bcc') { + if (is_array($copyTo) && $copyMethod == 'bcc') { // Add bcc to customer email foreach ($copyTo as $email) { $emailInfo->addBcc($email); @@ -569,7 +560,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); @@ -587,23 +578,17 @@ public function sendUpdateEmail($notifyCustomer = true, $comment = '') 'comment' => $comment, 'billing' => $order->getBillingAddress(), ]); - $mailer->send(); - return $this; - } + /** @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); - /** - * @param string $configPath - * @return array|false - */ - protected function _getEmails($configPath) - { - $data = Mage::getStoreConfig($configPath, $this->getStoreId()); - if (!empty($data)) { - return explode(',', $data); - } + $mailer->setQueue($emailQueue)->send(); - return false; + return $this; } /** 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 7ed9fbf0592..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 @@ */ abstract class Mage_Sales_Model_Resource_Order_Comment_Collection_Abstract extends Mage_Sales_Model_Resource_Collection_Abstract