-
-
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
Test version logic #142
Comments
If I recall, it was me who added this option and the related code, and therefore probably me who documented it too. I don't have much time this week, but I'll try and look at it and respond properly as soon as I can. |
... however, to answer your specific question off the top of my head, the intended behaviour was probably "don't break backwards-compatibility for existing deployments which don't specify a value". :-) |
The thing what gets me is that it is not clear at all from the
|
Sorry about the delay replying to this. I'm not sure if this reply is going to answer all your questions, but I've dug through the history and discovered this comment from my original commit of these functions, in revision 752feb0:
As you pointed out from the code, and as confirmed by the above commit message, the supportsAbove() test returns true when the testVersion is null, whilst the supportsBelow() test returns false. This was intentional, in order to ensure no change in behaviour for installations that don't specify a testVersion, and it is therefore the documentation that was incorrect when I came to document the testVersion setting in commit 5834c92. In effect, it means that if no testVersion is specified (and assuming the sniffs are implemented consistently) we report any and all deprecated/removed features (backwards-compatibility issues) but we don't report any new features (forwards-compatibility issues). This could be considered desirable behaviour, or it could not. Either way the important thing is consistency and clarity with regards this setting when it is omitted. There are probably four options:
My recommendation is option 3, as it is simplest to code and simplest to understand. I could also go for option 1 if someone put forward a compelling use-case for it (though arguably this would be better and more clearly handled by an additional 'compatibilityMode' argument with three possible values: 'forward', 'backward' or 'both', which could be used in combination with the testVersion setting). Anyway, that's all a bit of a brain-dump - sorry for waffling on! Thoughts? |
@MarkMaldaba Thanks for you extensive reply. Appreciated. I'd be all for 3, though I can now better understand the case for 1, which does make some sense too. Additionally, I would suggest the following - partially based on #197 -:
Concerning the function names:They currently make perfect sense to me, but it took me a while to get them. So for someone who's just starting to contribute to the library or who contributes infrequently, they may not be as intuitive as they may seem for people who use them on a more regular basis. The docblock documentation could help already to make things clearer, but it couldn't hurt to at least have a think about the function names. About the setting of testVersion:Another thing I'd like to put out there would be the possibility to just set a minimum testVersion and leave the maximum open to auto-adjust to the available sniffs/PHP version. A lot of people will use PHPCompatibility as part of their ruleset rather than run it separately from the command line. In that case, they could set the |
Side note: I've just been running some tests with setting the test version via the config and it's not actually working at this moment, so the instructions I added to the readme are wrong for that. Update: got it working, I was using the wrong xml key |
I was thinking about names. How about I'm all for adding the ability for unbounded ranges:
Given that final point, would it be better to make it explicit. E.g. |
This was implemented some time ago. Closing. Feel free to reopen if anthing's still missing |
I think the documentation update was implemented, but there was ongoing discussion about whether to (a) rename the functions; or (b) update the logic, to work as per option 3 in my comment, above (#142 (comment)). I don't know whether that means this ticket should be re-opened, or a new ticket (or tickets) logged - or, actually, that the current situation is fine and no further action is needed. Would be good to have @jrfnl's thoughts on this. |
While the documentation is better now, the function names are still not as intuitive as could be. |
The function names were changed in PR #1555, so that part can be considered addressed now. |
Before I start debugging/changing things around, I'd like to check what the intended behaviour is of the
testVersion
logic.It was always my understanding that if you provided a specific version or version range, you'd only get the notices which were relevant for those versions.
And if you didn't provide a
testVersion
, you'd get all the notices no matter what, i.e. this would currently translate to the range5.0-7.0
.In practice, that is not how it currently works.
The below comment is in the
PHPCompatibility_Sniff
abstract base class. The explanation in the comment is not in line with what my understanding was, but also not in line with how it currently works.This is what the functions currently return:
So my question specifically is what the intended behaviour is when no
testVersion
has been provided.The text was updated successfully, but these errors were encountered: