Skip to content

Commit c70d674

Browse files
committed
Fixed php 8.1 deprecations to pass Integration Tests
1 parent 3d4095f commit c70d674

File tree

11 files changed

+61
-55
lines changed

11 files changed

+61
-55
lines changed

app/code/Magento/Backend/view/adminhtml/templates/widget/grid/extended.phtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,7 @@ script;
303303
script;
304304
endif;
305305

306-
if (strpos($block->getRowClickCallback(), 'order.') !== false):
306+
if ($block->getRowClickCallback() && strpos($block->getRowClickCallback(), 'order.') !== false):
307307
$scriptString .= <<<script
308308
309309
deps.push('Magento_Sales/order/create/form')

app/code/Magento/Catalog/view/frontend/templates/product/list.phtml

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,8 @@ $_helper = $block->getData('outputHelper');
8787
data-product-sku="<?= $escaper->escapeHtml($_product->getSku()) ?>"
8888
action="<?= $escaper->escapeUrl($postParams['action']) ?>"
8989
method="post">
90-
<?php $optionsData = $block->getData('viewModel')->getOptionsData($_product); ?>
91-
<?php foreach ($optionsData as $optionItem): ?>
90+
<?php $options = $block->getData('viewModel')->getOptionsData($_product); ?>
91+
<?php foreach ($options as $optionItem): ?>
9292
<input type="hidden"
9393
name="<?= $escaper->escapeHtml($optionItem['name']) ?>"
9494
value="<?= $escaper->escapeHtml($optionItem['value']) ?>">
@@ -119,7 +119,7 @@ $_helper = $block->getData('outputHelper');
119119
<?php endif; ?>
120120
<?php endif; ?>
121121
</div>
122-
<?= strpos($pos, $viewMode . '-primary') ?
122+
<?= ($pos && strpos($pos, $viewMode . '-primary')) ?
123123
/* @noEscape */ $secureRenderer->renderStyleAsTag(
124124
$position,
125125
'product-item-info_' . $_product->getId() . ' div.actions-primary'
@@ -129,7 +129,7 @@ $_helper = $block->getData('outputHelper');
129129
<?= $addToBlock->setProduct($_product)->getChildHtml() ?>
130130
<?php endif; ?>
131131
</div>
132-
<?= strpos($pos, $viewMode . '-secondary') ?
132+
<?= ($pos && strpos($pos, $viewMode . '-secondary')) ?
133133
/* @noEscape */ $secureRenderer->renderStyleAsTag(
134134
$position,
135135
'product-item-info_' . $_product->getId() . ' div.actions-secondary'
@@ -150,7 +150,7 @@ $_helper = $block->getData('outputHelper');
150150
</div>
151151
</div>
152152
</div>
153-
<?= strpos($pos, $viewMode . '-actions') ?
153+
<?= ($pos && strpos($pos, $viewMode . '-actions')) ?
154154
/* @noEscape */ $secureRenderer->renderStyleAsTag(
155155
$position,
156156
'product-item-info_' . $_product->getId() . ' div.product-item-actions'
@@ -160,6 +160,7 @@ $_helper = $block->getData('outputHelper');
160160
</ol>
161161
</div>
162162
<?= $block->getChildBlock('toolbar')->setIsBottom(true)->toHtml() ?>
163+
<?php // phpcs:ignore Magento2.Legacy.PhtmlTemplate ?>
163164
<script type="text/x-magento-init">
164165
{
165166
"[data-role=tocart-form], .form.map.checkout": {

app/code/Magento/Cms/Block/Adminhtml/Wysiwyg/Images/Tree.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ public function getTreeLoaderUrl()
115115

116116
$currentTreePath = $this->getRequest()->getParam('current_tree_path');
117117

118-
if (strlen($currentTreePath)) {
118+
if ($currentTreePath && strlen($currentTreePath)) {
119119
$params['current_tree_path'] = $currentTreePath;
120120
}
121121

@@ -138,7 +138,7 @@ public function getRootNodeName()
138138
/**
139139
* Return tree node full path based on current path
140140
*
141-
* @return string
141+
* @return string[]
142142
*/
143143
public function getTreeCurrentPath()
144144
{
@@ -150,7 +150,7 @@ public function getTreeCurrentPath()
150150
$path = $this->_coreRegistry->registry('storage')->getSession()->getCurrentPath();
151151
}
152152

153-
if (strlen($path)) {
153+
if ($path) {
154154
$path = str_replace($this->_cmsWysiwygImages->getStorageRoot(), '', $path);
155155
$relative = [];
156156
foreach (explode('/', $path) as $dirName) {

app/code/Magento/Cron/Model/Schedule.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,15 +36,15 @@
3636
*/
3737
class Schedule extends \Magento\Framework\Model\AbstractModel
3838
{
39-
const STATUS_PENDING = 'pending';
39+
public const STATUS_PENDING = 'pending';
4040

41-
const STATUS_RUNNING = 'running';
41+
public const STATUS_RUNNING = 'running';
4242

43-
const STATUS_SUCCESS = 'success';
43+
public const STATUS_SUCCESS = 'success';
4444

45-
const STATUS_MISSED = 'missed';
45+
public const STATUS_MISSED = 'missed';
4646

47-
const STATUS_ERROR = 'error';
47+
public const STATUS_ERROR = 'error';
4848

4949
/**
5050
* @var TimezoneInterface
@@ -129,7 +129,7 @@ public function trySchedule()
129129
return false;
130130
}
131131
$configTimeZone = $this->timezoneConverter->getConfigTimezone();
132-
$storeDateTime = $this->dateTimeFactory->create(null, new \DateTimeZone($configTimeZone));
132+
$storeDateTime = $this->dateTimeFactory->create('now', new \DateTimeZone($configTimeZone));
133133
if (!is_numeric($time)) {
134134
//convert time from UTC to admin store timezone
135135
//we assume that all schedules in configuration (crontab.xml and DB tables) are in admin store timezone

app/code/Magento/Integration/Block/Adminhtml/Widget/Grid/Column/Renderer/Name.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,6 @@ public function render(\Magento\Framework\DataObject $row)
3636
*/
3737
protected function isUrlSecure($url)
3838
{
39-
return (strpos($url, 'http:') !== 0);
39+
return (is_string($url) && strpos($url, 'http:') !== 0);
4040
}
4141
}

app/code/Magento/Tax/Model/Calculation/Rate.php

Lines changed: 32 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
use Magento\Framework\Api\AttributeValueFactory;
1111
use Magento\Framework\Exception\CouldNotDeleteException;
1212
use Magento\Tax\Api\Data\TaxRateInterface;
13+
use Magento\Tax\Api\Data\TaxRateTitleInterface;
1314

1415
/**
1516
* Tax Rate Model
@@ -21,20 +22,22 @@ class Rate extends \Magento\Framework\Model\AbstractExtensibleModel implements T
2122
/**#@+
2223
* Constants defined for keys of array, makes typos less likely
2324
*/
24-
const KEY_ID = 'id';
25-
const KEY_COUNTRY_ID = 'tax_country_id';
26-
const KEY_REGION_ID = 'tax_region_id';
27-
const KEY_REGION_NAME = 'region_name';
28-
const KEY_POSTCODE = 'tax_postcode';
29-
const KEY_ZIP_IS_RANGE = 'zip_is_range';
30-
const KEY_ZIP_RANGE_FROM = 'zip_from';
31-
const KEY_ZIP_RANGE_TO = 'zip_to';
32-
const KEY_PERCENTAGE_RATE = 'rate';
33-
const KEY_CODE = 'code';
34-
const KEY_TITLES = 'titles';
25+
public const KEY_ID = 'id';
26+
public const KEY_COUNTRY_ID = 'tax_country_id';
27+
public const KEY_REGION_ID = 'tax_region_id';
28+
public const KEY_REGION_NAME = 'region_name';
29+
public const KEY_POSTCODE = 'tax_postcode';
30+
public const KEY_ZIP_IS_RANGE = 'zip_is_range';
31+
public const KEY_ZIP_RANGE_FROM = 'zip_from';
32+
public const KEY_ZIP_RANGE_TO = 'zip_to';
33+
public const KEY_PERCENTAGE_RATE = 'rate';
34+
public const KEY_CODE = 'code';
35+
public const KEY_TITLES = 'titles';
3536
/**#@-*/
3637

37-
/**#@-*/
38+
/**
39+
* @var TaxRateTitleInterface[]
40+
*/
3841
protected $_titles = null;
3942

4043
/**
@@ -163,7 +166,7 @@ public function beforeSave()
163166
} else {
164167
$taxPostCode = $this->getTaxPostcode();
165168

166-
if (strlen($taxPostCode) > 10) {
169+
if ($taxPostCode && strlen($taxPostCode) > 10) {
167170
$taxPostCode = substr($taxPostCode, 0, 10);
168171
}
169172

@@ -212,7 +215,8 @@ public function beforeDelete()
212215

213216
/**
214217
* After rate delete
215-
* redeclared for dispatch tax_settings_change_after event
218+
*
219+
* Redeclared for dispatch tax_settings_change_after event
216220
*
217221
* @return \Magento\Tax\Model\Calculation\Rate
218222
*/
@@ -266,7 +270,7 @@ public function getTitleModel()
266270
}
267271

268272
/**
269-
* {@inheritdoc}
273+
* @inheritdoc
270274
*/
271275
public function getTitles()
272276
{
@@ -314,7 +318,7 @@ protected function _isInRule()
314318
}
315319

316320
/**
317-
* {@inheritdoc}
321+
* @inheritdoc
318322
*/
319323
public function getRegionName()
320324
{
@@ -326,72 +330,72 @@ public function getRegionName()
326330
}
327331

328332
/**
333+
* @inheritdoc
329334
* @codeCoverageIgnoreStart
330-
* {@inheritdoc}
331335
*/
332336
public function getTaxCalculationRateId()
333337
{
334338
return $this->getData(self::KEY_ID);
335339
}
336340

337341
/**
338-
* {@inheritdoc}
342+
* @inheritdoc
339343
*/
340344
public function getTaxCountryId()
341345
{
342346
return $this->getData(self::KEY_COUNTRY_ID);
343347
}
344348

345349
/**
346-
* {@inheritdoc}
350+
* @inheritdoc
347351
*/
348352
public function getTaxRegionId()
349353
{
350354
return $this->getData(self::KEY_REGION_ID);
351355
}
352356

353357
/**
354-
* {@inheritdoc}
358+
* @inheritdoc
355359
*/
356360
public function getTaxPostcode()
357361
{
358362
return $this->getData(self::KEY_POSTCODE);
359363
}
360364

361365
/**
362-
* {@inheritdoc}
366+
* @inheritdoc
363367
*/
364368
public function getZipFrom()
365369
{
366370
return $this->getData(self::KEY_ZIP_RANGE_FROM);
367371
}
368372

369373
/**
370-
* {@inheritdoc}
374+
* @inheritdoc
371375
*/
372376
public function getZipTo()
373377
{
374378
return $this->getData(self::KEY_ZIP_RANGE_TO);
375379
}
376380

377381
/**
378-
* {@inheritdoc}
382+
* @inheritdoc
379383
*/
380384
public function getRate()
381385
{
382386
return $this->getData(self::KEY_PERCENTAGE_RATE);
383387
}
384388

385389
/**
386-
* {@inheritdoc}
390+
* @inheritdoc
387391
*/
388392
public function getCode()
389393
{
390394
return $this->getData(self::KEY_CODE);
391395
}
392396

393397
/**
394-
* {@inheritdoc}
398+
* @inheritdoc
395399
*/
396400
public function getZipIsRange()
397401
{
@@ -500,7 +504,7 @@ public function setCode($code)
500504
/**
501505
* Set tax rate titles
502506
*
503-
* @param \Magento\Tax\Api\Data\TaxRateTitleInterface[] $titles
507+
* @param TaxRateTitleInterface[] $titles
504508
* @return $this
505509
*/
506510
public function setTitles(array $titles = null)
@@ -511,7 +515,7 @@ public function setTitles(array $titles = null)
511515
// @codeCoverageIgnoreEnd
512516

513517
/**
514-
* {@inheritdoc}
518+
* @inheritdoc
515519
*
516520
* @return \Magento\Tax\Api\Data\TaxRateExtensionInterface|null
517521
*/
@@ -521,7 +525,7 @@ public function getExtensionAttributes()
521525
}
522526

523527
/**
524-
* {@inheritdoc}
528+
* @inheritdoc
525529
*
526530
* @param \Magento\Tax\Api\Data\TaxRateExtensionInterface $extensionAttributes
527531
* @return $this

dev/tests/integration/testsuite/Magento/Paypal/Model/Api/NvpTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,7 @@ public function testCallRefundTransaction()
156156
[],
157157
$httpQuery
158158
);
159+
$this->httpClient->method('read')->willReturn('');
159160

160161
$this->nvpApi->callRefundTransaction();
161162
}

dev/tests/integration/testsuite/Magento/Security/Model/Plugin/AuthSessionTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ public function testConsecutiveProcessProlong()
9595
);
9696
$adminSessionInfoId = $this->authSession->getAdminSessionInfoId();
9797
$prolongsDiff = log($this->securityConfig->getAdminSessionLifetime()) - 2; // X from comment above
98-
$dateInPast = $this->dateTime->formatDate($this->authSession->getUpdatedAt() - $prolongsDiff);
98+
$dateInPast = $this->dateTime->formatDate((int) ($this->authSession->getUpdatedAt() - $prolongsDiff));
9999
$this->adminSessionsManager->getCurrentSession()
100100
->setData(
101101
'updated_at',
@@ -127,7 +127,7 @@ public function testProcessProlong()
127127
);
128128
$adminSessionInfoId = $this->authSession->getAdminSessionInfoId();
129129
$prolongsDiff = 4 * log($this->securityConfig->getAdminSessionLifetime()) + 2; // X from comment above
130-
$dateInPast = $this->dateTime->formatDate($this->authSession->getUpdatedAt() - $prolongsDiff);
130+
$dateInPast = $this->dateTime->formatDate((int) ($this->authSession->getUpdatedAt() - $prolongsDiff));
131131
$this->adminSessionsManager->getCurrentSession()
132132
->setData(
133133
'updated_at',
@@ -171,7 +171,7 @@ public function testProcessProlongWithExpiredUser()
171171
// need to trigger a prolong
172172
$adminSessionInfoId = $this->authSession->getAdminSessionInfoId();
173173
$prolongsDiff = 4 * log($this->securityConfig->getAdminSessionLifetime()) + 2;
174-
$dateInPast = $this->dateTime->formatDate($this->authSession->getUpdatedAt() - $prolongsDiff);
174+
$dateInPast = $this->dateTime->formatDate((int) ($this->authSession->getUpdatedAt() - $prolongsDiff));
175175
$this->adminSessionsManager->getCurrentSession()
176176
->setData(
177177
'updated_at',

lib/internal/Magento/Framework/Stdlib/DateTime/Timezone.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ public function formatDate($date = null, $format = \IntlDateFormatter::SHORT, $s
240240
$formatTime = $showTime ? $format : \IntlDateFormatter::NONE;
241241

242242
if (!($date instanceof \DateTimeInterface)) {
243-
$date = new \DateTime($date);
243+
$date = new \DateTime($date ?? 'now');
244244
}
245245

246246
return $this->formatDateTime($date, $format, $formatTime);

setup/src/Magento/Setup/Console/Command/GenerateFixturesCommand.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,8 +122,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
122122
}
123123

124124
$totalEndTime = microtime(true);
125-
$totalResultTime = $totalEndTime - $totalStartTime;
126-
125+
$totalResultTime = (int) ($totalEndTime - $totalStartTime);
127126
$output->writeln('<info>Total execution time: ' . gmdate('H:i:s', $totalResultTime) . '</info>');
128127
} catch (\Exception $e) {
129128
$output->writeln('<error>' . $e->getMessage() . '</error>');

0 commit comments

Comments
 (0)