-
Notifications
You must be signed in to change notification settings - Fork 473
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
Detect enum duplicated values #2371
Merged
ondrejmirtes
merged 12 commits into
phpstan:1.10.x
from
kubk:detect-duplicate-enum-values
May 23, 2023
+153
−1
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
892a7f9
Detect enum duplicated values
kubk 5104fd6
Infer ->scalarType
kubk 72a471e
Make test pass for PHP 8.0 too
kubk a0c4c3a
Additional enum rules
kubk 1669aba
naming
kubk 853df3c
rename identifier
kubk c2555dd
Fix CS
kubk 1cfc7ac
Respect early return rule
kubk f9d0560
Fix for old PHP
kubk 7edd4dd
Cosmetics
ondrejmirtes a27b32e
handle empty expr
kubk 8dcd207
Fix bug that wasn't covered by tests
kubk File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here I had to use early return (
if (!$isStringBackedWithoutStringCase) {
) because linter forced me to do that.Early return is a great rule to reduce code complexity, but in my opinion in this situation it made the code a bit harder to follow. Because instead of this code:
we got:
I saw that this rule was even suppressed once in phpstan repository:
https://github.com/phpstan/phpstan-deprecation-rules/blob/9d366debb01a8097106174e46c9aa138d3bf1c01/src/Rules/Deprecations/FetchingDeprecatedConstRule.php#L30
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You might want to look into fine-tuning https://github.com/slevomat/coding-standard/blob/master/doc/control-structures.md#slevomatcodingstandardcontrolstructuresearlyexit-
I obviously can't speak for Ondřej, but the last time a similar thing like this was discussed it sounded like he is open to look into adapting it.