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
Output warnings for deprecated rules and options #3699
Output warnings for deprecated rules and options #3699
Conversation
what's wrong with using I'm not feeling comfortable with adding event dispatcher to every single class we have :( |
Using I don't like to have the event dispatcher everywhere too but I couldn't find a better solution. I think we should introduce a dependency injection container but I'm not sure we can do that in a BC way easily. |
Agree about DIC, and agree more that totally out of scope here. So, we do already trigger errors for all deprecations? What I don't like is mostly the fact that we change all classes just to handle deprecations, which are not the base flow. What I was always following here was making the code nice for best case scenario, and uglier for edge cases. And deprecations are edge cases, as they gonna be removed (or actually, already are, on 3.x line) |
As said, I'm not willing to inject EventDispatcher to every single fixer. |
Agreed injecting the event dispatcher everywhere for an edge case is definitely far from optimal solution. But I would like to avoid using a custom error handler as using they is sometimes tricky and can bring more problems than it actually solves. We know we would like to have a dependency injection container in the future. Maybe we can introduce it here and use it only for the event dispatcher for now. We could then refactor gradually other parts of the code to use it as well later, rather than creating a dedicated PR that would probably be huge and hard to review. WDYT? If you don't like the idea, I'll go with the custom error handler, I don't want to drop the proposal :) |
that's the thing. I believe that deprecations shall be handled by E_USER_DEPRECATE, not random event dispatcher :( |
Thanks for picking this up 👍 |
630394d
to
758e1ea
Compare
PR reworked. Still WIP as there is a few things left to do (mostly checking which deprecation notice is relevant for console output before printing it). Please let me know what you think about the general direction the PR is taking now :) |
I like the direction @julienfalque ! 👍 |
758e1ea
to
11cd72a
Compare
Ready for review I think. |
a462bdf
to
a9d2495
Compare
shouldn't |
That would require to expose |
like |
meh :/ |
self::$printCurrentDeprecationNotice = true; | ||
@trigger_error($message, E_USER_DEPRECATED); | ||
self::$printCurrentDeprecationNotice = false; | ||
} |
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 we woud replace this method with
$stdErr->writeln("<bg=yellow;fg=black;>{$message}</>");
@trigger_error($message, E_USER_DEPRECATED);
we would need no custom error handles any more, don't we ?
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.
This is not possible where $strErr
is not available.
a9d2495
to
4574829
Compare
4574829
to
d3ed10a
Compare
d3ed10a
to
99986ed
Compare
99986ed
to
3f119ee
Compare
3f119ee
to
104f0b3
Compare
104f0b3
to
1a9e0c7
Compare
@fabpot It looks like fabbot reports a false positive regarding exception message formatting: https://fabbot.io/report/FriendsOfPHP/PHP-CS-Fixer/3699/1a9e0c7e80b5db6a4d1cfb773aa495daba188c5c. The first change is within a string. |
What is the status of this PR? Can we add some auto review tests to ensure no one will call |
This would fail because
I think all review feedback has been addressed except @keradus' concern maybe? |
@keradus @kubawerlos @SpacePossum @localheinz Shall we finish this PR prio to releasing |
I would suggest to go this way, @julienfalque |
This PR adds warnings in the
fix
command output when using deprecated rules or deprecated options.