-
-
Notifications
You must be signed in to change notification settings - Fork 192
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
Create special case for T_BAD_CHARACTER constant #1586
Conversation
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.
Hiya @fredden Thanks for looking into this!
I need to think this solution over a little as it is quite different from what I had in mind.
Would you mind explaining why you choose to create a separate array based sniff, instead of special casing the constant in the RemovedConstants
and NewConstants
sniffs ?
Do you expect this kind of thing to happen more regularly in PHP in the future ?
Initially I added more code to If you'd prefer, I can look at re-doing this without adding a new sniff and instead only modifying
I have no idea. :) I suspect it won't re-occur, but I don't know. |
Just guessing - were you trying to make the special casing dynamic ? As in: allow for an array based list of special cases ? In that case, I can imagine there would be redundancy and code duplication, but as things are, we only need to account for one special case....
Well, as neither of us can look into the future... what about writing the sniff based on the now ? What I mean by that, is that the sniff as-is doesn't need to be array based. This would also allow for greatly simplifying the tests.
Let me think it over a little more ;-) In the mean time - would you like some general feedback on the code as-is ? (without an opinion on the direction of the PR yet) |
Yes, I had avoided hard-coding the T_BAD_CHARACTER name and listed this in a (array) class constant/property.
Looking at the code, there's not a whole lot in there that would be simpler if we hard-coded everything rather than looking up values from the array property. Perhaps I've misunderstood what you mean.
I can see that this would allow removing a few arguments in the data provider. I wanted to use It's possible to reduce the number of tests without impacting coverage - for example, we don't strictly need to test with all of
Yes, that sounds useful for progressing this work. |
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.
As noted in my previous comment - these are mostly just general feedback/guidelines for how we work in this repo without an opinion on the direction this PR should take.
If we'd go with the new sniff, I would like to have a good think about the sniff name as well.
While it is a single-constant sniff it could just be named after the constant.
And maybe use Reintroduced
instead of TemporarilyRemoved
?
PHPCompatibility/Sniffs/Constants/TemporarilyRemovedConstantsSniff.php
Outdated
Show resolved
Hide resolved
PHPCompatibility/Sniffs/Constants/TemporarilyRemovedConstantsSniff.php
Outdated
Show resolved
Hide resolved
PHPCompatibility/Sniffs/Constants/TemporarilyRemovedConstantsSniff.php
Outdated
Show resolved
Hide resolved
PHPCompatibility/Sniffs/Constants/TemporarilyRemovedConstantsSniff.php
Outdated
Show resolved
Hide resolved
PHPCompatibility/Tests/Constants/TemporarilyRemovedConstantsUnitTest.php
Outdated
Show resolved
Hide resolved
PHPCompatibility/Tests/Constants/TemporarilyRemovedConstantsUnitTest.php
Outdated
Show resolved
Hide resolved
PHPCompatibility/Tests/Constants/TemporarilyRemovedConstantsUnitTest.php
Outdated
Show resolved
Hide resolved
PHPCompatibility/Tests/Constants/TemporarilyRemovedConstantsUnitTest.php
Outdated
Show resolved
Hide resolved
PHPCompatibility/Tests/Constants/TemporarilyRemovedConstantsUnitTest.inc
Outdated
Show resolved
Hide resolved
c889095
to
4eace06
Compare
4eace06
to
fa14bc3
Compare
@fredden and me discussed this off-GitHub and what with this being a breaking change as it currently is (new sniffname/error codes), while it could also be special cased in the |
1f0b5f8
to
698e9a9
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.
@fredden Thanks for updating the PR. Looks like this could still be simplified further.
Would you like me to push an update to the PR ?
@jrfnl thanks for the feedback. I've applied the suggested changes and confirmed that the test suite still runs without error. Would you like to squash-merge this, or shall I rewrite the history to have only one commit here (after you've reviewed again)? |
@fredden Thanks for making that update and for your work on this PR! I'll squash-merge it once the build passes. Feedback-wise, the only thing which I'd still say about this PR (but which is definitely not a blocker) is that splitting the tests and removing some redundancy would still be nice (see #1586 (comment) ), but I'm fine with leaving that. |
Fixes #1351