Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit0865fc4

Browse files
committed
Fixed PHPUnit 8.3 incompatibility: method handleError was renamed to __invoke
1 parent8f1d9d2 commit0865fc4

File tree

1 file changed

+17
-4
lines changed

1 file changed

+17
-4
lines changed

‎src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler.php‎

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ class DeprecationErrorHandler
4949

5050
privatestatic$isRegistered =false;
5151
privatestatic$utilPrefix;
52+
privatestatic$isHandlerInvokable;
5253

5354
/**
5455
* Registers and configures the deprecation handler.
@@ -73,14 +74,16 @@ public static function register($mode = 0)
7374
}
7475

7576
self::$utilPrefix =class_exists('PHPUnit_Util_ErrorHandler') ?'PHPUnit_Util_' :'PHPUnit\Util\\';
77+
self::$isHandlerInvokable =method_exists(self::$utilPrefix.'ErrorHandler','__invoke');
7678

7779
$handler =newself();
7880
$oldErrorHandler =set_error_handler([$handler,'handleError']);
7981

8082
if (null !==$oldErrorHandler) {
8183
restore_error_handler();
8284

83-
if ([self::$utilPrefix.'ErrorHandler','handleError'] ===$oldErrorHandler) {
85+
$handlerMethod =self::$isHandlerInvokable ?'__invoke' :'handleError';
86+
if ([self::$utilPrefix.'ErrorHandler',$handlerMethod] ===$oldErrorHandler) {
8487
restore_error_handler();
8588
self::register($mode);
8689
}
@@ -116,15 +119,25 @@ public static function collectDeprecations($outputFile)
116119
});
117120
}
118121

122+
privatefunctioncallPhpUnitErrorHandler($type,$msg,$file,$line,$context)
123+
{
124+
$ErrorHandler =self::$utilPrefix.'ErrorHandler';
125+
if (self::$isHandlerInvokable) {
126+
$object =new$ErrorHandler($convertDeprecationsToExceptions =true,$convertErrorsToExceptions =true,$convertNoticesToExceptions =true,$convertWarningsToExceptions =true);
127+
128+
return$object($type,$msg,$file,$line,$context);
129+
}
130+
131+
return$ErrorHandler::handleError($type,$msg,$file,$line,$context);
132+
}
133+
119134
/**
120135
* @internal
121136
*/
122137
publicfunctionhandleError($type,$msg,$file,$line,$context = [])
123138
{
124139
if ((E_USER_DEPRECATED !==$type &&E_DEPRECATED !==$type) || !$this->getConfiguration()->isEnabled()) {
125-
$ErrorHandler =self::$utilPrefix.'ErrorHandler';
126-
127-
return$ErrorHandler::handleError($type,$msg,$file,$line,$context);
140+
return$this->callPhpUnitErrorHandler($type,$msg,$file,$line,$context);
128141
}
129142

130143
$deprecation =newDeprecation($msg,debug_backtrace(),$file);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp