Skip to content

Commit a63a8f0

Browse files
committed
AC-1685: Fix Integration Tests to be compatible with PHP 8.1
1 parent e6910bd commit a63a8f0

File tree

7 files changed

+81
-14
lines changed

7 files changed

+81
-14
lines changed

app/code/Magento/ReleaseNotification/Model/Condition/CanViewNotification.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ public function isVisible(array $arguments)
8383

8484
if ($value === false) {
8585
$value = version_compare(
86-
$this->viewerLogger->get($userId)->getLastViewVersion(),
86+
$this->viewerLogger->get($userId)->getLastViewVersion() ?? '',
8787
$this->productMetadata->getVersion(),
8888
'<'
8989
);

app/code/Magento/ReleaseNotification/Test/Unit/Model/Condition/CanViewNotificationTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ public function isVisibleProvider()
122122
return [
123123
[false, '2.2.1-dev', '999.999.999-alpha'],
124124
[true, '2.2.1-dev', '2.0.0'],
125-
[true, '2.2.1-dev', '2.2.0'],
125+
[true, '2.2.1-dev', null],
126126
[false, '2.2.1-dev', '2.2.1'],
127127
[true, '2.2.1-dev', '2.2.0'],
128128
[true, '2.3.0', '2.2.0'],

app/code/Magento/Widget/Model/ResourceModel/Widget/Instance.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ protected function _saveLayoutUpdates($widgetInstance, $pageGroupData)
124124
$pageGroupData['template']
125125
);
126126
$insert = ['handle' => $handle, 'xml' => $xml];
127-
if (strlen($widgetInstance->getSortOrder())) {
127+
if ($widgetInstance->getSortOrder() !== null && strlen($widgetInstance->getSortOrder())) {
128128
$insert['sort_order'] = $widgetInstance->getSortOrder();
129129
}
130130

lib/internal/Magento/Framework/Code/Reader/ArgumentsReader.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,8 +110,11 @@ private function processType(\ReflectionClass $class, \Laminas\Code\Reflection\P
110110

111111
$type = $parameter->detectType();
112112

113+
/**
114+
* $type === null if it is unspecified
115+
* $type === 'null' if it is used in doc block
116+
*/
113117
if ($type === null || $type === 'null') {
114-
// check on null for PHP 8.1 compatibility, emulates the behavior from PHP 7.4
115118
return null;
116119
}
117120

lib/internal/Magento/Framework/Code/Test/Unit/Reader/ArgumentsReaderTest.php

Lines changed: 64 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -46,34 +46,62 @@ public function testGetConstructorArgumentsClassWithAllArgumentsType()
4646
'isOptional' => false,
4747
'default' => null,
4848
],
49+
'noType' => [
50+
'name' => 'noType',
51+
'position' => 3,
52+
'type' => '\\\\noType',
53+
'isOptional' => false,
54+
'default' => null,
55+
],
4956
'const' => [
5057
'name' => 'const',
51-
'position' => 3,
58+
'position' => 4,
5259
'type' => 'string',
5360
'isOptional' => true,
5461
'default' => 'Const Value',
5562
],
5663
'optionalNumValue' => [
5764
'name' => 'optionalNumValue',
58-
'position' => 4,
65+
'position' => 5,
5966
'type' => 'int',
6067
'isOptional' => true,
6168
'default' => 9807,
6269
],
6370
'optionalStringValue' => [
6471
'name' => 'optionalStringValue',
65-
'position' => 5,
72+
'position' => 6,
6673
'type' => 'string',
6774
'isOptional' => true,
6875
'default' => 'optional string',
6976
],
7077
'optionalArrayValue' => [
7178
'name' => 'optionalArrayValue',
72-
'position' => 6,
79+
'position' => 7,
7380
'type' => 'array',
7481
'isOptional' => true,
7582
'default' => "array('optionalKey' => 'optionalValue')",
7683
],
84+
'optNullValue' => [
85+
'name' => 'optNullValue',
86+
'position' => 8,
87+
'type' => null,
88+
'isOptional' => true,
89+
'default' => null,
90+
],
91+
'optNullIntValue' => [
92+
'name' => 'optNullIntValue',
93+
'position' => 9,
94+
'type' => null,
95+
'isOptional' => true,
96+
'default' => 1,
97+
],
98+
'optNoTypeValue' => [
99+
'name' => 'optNoTypeValue',
100+
'position' => 10,
101+
'type' => null,
102+
'isOptional' => true,
103+
'default' => null,
104+
],
77105
];
78106
$class = new \ReflectionClass('ClassWithAllArgumentTypes');
79107
$actualResult = $this->_model->getConstructorArguments($class);
@@ -113,34 +141,62 @@ public function testGetConstructorArgumentsClassWithoutOwnConstructorInheritedTr
113141
'isOptional' => false,
114142
'default' => null,
115143
],
144+
'noType' => [
145+
'name' => 'noType',
146+
'position' => 3,
147+
'type' => '\\\\noType',
148+
'isOptional' => false,
149+
'default' => null,
150+
],
116151
'const' => [
117152
'name' => 'const',
118-
'position' => 3,
153+
'position' => 4,
119154
'type' => 'string',
120155
'isOptional' => true,
121156
'default' => 'Const Value',
122157
],
123158
'optionalNumValue' => [
124159
'name' => 'optionalNumValue',
125-
'position' => 4,
160+
'position' => 5,
126161
'type' => 'int',
127162
'isOptional' => true,
128163
'default' => 9807,
129164
],
130165
'optionalStringValue' => [
131166
'name' => 'optionalStringValue',
132-
'position' => 5,
167+
'position' => 6,
133168
'type' => 'string',
134169
'isOptional' => true,
135170
'default' => 'optional string',
136171
],
137172
'optionalArrayValue' => [
138173
'name' => 'optionalArrayValue',
139-
'position' => 6,
174+
'position' => 7,
140175
'type' => 'array',
141176
'isOptional' => true,
142177
'default' => "array('optionalKey' => 'optionalValue')",
143178
],
179+
'optNullValue' => [
180+
'name' => 'optNullValue',
181+
'position' => 8,
182+
'type' => null,
183+
'isOptional' => true,
184+
'default' => null,
185+
],
186+
'optNullIntValue' => [
187+
'name' => 'optNullIntValue',
188+
'position' => 9,
189+
'type' => null,
190+
'isOptional' => true,
191+
'default' => 1,
192+
],
193+
'optNoTypeValue' => [
194+
'name' => 'optNoTypeValue',
195+
'position' => 10,
196+
'type' => null,
197+
'isOptional' => true,
198+
'default' => null,
199+
],
144200
];
145201
$class = new \ReflectionClass('ClassWithoutOwnConstruct');
146202
$actualResult = $this->_model->getConstructorArguments($class, false, true);

