diff --git a/app/bootstrap.php b/app/bootstrap.php index a7aea8094f816..2e99d752b06cc 100644 --- a/app/bootstrap.php +++ b/app/bootstrap.php @@ -13,9 +13,8 @@ } #ini_set('display_errors', 1); -/* PHP version validation */ -if (!defined('PHP_VERSION_ID') || PHP_VERSION_ID < 80100) { - if (PHP_SAPI == 'cli') { +if (PHP_VERSION_ID < 80100) { + if (PHP_SAPI === 'cli') { echo 'Magento supports PHP 8.1.0 or later. ' . 'Please read https://experienceleague.adobe.com/docs/commerce-operations/installation-guide/system-requirements.html'; } else { @@ -31,16 +30,6 @@ exit(1); } -// PHP 8 compatibility. Define constants that are not present in PHP < 8.0 -if (!defined('PHP_VERSION_ID') || PHP_VERSION_ID < 80000) { - if (!defined('T_NAME_QUALIFIED')) { - define('T_NAME_QUALIFIED', 24001); - } - if (!defined('T_NAME_FULLY_QUALIFIED')) { - define('T_NAME_FULLY_QUALIFIED', 24002); - } -} - require_once __DIR__ . '/autoload.php'; // Sets default autoload mappings, may be overridden in Bootstrap::create \Magento\Framework\App\Bootstrap::populateAutoloader(BP, []); diff --git a/dev/tests/static/framework/bootstrap.php b/dev/tests/static/framework/bootstrap.php index 28f8824221f5e..36a2966879a42 100644 --- a/dev/tests/static/framework/bootstrap.php +++ b/dev/tests/static/framework/bootstrap.php @@ -21,15 +21,6 @@ define('TESTS_TEMP_DIR', dirname(__DIR__) . '/tmp'); } -// PHP 8 compatibility. Define constants that are not present in PHP < 8.0 -if (!defined('PHP_VERSION_ID') || PHP_VERSION_ID < 80000) { - if (!defined('T_NAME_QUALIFIED')) { - define('T_NAME_QUALIFIED', 24001); - } - if (!defined('T_NAME_FULLY_QUALIFIED')) { - define('T_NAME_FULLY_QUALIFIED', 24002); - } -} setCustomErrorHandler(); diff --git a/dev/tests/unit/framework/bootstrap.php b/dev/tests/unit/framework/bootstrap.php index 31eab08d1221a..24902cfda984b 100644 --- a/dev/tests/unit/framework/bootstrap.php +++ b/dev/tests/unit/framework/bootstrap.php @@ -10,16 +10,6 @@ define('TESTS_TEMP_DIR', dirname(__DIR__) . '/tmp'); } -// PHP 8 compatibility. Define constants that are not present in PHP < 8.0 -if (!defined('PHP_VERSION_ID') || PHP_VERSION_ID < 80000) { - if (!defined('T_NAME_QUALIFIED')) { - define('T_NAME_QUALIFIED', 24001); - } - if (!defined('T_NAME_FULLY_QUALIFIED')) { - define('T_NAME_FULLY_QUALIFIED', 24002); - } -} - require_once __DIR__ . '/autoload.php'; setCustomErrorHandler(); @@ -59,7 +49,7 @@ function ($errNo, $errStr, $errFile, $errLine) { E_USER_DEPRECATED => 'User Deprecated', ]; - $errName = isset($errorNames[$errNo]) ? $errorNames[$errNo] : ""; + $errName = $errorNames[$errNo] ?? ""; throw new \PHPUnit\Framework\Exception( sprintf("%s: %s in %s:%s.", $errName, $errStr, $errFile, $errLine), diff --git a/lib/internal/Magento/Framework/DB/DataConverter/SerializedToJson.php b/lib/internal/Magento/Framework/DB/DataConverter/SerializedToJson.php index bc31cb91ecede..620cc1f0806e1 100644 --- a/lib/internal/Magento/Framework/DB/DataConverter/SerializedToJson.php +++ b/lib/internal/Magento/Framework/DB/DataConverter/SerializedToJson.php @@ -1,7 +1,7 @@ = 7.1.0 serialize() and json_encode() use PG(serialize_precision) which set to -1 be default. - * Setting -1 uses better algorithm for rounding float numbers. - * But for data consistency during converting process PG(serialize_precision) is set to 17. + * For data consistency during converting process PG(serialize_precision) is set to 17. * * @param string $value * @return string @@ -111,20 +103,13 @@ protected function unserializeValue($value) */ protected function encodeJson($value) { - $storedPrecision = ini_get('precision'); $storedSerializePrecision = ini_get('serialize_precision'); - if (PHP_VERSION_ID < 70100) { - // In PHP version < 7.1.0 json_encode() uses EG(precision). - ini_set('precision', 17); - } else { - // In PHP version >= 7.1.0 json_encode() uses PG(serialize_precision). - ini_set('serialize_precision', 17); - } + // In PHP 8.1+ json_encode() uses PG(serialize_precision) + ini_set('serialize_precision', 17); $value = $this->json->serialize($value); - ini_set('precision', $storedPrecision); ini_set('serialize_precision', $storedSerializePrecision); if (json_last_error()) { diff --git a/lib/internal/Magento/Framework/DB/Test/Unit/DB/Statement/MysqlTest.php b/lib/internal/Magento/Framework/DB/Test/Unit/DB/Statement/MysqlTest.php index 45efccba28ca9..ae50aade8b7a7 100644 --- a/lib/internal/Magento/Framework/DB/Test/Unit/DB/Statement/MysqlTest.php +++ b/lib/internal/Magento/Framework/DB/Test/Unit/DB/Statement/MysqlTest.php @@ -1,7 +1,7 @@ = 80100) { - $this->pdoStatementMock->queryString = $query; - } + $this->pdoStatementMock->queryString = $query; } }