Repository navigation
Generic/RequireStrictTypes: various bugfixes - #51
Merged
jrfnl merged 4 commits intoDec 5, 2023
Merged
Conversation
jrfnl
force-pushed
the
feature/generic-requirestricttypes-various-bugfixes
branch
from
November 11, 2023 03:34
4352bfb to
54a0dfe
Compare
These tests safeguard the following, which is already handled correctly by the sniff: * Execution directives are case-insensitive in PHP. * The sniff should ignore docblocks at the top of the file.
…ment While hopefully unlikely in real life, the sniff should handle parse errors correctly. Along the same lines, live coding should be handled correctly and a `declare()` statement should only be examined once the statement has been completed. This updates the sniff to handle both situations correctly. Without these fixes, no error would be thrown in test case file 5 or 6 (false negative), while an error would be thrown in test case file 7 (false positive). Includes unit tests. Includes minor efficiency tweak to only start looking for a "next" token _after_ the current token.
…ments PHP allows for multiple directives to be passed in one `declare()` statement. The sniff, however, did not allow for this, which could lead to false positives. Fixed now. Includes unit tests.
Strict types is disabled when the value for the `strict_types` directive is `0`. As this sniff is supposed to be about enforcing the use of `strict_types`, `strict_types` declarations which turn the feature off should be flagged as well. Implemented with a separate error code to allow for selectively turning this warning off. Includes dedicated tests.
jrfnl
force-pushed
the
feature/generic-requirestricttypes-various-bugfixes
branch
from
December 5, 2023 15:11
54a0dfe to
3ff23a3
Compare
5 of 11 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Description
Recreation of upstream PR squizlabs/PHP_CodeSniffer#3720:
Suggested changelog entry
Generic.PHP.RequireStrictTypes.Disablederror code