lib/internal/Magento/Framework/Code/Test/Unit/Reader/_files/ClassesForArgumentsReader.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,19 +51,27 @@ class ClassWithAllArgumentTypes
5151
* @param stdClass $stdClassObject
5252
* @param ClassWithoutConstruct $withoutConstructorClassObject
5353
* @param mixed $someVariable
54+
* @param $noType
5455
* @param string $const
5556
* @param int $optionalNumValue
5657
* @param string $optionalStringValue
5758
* @param array $optionalArrayValue
59+
* @param null $optNullValue
60+
* @param null|int $optNullIntValue first type from defined will be used
61+
* @param $optNoTypeValue
5862
*/
5963
public function __construct(
6064
\stdClass $stdClassObject,
6165
\ClassWithoutConstruct $withoutConstructorClassObject,
6266
$someVariable,
67+
$noType,
6368
$const = \ClassWithAllArgumentTypes::DEFAULT_VALUE,
6469
$optionalNumValue = 9807,
6570
$optionalStringValue = 'optional string',
66-
$optionalArrayValue = ['optionalKey' => 'optionalValue']
71+
$optionalArrayValue = ['optionalKey' => 'optionalValue'],
72+
$optNullValue = null,
73+
$optNullIntValue = 1,
74+
$optNoTypeValue = null
6775
) {
6876
$this->_stdClassObject = $stdClassObject;
6977
$this->_withoutConstructorClassObject = $withoutConstructorClassObject;

lib/internal/Magento/Framework/View/Page/Config.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -657,6 +657,6 @@ public function getIncludes()
657657
\Magento\Store\Model\ScopeInterface::SCOPE_STORE
658658
);
659659
}
660-
return $this->includes;
660+
return $this->includes ?? '';
661661
}
662662
}

0 commit comments

Comments
 (0)