NewHeredocInitialize: extend the NewScalarExpressions sniff to cover more cases #641
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.
NewHeredocInitialize: add unit tests for global constants, multi-declarations and function param defaults
The PHP 5.3 change regarding initializing something with a heredoc turns out to apply to more than the current sniff was sniffing for (undocumented/based on tests ran).
Add tests for:
const
keywordA bit of a mood case as the
const
keyword was only introduced in PHP 5.3. All the same, the sniff should be accurate and the unit tests should reflect this.NewHeredocInitialize: extend the NewScalarExpressions sniff
The logic within the original
NewHeredocInitialize
sniff did not allow for multi-declarations nor for examining the default values of function parameters.While not (well) documented, these features are supported and do allow initialization with heredocs since PHP 5.3.
As the logic to determine whether a token needs to be examined is the same for this sniff and for the new
NewScalarExpressions
sniff, letting the sniff extend theNewScalarExpressions
sniff prevents code duplication.