Skip to content

Commit 2b9b6d8

Browse files
karyna-tandrewbess
authored andcommitted
Added PHP 8 constants and error handler changes into tests bootstrap files
1 parent 2a40085 commit 2b9b6d8

File tree

5 files changed

+28
-4
lines changed

5 files changed

+28
-4
lines changed

dev/tests/api-functional/framework/bootstrap.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,8 @@ function setCustomErrorHandler()
123123
{
124124
set_error_handler(
125125
function ($errNo, $errStr, $errFile, $errLine) {
126-
if (error_reporting()) {
126+
$errLevel = error_reporting();
127+
if (($errLevel & $errNo) !== 0) {
127128
$errorNames = [
128129
E_ERROR => 'Error',
129130
E_WARNING => 'Warning',

dev/tests/error_handler.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ function setCustomErrorHandler()
1111
{
1212
set_error_handler(
1313
function ($errNo, $errStr, $errFile, $errLine) {
14-
if (error_reporting()) {
14+
$errLevel = error_reporting();
15+
if (($errLevel & $errNo) !== 0) {
1516
$errorNames = [
1617
E_ERROR => 'Error',
1718
E_WARNING => 'Warning',

dev/tests/integration/framework/bootstrap.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,8 @@ function setCustomErrorHandler()
131131
{
132132
set_error_handler(
133133
function ($errNo, $errStr, $errFile, $errLine) {
134-
if (error_reporting()) {
134+
$errLevel = error_reporting();
135+
if (($errLevel & $errNo) !== 0) {
135136
$errorNames = [
136137
E_ERROR => 'Error',
137138
E_WARNING => 'Warning',

dev/tests/static/framework/bootstrap.php

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,16 @@
2020
define('TESTS_TEMP_DIR', dirname(__DIR__) . '/tmp');
2121
}
2222

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

2535
$componentRegistrar = new ComponentRegistrar();
@@ -38,7 +48,8 @@ function setCustomErrorHandler()
3848
{
3949
set_error_handler(
4050
function ($errNo, $errStr, $errFile, $errLine) {
41-
if (error_reporting()) {
51+
$errLevel = error_reporting();
52+
if (($errLevel & $errNo) !== 0) {
4253
$errorNames = [
4354
E_ERROR => 'Error',
4455
E_WARNING => 'Warning',

dev/tests/unit/framework/bootstrap.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,16 @@
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+
1323
require_once __DIR__ . '/autoload.php';
1424

1525
setCustomErrorHandler();

0 commit comments

Comments
 (0)