Skip to content

Commit e8e4b1a

Browse files
Merge remote-tracking branch '39882/remove-legacy-code' into comprs_june
2 parents 7acd205 + 9ccfe3d commit e8e4b1a

File tree

5 files changed

+16
-59
lines changed

5 files changed

+16
-59
lines changed

app/bootstrap.php

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,8 @@
1313
}
1414
#ini_set('display_errors', 1);
1515

16-
/* PHP version validation */
17-
if (!defined('PHP_VERSION_ID') || PHP_VERSION_ID < 80100) {
18-
if (PHP_SAPI == 'cli') {
16+
if (PHP_VERSION_ID < 80100) {
17+
if (PHP_SAPI === 'cli') {
1918
echo 'Magento supports PHP 8.1.0 or later. ' .
2019
'Please read https://experienceleague.adobe.com/docs/commerce-operations/installation-guide/system-requirements.html';
2120
} else {
@@ -31,16 +30,6 @@
3130
exit(1);
3231
}
3332

34-
// PHP 8 compatibility. Define constants that are not present in PHP < 8.0
35-
if (!defined('PHP_VERSION_ID') || PHP_VERSION_ID < 80000) {
36-
if (!defined('T_NAME_QUALIFIED')) {
37-
define('T_NAME_QUALIFIED', 24001);
38-
}
39-
if (!defined('T_NAME_FULLY_QUALIFIED')) {
40-
define('T_NAME_FULLY_QUALIFIED', 24002);
41-
}
42-
}
43-
4433
require_once __DIR__ . '/autoload.php';
4534
// Sets default autoload mappings, may be overridden in Bootstrap::create
4635
\Magento\Framework\App\Bootstrap::populateAutoloader(BP, []);

dev/tests/static/framework/bootstrap.php

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,6 @@
2121
define('TESTS_TEMP_DIR', dirname(__DIR__) . '/tmp');
2222
}
2323

24-
// PHP 8 compatibility. Define constants that are not present in PHP < 8.0
25-
if (!defined('PHP_VERSION_ID') || PHP_VERSION_ID < 80000) {
26-
if (!defined('T_NAME_QUALIFIED')) {
27-
define('T_NAME_QUALIFIED', 24001);
28-
}
29-
if (!defined('T_NAME_FULLY_QUALIFIED')) {
30-
define('T_NAME_FULLY_QUALIFIED', 24002);
31-
}
32-
}
3324

3425
setCustomErrorHandler();
3526

dev/tests/unit/framework/bootstrap.php

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,6 @@
1010
define('TESTS_TEMP_DIR', dirname(__DIR__) . '/tmp');
1111
}
1212

13-
// PHP 8 compatibility. Define constants that are not present in PHP < 8.0
14-
if (!defined('PHP_VERSION_ID') || PHP_VERSION_ID < 80000) {
15-
if (!defined('T_NAME_QUALIFIED')) {
16-
define('T_NAME_QUALIFIED', 24001);
17-
}
18-
if (!defined('T_NAME_FULLY_QUALIFIED')) {
19-
define('T_NAME_FULLY_QUALIFIED', 24002);
20-
}
21-
}
22-
2313
require_once __DIR__ . '/autoload.php';
2414

2515
setCustomErrorHandler();
@@ -59,7 +49,7 @@ function ($errNo, $errStr, $errFile, $errLine) {
5949
E_USER_DEPRECATED => 'User Deprecated',
6050
];
6151

62-
$errName = isset($errorNames[$errNo]) ? $errorNames[$errNo] : "";
52+
$errName = $errorNames[$errNo] ?? "";
6353

6454
throw new \PHPUnit\Framework\Exception(
6555
sprintf("%s: %s in %s:%s.", $errName, $errStr, $errFile, $errLine),

lib/internal/Magento/Framework/DB/DataConverter/SerializedToJson.php

Lines changed: 5 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
22
/**
3-
* Copyright © Magento, Inc. All rights reserved.
4-
* See COPYING.txt for license details.
3+
* Copyright 2016 Adobe
4+
* All rights reserved.
55
*/
66
namespace Magento\Framework\DB\DataConverter;
77

@@ -95,36 +95,21 @@ protected function unserializeValue($value)
9595
/**
9696
* Encode value with json encoder.
9797
*
98-
* In PHP version < 7.1.0 serialize() uses PG(serialize_precision) which set to 17 be default.
99-
* Since json_encode() uses EG(precision) which set to 14 be default, json_encode() removes lower digits of
100-
* fraction parts and destroys original value even if PHP's float could hold more precise float value.
101-
* To prevent this issue EG(precision) is set to 17 to be equal with PG(serialize_precision) during
102-
* data converting from serialized format to JSON.
103-
*
104-
* In PHP version >= 7.1.0 serialize() and json_encode() use PG(serialize_precision) which set to -1 be default.
105-
* Setting -1 uses better algorithm for rounding float numbers.
106-
* But for data consistency during converting process PG(serialize_precision) is set to 17.
98+
* For data consistency during converting process PG(serialize_precision) is set to 17.
10799
*
108100
* @param string $value
109101
* @return string
110102
* @throws DataConversionException
111103
*/
112104
protected function encodeJson($value)
113105
{
114-
$storedPrecision = ini_get('precision');
115106
$storedSerializePrecision = ini_get('serialize_precision');
116107

117-
if (PHP_VERSION_ID < 70100) {
118-
// In PHP version < 7.1.0 json_encode() uses EG(precision).
119-
ini_set('precision', 17);
120-
} else {
121-
// In PHP version >= 7.1.0 json_encode() uses PG(serialize_precision).
122-
ini_set('serialize_precision', 17);
123-
}
108+
// In PHP 8.1+ json_encode() uses PG(serialize_precision)
109+
ini_set('serialize_precision', 17);
124110

125111
$value = $this->json->serialize($value);
126112

127-
ini_set('precision', $storedPrecision);
128113
ini_set('serialize_precision', $storedSerializePrecision);
129114

130115
if (json_last_error()) {

lib/internal/Magento/Framework/DB/Test/Unit/DB/Statement/MysqlTest.php

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
22
/**
3-
* Copyright © Magento, Inc. All rights reserved.
4-
* See COPYING.txt for license details.
3+
* Copyright 2019 Adobe
4+
* All rights reserved.
55
*/
66
declare(strict_types=1);
77

@@ -110,6 +110,11 @@ public function testExecuteWhenParamsAsPrimitives()
110110
(new Mysql($this->adapterMock, $query))->_execute($params);
111111
}
112112

113+
/**
114+
* Test execute method when params are passed as Parameter objects.
115+
*
116+
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
117+
*/
113118
public function testExecuteWhenParamsAsParameterObject()
114119
{
115120
$param1 = $this->createMock(Parameter::class);
@@ -189,10 +194,7 @@ private function setQueryStringForPdoStmtMock(string $query): void
189194
/*
190195
* In PHP 8.1 $queryString is a Typed property, thus it should be initialized before the 1st call.
191196
* But it's not automatically initialized in case of Mocking, so we do it here.
192-
* Note: In PHP < 8.1 such assignment prohibited.
193197
*/
194-
if (PHP_VERSION_ID >= 80100) {
195-
$this->pdoStatementMock->queryString = $query;
196-
}
198+
$this->pdoStatementMock->queryString = $query;
197199
}
198200
}

0 commit comments

Comments
 (0)