Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork9.7k
Fixed PHPUnit 8.3 incompatibility: method handleError was renamed to __invoke#32890
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
706ad67 to0865fc4CompareUh oh!
There was an error while loading.Please reload this page.
smoench commentedAug 2, 2019
@karser On |
karser commentedAug 2, 2019
True. Do we need this autoload juggling? Didn't we already define which ErrorHandler class to use on line 76? |
0865fc4 to4e9e3d7Comparekarser commentedAug 2, 2019
@smoench Fixed. callPhpUnitErrorHandler is now static so it can be called from set_error_handler closure. |
dominikhajduk left a comment
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.
Tested and it solves issue. Thanks!
nicolas-grekas commentedAug 3, 2019 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
this is a critical blocker :( we need to completely redesign the way we hook there to collect deprecations. now we need to do this in our listener: when TestResult calls startTest in its run method, we need to register phpunit's error handler (duplicating what it does just after the call to startTest) and then add our collector. Then disable at endTest. Willing to dive there@karser? Maybe with help from@greg0ire too? Note that we need to do this for 3.4 and for 4.3 (since our code changed so much between the two) |
| { | ||
| $ErrorHandler =self::$utilPrefix.'ErrorHandler'; | ||
| if (self::$isHandlerInvokable) { | ||
| $object =new$ErrorHandler($convertDeprecationsToExceptions =true,$convertErrorsToExceptions =true,$convertNoticesToExceptions =true,$convertWarningsToExceptions =true); |
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.
variables$convertDeprecationsToExceptions,$convertErrorsToExceptions are not used and should be omit
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.
It was done on purpose because(true, ture, true, true) is not readable. FWIW@nicolas-grekas suggests to move this code to phpunit listener.
| if ([self::$utilPrefix.'ErrorHandler','handleError'] ===$oldErrorHandler) { | ||
| $handlerMethod =self::$isHandlerInvokable ?'__invoke' :'handleError'; | ||
| if ([self::$utilPrefix.'ErrorHandler',$handlerMethod] ===$oldErrorHandler) { |
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.
if the previous handler is the PhpUnit one, then$oldErrorHandler will contains an instance ofPHPUnit\Util\ErrorHandler
karser commentedAug 3, 2019
@nicolas-grekas I'm not fully following what happens in phpunit bridge, so I'll ask some stupid questions:
|
nicolas-grekas commentedAug 3, 2019
it copes only with that responsbility yes
It looks like so. Currently, it doesn't need to be registered as a listener, but it looks like phpunit 8 changes that.
I'd say yes, one listener is easier to setup for users
yes, although it could be done in another PR if that's easier? |
karser commentedAug 3, 2019
@nicolas-grekas Ok, I'll try to do what you described, let's see how far I can get. |
nicolas-grekas commentedAug 3, 2019
Another alternative might be to check how As of now, I wouldn't recommend merging the PR, as putting all these settings at true is a bug that someone will report sooner than later. |
karser commentedAug 3, 2019
nicolas-grekas commentedAug 3, 2019
Maybe we can have a look at the stack trace and read the properties from there? It looks like we might find the |
karser commentedAug 3, 2019
TestResult is created by TestRunner which passes $arguments which contain the neccessary parameters. $arguments are created by TestRunner::handleConfiguration. Here is simpllified function which does exactly what we need: |
c32c4a4 toede0976Compareede0976 to12717c9Comparekarser commentedAug 4, 2019 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
I extracted this logic into ErrorHandlerCallerV83. It obtains the necessary variables the way PHPUnit does and instantiates ErrorHandler. I made sure that these variables are changed when I modify them in phpunit.xml. it works with both v8.2 and v8.3. |
nicolas-grekas commentedAug 4, 2019 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
Maybe in another PR to keep this one as is: could you please give a try to the stacktrace-based approach? I feel like it could be simpler and more robust. |
karser commentedAug 4, 2019 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
nicolas-grekas commentedAug 4, 2019
We should then call the previous handler if one was set, or return false |
karser commentedAug 4, 2019
Here is stacktrace-based PR#32933 |


Uh oh!
There was an error while loading.Please reload this page.
The PHPUnit methodhandleError was renamed to__invoke in v8.3.
So we should check in SymfonyDeprecationErrorHandler if method
handleErrorexists, otherwise call__invokeIt 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', '');