-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[PhpUnitBridge] fixed PHPUnit 8.3 compatibility: method handleError was renamed to __invoke #32933
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[PhpUnitBridge] fixed PHPUnit 8.3 compatibility: method handleError was renamed to __invoke #32933
Conversation
a505eab
to
b253eb6
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(I rebased this PR for 3.4 and made some fixes)
…as renamed to __invoke
b253eb6
to
0c9539f
Compare
I see. Anyways I'm glad I could help you with the research part and learnt some error handling stuff. Still have one question though, why do you return a |
the return value is used with |
Nope, fabbot doesn't work for the bridge. |
Thank you @karser. |
…ndleError was renamed to __invoke (karser) This PR was merged into the 3.4 branch. Discussion ---------- [PhpUnitBridge] fixed PHPUnit 8.3 compatibility: method handleError was renamed to __invoke | Q | A | ------------- | --- | Branch? | 4.3 | Bug fix? | yes | New feature? | no <!-- please update src/**/CHANGELOG.md files --> | BC breaks? | no <!-- see https://symfony.com/bc --> | Deprecations? | no <!-- please update UPGRADE-*.md and src/**/CHANGELOG.md files --> | Tests pass? | yes <!-- please add some, will be required by reviewers --> | Fixed tickets | #32879 <!-- #-prefixed issue number(s), if any --> | License | MIT The PHPUnit method [handleError](https://github.com/sebastianbergmann/phpunit/blob/8.2.5/src/Util/ErrorHandler.php#L38) was renamed to [__invoke](https://github.com/sebastianbergmann/phpunit/blob/8.3/src/Util/ErrorHandler.php#L71) in v8.3. So we should check in Symfony [DeprecationErrorHandler](https://github.com/symfony/symfony/blob/v4.3.3/src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler.php) if method `handleError` exists, otherwise call `__invoke` It works with phpunit v8.2.5 and 8.3.2. The PHPUnit handler is called when I trigger some error, e.g `iconv('fdsfs', 'fsdfds', '');` Commits ------- 0c9539f [PhpUnitBridge] fixed PHPUnit 8.3 compatibility: method handleError was renamed to __invoke
@@ -44,6 +48,7 @@ public static function register($mode = 0) | |||
} | |||
|
|||
$UtilPrefix = class_exists('PHPUnit_Util_ErrorHandler') ? 'PHPUnit_Util_' : 'PHPUnit\Util\\'; | |||
self::$isAtLeastPhpUnit83 = method_exists('PHPUnit\Util\ErrorHandler', '__invoke'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ErrorHandler::class
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nvm. Didn't notice that version were 3.4
public static function getPhpUnitErrorHandler() | ||
{ | ||
if (!self::$isAtLeastPhpUnit83) { | ||
return (class_exists('PHPUnit_Util_ErrorHandler', false) ? 'PHPUnit_Util_' : 'PHPUnit\Util\\').'ErrorHandler::handleError'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return [ErrorHandler::class, 'handleError']
since #32940
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nvm. Didn't notice that version were 3.4
The PHPUnit method handleError was renamed to __invoke in v8.3.
So we should check in Symfony DeprecationErrorHandler if method
handleError
exists, otherwise call__invoke
It works with phpunit v8.2.5 and 8.3.2.
The PHPUnit handler is called when I trigger some error, e.g
iconv('fdsfs', 'fsdfds', '');