Skip to content

Commit 5f76c92

Browse files
authored
Merge pull request #7215 from magento-trigger/ph-delivery
[Platform Health] Updates for PHP8.1
2 parents 6818648 + ac0be8c commit 5f76c92

File tree

10 files changed

+31
-14
lines changed

10 files changed

+31
-14
lines changed

app/code/Magento/CatalogInventory/Model/StockStateProvider.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ public function checkQuoteItemQty(StockItemInterface $stockItem, $qty, $summaryQ
135135
$result->addData($this->checkQtyIncrements($stockItem, $qty)->getData());
136136

137137
$result->setItemIsQtyDecimal($stockItem->getIsQtyDecimal());
138-
if (!$stockItem->getIsQtyDecimal() && (floor($qty) !== $qty)) {
138+
if (!$stockItem->getIsQtyDecimal() && (floor($qty) !== (float) $qty)) {
139139
$result->setHasError(true)
140140
->setMessage(__('You cannot use decimal quantity for this product.'))
141141
->setErrorCode('qty_decimal')

dev/tests/api-functional/testsuite/Magento/Webapi/WsdlGenerationFromDataObjectTest.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,10 @@ public function testNoAuthorizedServices()
7171
curl_setopt($connection, CURLOPT_RETURNTRANSFER, 1);
7272
$responseContent = curl_exec($connection);
7373
$this->assertEquals(curl_getinfo($connection, CURLINFO_HTTP_CODE), 401);
74-
$this->assertStringContainsString("The consumer isn't authorized to access %resources.", $responseContent);
74+
$this->assertStringContainsString(
75+
"The consumer isn't authorized to access %resources.",
76+
htmlspecialchars_decode($responseContent, ENT_QUOTES)
77+
);
7578
}
7679

7780
public function testInvalidWsdlUrlNoServices()

lib/internal/Magento/Framework/App/Test/Unit/StaticResourceTest.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -328,6 +328,9 @@ public function testLaunchWrongPathProductionMode()
328328
$this->responseMock->expects($this->once())
329329
->method('setHttpResponseCode')
330330
->with(404);
331+
$this->driverMock->expects($this->once())
332+
->method('getRealPathSafety')
333+
->willReturnArgument(0);
331334
$this->object->launch();
332335
}
333336

lib/internal/Magento/Framework/App/Test/Unit/ViewTest.php

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,7 @@ public function testLoadLayoutWhenLayoutAlreadyLoaded(): void
155155
$this->expectException('RuntimeException');
156156
$this->expectExceptionMessage('Layout must be loaded only once.');
157157
$this->_view->setIsLayoutLoaded(true);
158+
// phpcs:ignore Magento2.Legacy.ObsoleteResponse
158159
$this->_view->loadLayout();
159160
}
160161

@@ -166,7 +167,8 @@ public function testLoadLayoutWithDefaultSetup(): void
166167
$this->_layoutProcessor
167168
->method('addHandle')
168169
->withConsecutive(['default']);
169-
$this->_requestMock->expects($this->any())->method('getFullActionName')->willReturn('action_name');
170+
$this->_requestMock->method('getFullActionName')->willReturn('action_name');
171+
// phpcs:ignore Magento2.Legacy.ObsoleteResponse
170172
$this->_view->loadLayout();
171173
}
172174

@@ -175,6 +177,8 @@ public function testLoadLayoutWithDefaultSetup(): void
175177
*/
176178
public function testLoadLayoutWhenBlocksNotGenerated(): void
177179
{
180+
$this->_requestMock->method('getFullActionName')->willReturn('action_name');
181+
// phpcs:ignore Magento2.Legacy.ObsoleteResponse
178182
$this->_view->loadLayout('', false, true);
179183
}
180184

@@ -183,6 +187,8 @@ public function testLoadLayoutWhenBlocksNotGenerated(): void
183187
*/
184188
public function testLoadLayoutWhenXmlNotGenerated(): void
185189
{
190+
$this->_requestMock->method('getFullActionName')->willReturn('action_name');
191+
// phpcs:ignore Magento2.Legacy.ObsoleteResponse
186192
$this->_view->loadLayout('', true, false);
187193
}
188194

@@ -263,8 +269,12 @@ public function testGenerateLayoutBlocksWhenFlagIsSet(): void
263269
*/
264270
public function testRenderLayoutIfActionFlagExist(): void
265271
{
266-
$this->_actionFlagMock->expects($this->once())->method('get')->with('', 'no-renderLayout')->willReturn(true);
272+
$this->_actionFlagMock->expects($this->once())
273+
->method('get')
274+
->with('', 'no-renderLayout')
275+
->willReturn(true);
267276
$this->_eventManagerMock->expects($this->never())->method('dispatch');
277+
// phpcs:ignore Magento2.Legacy.ObsoleteResponse
268278
$this->_view->renderLayout();
269279
}
270280

@@ -279,6 +289,7 @@ public function testRenderLayoutWhenOutputNotEmpty(): void
279289
->willReturn(false);
280290
$this->_layoutMock->expects($this->once())->method('addOutputElement')->with('output');
281291
$this->resultPage->expects($this->once())->method('renderResult')->with($this->response);
292+
// phpcs:ignore Magento2.Legacy.ObsoleteResponse
282293
$this->_view->renderLayout('output');
283294
}
284295

@@ -294,6 +305,7 @@ public function testRenderLayoutWhenOutputEmpty(): void
294305

295306
$this->_layoutMock->expects($this->never())->method('addOutputElement');
296307
$this->resultPage->expects($this->once())->method('renderResult')->with($this->response);
308+
// phpcs:ignore Magento2.Legacy.ObsoleteResponse
297309
$this->_view->renderLayout();
298310
}
299311
}

lib/internal/Magento/Framework/Code/Generator/EntityAbstract.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,8 +157,7 @@ public function getSourceClassNameWithoutNamespace()
157157
*/
158158
protected function _getFullyQualifiedClassName($className)
159159
{
160-
$className = ltrim($className, '\\');
161-
return $className ? '\\' . $className : '';
160+
return $className ? '\\' . ltrim($className, '\\') : '';
162161
}
163162

164163
/**

lib/internal/Magento/Framework/HTTP/PhpEnvironment/RemoteAddress.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ function (string $ip) {
9999
return !in_array(trim($ip), $this->trustedProxies, true);
100100
}
101101
);
102-
$remoteAddress = trim(array_pop($ipList));
102+
$remoteAddress = empty($ipList) ? '' : trim(array_pop($ipList));
103103
} else {
104104
$remoteAddress = trim(reset($ipList));
105105
}

lib/internal/Magento/Framework/Mview/View/Changelog.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ public function getVersion()
265265
*/
266266
public function getName()
267267
{
268-
if (strlen($this->viewId) == 0) {
268+
if (!$this->viewId || strlen($this->viewId) == 0) {
269269
throw new \DomainException(
270270
new Phrase("View's identifier is not set")
271271
);

lib/internal/Magento/Framework/ObjectManager/Test/Unit/Config/ConfigTest.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,11 @@ public function testExtendWithCacheMock()
5656
$cache = $this->getMockForAbstractClass(ConfigCacheInterface::class);
5757
$cache->expects($this->once())->method('get')->willReturn(false);
5858

59-
$config = new Config(null, $definitions);
6059
$serializerMock = $this->getMockForAbstractClass(SerializerInterface::class);
61-
$serializerMock->expects($this->exactly(2))
62-
->method('serialize');
60+
$serializerMock->expects($this->atLeast(2))
61+
->method('serialize')
62+
->willReturn('[[],[],[],[]]');
63+
$config = new Config(null, $definitions, $serializerMock);
6364
$this->objectManagerHelper->setBackwardCompatibleProperty(
6465
$config,
6566
'serializer',

lib/internal/Magento/Framework/Serialize/Test/Unit/Serializer/JsonHexTagTest.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,6 @@ public function unserializeExceptionDataProvider(): array
115115
return [
116116
[''],
117117
[false],
118-
[null],
119118
['{']
120119
];
121120
}

setup/src/Magento/Setup/Fixtures/CartPriceRulesFixture.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ public function generateAdvancedCondition($ruleId, $categoriesArray)
264264
'type' => \Magento\SalesRule\Model\Rule\Condition\Product::class,
265265
'attribute' => 'category_ids',
266266
'operator' => '==',
267-
'value' => $categoriesArray[($ruleId / 4) % count($categoriesArray)][0],
267+
'value' => $categoriesArray[intdiv($ruleId, 4) % count($categoriesArray)][0],
268268
];
269269

270270
$subtotal = [0, 5, 10, 15];
@@ -316,7 +316,7 @@ public function generateAdvancedCondition($ruleId, $categoriesArray)
316316
'type' => \Magento\SalesRule\Model\Rule\Condition\Address::class,
317317
'attribute' => 'region',
318318
'operator' => '==',
319-
'value' => $regions[($ruleId / 4) % 50],
319+
'value' => $regions[intdiv($ruleId, 4) % 50],
320320
];
321321

322322
$subtotals = [0, 5, 10, 15];

0 commit comments

Comments
 (0)