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
Imrpove or remove reporting of missing default timezone #457
Comments
I agree with this and it's something that's been bothering me for a while too. It was added for PHP 5.3's requirement to set one by default. However, since that requirement has disappeared in 7.0, I think we can safely remove this entire sniff, for all of the reasons you mention and many more ;-) Unless someone knows of a good reason to keep it ? |
I don't think the PHP 7.0 change should make a difference to the decision. We still want to support earlier PHP versions and I can see the usefulness of reporting this issue if we are able to detect it meaningfully. For example, if you are building a framework or product that you anticipate running on a wide range of PHP versions, you should take this setting into account and make sure you avoid this error no matter how php.ini is configured. (Most frameworks will use a variant of However, the reason I think it should probably be removed is that I am unconvinced that we could meaningfully detect these scenarios. Or rather, I am certain that we couldn't detect all situations where this error has been avoided - what I am less sure about is whether we could lower the rate of false-positives to a sufficiently low level to make this sniff worth retaining. And in all cases, it should be based on the code, not on the test server's php.ini. |
I'll leave the issue open for a few days to see if anyone has a reason to really keep it. |
+1 from me for removal as it is neigh impossible to detect this in a meaningful way as that would require cross-file sniffing which PHPCS is not build to handle and - while it may still be possible to do so in v2.x in a very round-about way (with properties keeping track of files sniffed and code detected) - in v 3.x with multi-threaded sniffing, it would become unmanageable. |
Removed: default timezone check - fixes #457
Currently, our compatibility sniff emits an error if date.timezone is not set in the
php.ini
file of the PHP instance on which you are running the tests.To me, this seems wholly un-useful. It bears no relation to your code (which may be explicitly setting the default timezone, or perhaps doesn't use dates at all) nor to the system on which you will be running the code (unless you are running your tests on your production environment, which is unlikely and inadvisable).
As it stands, this test seems pointless, and I would argue for its removal.
If it is to be retained, then it needs to be a lot more intelligent:
I've been meaning to log this for a while, but was prompted to do so by a comment in issue #455.
The text was updated successfully, but these errors were encountered: