Skip to content

Commit 41307fc

Browse files
committed
Suppress E_DEPRECATED in tests on PHP8.1
1 parent e4579d2 commit 41307fc

File tree

4 files changed

+66
-53
lines changed

4 files changed

+66
-53
lines changed

.github/workflows/php.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,12 @@ jobs:
4141
dependency-versions: "${{ matrix.dependencies }}"
4242
composer-options: "${{ matrix.composer-options }}"
4343

44+
# Exclude E_DEPRECATED on PHP 8.1.
45+
# Remove once https://github.com/tomzx/php-semver-checker/pull/112 fixed
46+
- name: Sets error reporting
47+
if: contains(${{ matrix.php-version }}, '8.1')
48+
run: echo "error_reporting=24575" >> $GITHUB_ENV
49+
4450
- name: Run unit tests suite
4551
run: vendor/bin/phpunit --configuration tests/Unit/phpunit.xml.dist
4652

composer.lock

Lines changed: 55 additions & 51 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/Unit/bootstrap.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@
1212
require_once __DIR__ . '/../../vendor/autoload.php';
1313

1414
setCustomErrorHandler();
15-
error_reporting(E_ALL);
15+
$errorReportingLevel = $_ENV['error_reporting'] ?? E_ALL;
16+
error_reporting((int) $errorReportingLevel);
1617
ini_set('display_errors', 1);
1718

1819
/**
@@ -22,7 +23,8 @@ function setCustomErrorHandler()
2223
{
2324
set_error_handler(
2425
function ($errNo, $errStr, $errFile, $errLine) {
25-
if (error_reporting()) {
26+
$errLevel = error_reporting();
27+
if (($errLevel & $errNo) !== 0) {
2628
$errorNames = [
2729
E_ERROR => 'Error',
2830
E_WARNING => 'Warning',

tests/Unit/phpunit.xml.dist

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,6 @@
1717
<php>
1818
<ini name="date.timezone" value="America/Los_Angeles"/>
1919
<ini name="xdebug.max_nesting_level" value="200"/>
20+
<env name="error_reporting" value="32767"/>
2021
</php>
2122
</phpunit>

0 commit comments

Comments
 (0)