Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions PHPUnit/Framework/TestResult.php
Original file line number Diff line number Diff line change
Expand Up @@ -580,9 +580,13 @@ public function run(PHPUnit_Framework_Test $test)
$errorHandlerSet = FALSE;

if ($this->convertErrorsToExceptions) {
$errorLevels = E_ALL;
if (PHP_VERSION_ID < 70400) {
$errorLevels = E_ALL | E_STRICT;
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

alternatives:

single line:

$errorLevels = PHP_VERSION_ID < 70400 ? E_ALL | E_STRICT : E_ALL;`

multiline:

$errorLevels = E_ALL;

if (PHP_VERSION_ID < 70400) {
    $errorLevels |= E_STRICT;
}

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe the current one is clear enough and easy to understand.

$oldErrorHandler = set_error_handler(
array('PHPUnit_Util_ErrorHandler', 'handleError'),
E_ALL | E_STRICT
array('PHPUnit_Util_ErrorHandler', 'handleError'),
$errorLevels
);

if ($oldErrorHandler === NULL) {
Expand Down
3 changes: 2 additions & 1 deletion PHPUnit/Util/ErrorHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,8 @@ public static function handleError($errno, $errstr, $errfile, $errline)
}
}

if ($errno == E_NOTICE || $errno == E_USER_NOTICE || $errno == E_STRICT) {
if ($errno == E_NOTICE || $errno == E_USER_NOTICE
|| (PHP_VERSION_ID < 70400 && $errno == E_STRICT)) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
|| (PHP_VERSION_ID < 70400 && $errno == E_STRICT)) {
|| (PHP_VERSION_ID < 80400 && $errno == E_STRICT)) {

Shouldn't the deprecation start with 8.4? not 7.4?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@glensc According to this, some functions already emit deprecation notice starting 7.4:
https://php.watch/versions/8.4/E_STRICT-deprecated

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

from the linked article:

It is safe to assume that any PHP applications that run on PHP 8.0 and later will never encounter E_STRICT notices

but still the correct check would be <= 70400 or < 80000 instead of < 70400 @marcing

if (PHPUnit_Framework_Error_Notice::$enabled !== TRUE) {
return FALSE;
}
Expand Down