Complete fix for #77 (timezone warning) #297
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The #77 bug involves this warning being raised when PHPMD is executed:
In v2.0.0 and earlier, the warning was caused by calling
date()
without first setting the timezone, in this line inXMLRenderer::renderReport()
:93b5835 attempted to fix the bug by adding this code to
src/bin/phpmd
:date()
call inXMLRenderer::renderReport()
, it introduced a new bug. The new call todate_default_timezone_get()
raises this warning:See @hbandura's comment on #77.
From the docs for
date_default_timezone_get()
:There's no need to call
date_default_timezone_get()
, because:date_default_timezone_set()
hasn't been called. (Look at the top ofsrc/bin/phpmd
. Only Composer'sautoload.php
is executed, anddate_default_timezone_set()
is not called there.)date.timezone
ini option by callingini_get('date.timezone')
.So the call to
date_default_timezone_get()
can safely be removed, and this will completely fix the issue of the timezone warning.