Skip to content

Commit ca753ec

Browse files
committed
Merge remote-tracking branch 'anzin/php8-compatibility/fixes-for-integration-tests-p1' into platform-health
2 parents 9a72a4f + 5fbc947 commit ca753ec

File tree

15 files changed

+92
-47
lines changed

15 files changed

+92
-47
lines changed

app/code/Magento/Analytics/Model/Config/Mapper.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,9 @@ public function execute($configData)
5252
$providerData['parameters'] = !empty($providerData['parameters'])
5353
? reset($providerData['parameters'])
5454
: [];
55-
$providerData['parameters'] = array_map(
56-
'reset',
57-
$providerData['parameters']
58-
);
55+
array_walk($providerData['parameters'], function (&$array) {
56+
$array = reset($array);
57+
});
5958
$providers[$providerType] = $providerData;
6059
}
6160
$files[$fileData['name']] = $fileData;

app/code/Magento/Customer/Model/AccountManagement.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1116,7 +1116,7 @@ public function validate(CustomerInterface $customer)
11161116
// phpcs:ignore Magento2.Functions.DiscouragedFunction
11171117
call_user_func_array(
11181118
'array_merge',
1119-
$this->getEavValidator()->getMessages()
1119+
array_values($this->getEavValidator()->getMessages())
11201120
)
11211121
);
11221122
}

app/code/Magento/CustomerImportExport/Model/ResourceModel/Import/Address/Storage.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ private function loadAddresses(array $customerIds): void
9898
$select->reset(Select::COLUMNS)->columns([$tableId . '.entity_id', $tableId . '.parent_id']);
9999

100100
$pageSize = $this->config->getValue(AbstractEntity::XML_PATH_PAGE_SIZE);
101+
$pageSize = $pageSize !== null ? (int) $pageSize : null;
101102
$getChuck = function (int $offset) use ($customerIds, $pageSize) {
102103
return array_slice($customerIds, $offset, $pageSize);
103104
};

app/code/Magento/Paypal/Model/Cart.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ protected function _importItemsFromSalesModel()
150150
$this->addSubtotal($this->_salesModel->getBaseSubtotal());
151151
$this->addTax($this->_salesModel->getBaseTaxAmount());
152152
$this->addShipping($this->_salesModel->getBaseShippingAmount());
153-
$this->addDiscount(abs($this->_salesModel->getBaseDiscountAmount()));
153+
$this->addDiscount(abs((float) $this->_salesModel->getBaseDiscountAmount()));
154154
}
155155

156156
/**

app/code/Magento/Paypal/Model/Express/Checkout.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -505,7 +505,7 @@ public function start($returnUrl, $cancelUrl, $button = null)
505505
$solutionType = $this->_config->getMerchantCountry() == 'DE'
506506
? \Magento\Paypal\Model\Config::EC_SOLUTION_TYPE_MARK
507507
: $this->_config->getValue('solutionType');
508-
$totalAmount = round($this->_quote->getBaseGrandTotal(), 2);
508+
$totalAmount = round((float)$this->_quote->getBaseGrandTotal(), 2);
509509
$this->_getApi()->setAmount($totalAmount)
510510
->setCurrencyCode($this->_quote->getBaseCurrencyCode())
511511
->setInvNum($this->_quote->getReservedOrderId())
@@ -663,7 +663,7 @@ public function returnFromPaypal($token, string $payerIdentifier = null)
663663
) === \Magento\Paypal\Model\Config::REQUIRE_BILLING_ADDRESS_ALL;
664664

665665
if ($isButton && !$requireBillingAddress && !$quote->isVirtual()) {
666-
$billingAddress = clone $shippingAddress;
666+
$billingAddress = clone $shippingAddress; /** @phpstan-ignore-line */
667667
$billingAddress->unsAddressId()->unsAddressType()->setCustomerAddressId(null);
668668
$data = $billingAddress->getData();
669669
$data['save_in_address_book'] = 0;

app/code/Magento/Quote/Model/ResourceModel/Quote.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,11 @@ protected function _getLoadSelect($field, $value, $object)
6161
{
6262
$select = parent::_getLoadSelect($field, $value, $object);
6363
$storeIds = $object->getSharedStoreIds();
64+
6465
if ($storeIds) {
65-
if ($storeIds != ['*']) {
66+
// The comparison the arrays [0] != ['*'] returns `true` in PHP >= 8 and `false` otherwise
67+
// This check emulates an old behavior (as it was in PHP 7)
68+
if ($storeIds !== ['*'] && $storeIds !== [0]) {
6669
$select->where('store_id IN (?)', $storeIds);
6770
}
6871
} else {

app/code/Magento/Sales/Model/Order/ShipmentFactory.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ private function validateItem(\Magento\Sales\Model\Order\Item $orderItem, array
165165

166166
// Remove from shipment items without qty or with qty=0
167167
if (!$orderItem->isDummy(true)
168-
&& (!isset($items[$orderItem->getId()]) || $items[$orderItem->getId()] <= 0)
168+
&& (!isset($items[$orderItem->getId()]) || (int) $items[$orderItem->getId()] <= 0)
169169
) {
170170
return false;
171171
}
@@ -281,12 +281,14 @@ protected function canShipItem($item, array $items = [])
281281
return isset($items[$parent->getId()]) && $items[$parent->getId()] > 0;
282282
}
283283
}
284-
} else {
285-
return $item->getQtyToShip() > 0;
286284
}
285+
286+
return $item->getQtyToShip() > 0;
287287
}
288288

289289
/**
290+
* Casts Qty to float or integer type
291+
*
290292
* @param Item $item
291293
* @param string|int|float $qty
292294
* @return float|int

app/code/Magento/Sales/Model/ResourceModel/Order/Status.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ public function checkIsStateLast($state)
206206
$this->getConnection()->select()
207207
->from(['sss' => $this->stateTable], [])
208208
->where('state = ?', $state)
209-
->columns([new\Zend_Db_Expr('COUNT(1)')])
209+
->columns([new \Zend_Db_Expr('COUNT(1)')])
210210
));
211211
}
212212

app/code/Magento/Usps/Model/Carrier.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -634,7 +634,9 @@ protected function _parseXmlResponse($response)
634634
);
635635
}
636636
}
637-
asort($priceArr);
637+
uasort($priceArr, function ($previous, $next) {
638+
return ($previous <= $next) ? -1 : 1;
639+
});
638640
} elseif (!$isUS && is_object($xml->Package->Service)) {
639641
/*
640642
* International Rates
@@ -654,7 +656,9 @@ protected function _parseXmlResponse($response)
654656
);
655657
}
656658
}
657-
asort($priceArr);
659+
uasort($priceArr, function ($previous, $next) {
660+
return ($previous <= $next) ? -1 : 1;
661+
});
658662
}
659663
}
660664
}

dev/tests/integration/testsuite/Magento/CatalogImportExport/Model/AbstractProductExportImportTestCase.php

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
*/
66
namespace Magento\CatalogImportExport\Model;
77

8+
use Magento\CatalogImportExport\Model\Export\Product;
89
use Magento\Framework\App\Bootstrap;
910
use Magento\Framework\App\Filesystem\DirectoryList;
1011
use Magento\ImportExport\Model\Export\Adapter\AbstractAdapter;
@@ -358,13 +359,10 @@ protected function executeImportReplaceTest(
358359
$index++;
359360
}
360361

361-
$exportProduct = $this->objectManager->create(\Magento\CatalogImportExport\Model\Export\Product::class);
362+
$exportProduct = $this->objectManager->create(Product::class);
362363
if ($usePagination) {
363364
/** @var \ReflectionProperty $itemsPerPageProperty */
364-
$itemsPerPageProperty = $this->objectManager->create(\ReflectionProperty::class, [
365-
'class' => \Magento\CatalogImportExport\Model\Export\Product::class,
366-
'name' => '_itemsPerPage'
367-
]);
365+
$itemsPerPageProperty = new \ReflectionProperty(Product::class, '_itemsPerPage');
368366
$itemsPerPageProperty->setAccessible(true);
369367
$itemsPerPageProperty->setValue($exportProduct, 1);
370368
}
@@ -407,16 +405,16 @@ protected function executeImportReplaceTest(
407405
/**
408406
* Export products in the system.
409407
*
410-
* @param \Magento\CatalogImportExport\Model\Export\Product|null $exportProduct
408+
* @param Product|null $exportProduct
411409
* @return string Return exported file
412410
*/
413-
private function exportProducts(\Magento\CatalogImportExport\Model\Export\Product $exportProduct = null)
411+
private function exportProducts(Product $exportProduct = null)
414412
{
415413
$csvfile = uniqid('importexport_') . '.csv';
416414
$this->csvFile = $csvfile;
417415

418416
$exportProduct = $exportProduct ?: $this->objectManager->create(
419-
\Magento\CatalogImportExport\Model\Export\Product::class
417+
Product::class
420418
);
421419
$this->writer = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create(
422420
\Magento\ImportExport\Model\Export\Adapter\Csv::class,

0 commit comments

Comments
 (0)