-
Notifications
You must be signed in to change notification settings - Fork 519
Rule to check if required file exists #3294
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
Merged
ondrejmirtes
merged 49 commits into
phpstan:1.12.x
from
Bellangelo:required-file-exists-rule
Aug 29, 2024
Merged
Changes from 1 commit
Commits
Show all changes
49 commits
Select commit
Hold shift + click to select a range
c1f3c6f
Create rule for checking paths inside the require keyword
Bellangelo fb165ba
Test that it cannot read constants from the analyzing file
Bellangelo 749414a
Test that relative paths can produce problems
Bellangelo deefe60
Test that it can read class constants
Bellangelo be18ba6
Test that it can read constants
Bellangelo 24a9650
Test that it can read __DIR__
Bellangelo 7c3f635
Test that it cannot read class properties
Bellangelo 4ff25c8
Test that it cannot read variables
Bellangelo 1625225
Test that it cannot class methods
Bellangelo 496c541
Test that it cannot read functions
Bellangelo 03f15fa
Unify filenames
Bellangelo 4889f9e
Const types are not released until PHP 8.3
Bellangelo 0e581eb
Fix code style
Bellangelo 1520ea9
Classes should be abstract or final
Bellangelo 960c71a
getValue() is deprecated
Bellangelo aff4b04
Put non-important errors under the baseline
Bellangelo 2814cf8
Test files were renamed
Bellangelo 4acc555
Make condition more clear
Bellangelo 4680c6e
Make error message more descriptive
Bellangelo 67ce86b
Remove unused import
Bellangelo 31fa5e0
getConstantStrings() can handle all the manipulation of the path
Bellangelo 50dde41
Make condition more specific
Bellangelo 9f353d8
Class does not accept any arguments in constructor anymore
Bellangelo bfa3908
Fix conflicts
Bellangelo 2369559
Register class rule
Bellangelo a2f0e6e
Fix small PHPStan issues
Bellangelo f20f26f
Fix code style
Bellangelo 9896884
Convert syntax to <=PHP7.4
Bellangelo 54f7779
Handle include() and include_once()
Bellangelo b723cf2
Rules section is always registered regardless of the conditionalTags
Bellangelo 9035154
Add identifier in rule
Bellangelo 4c85ed7
Tag forces rule to be always registered
Bellangelo 2bed45a
Constants are not readable without the usePathConstantsAsConstantStri…
Bellangelo 76b6f4f
Validate all possible cases
Bellangelo 8ea25b8
remove unused import
Bellangelo f8db0ec
Handle include paths
Bellangelo 032965a
Simplify tests
Bellangelo 31a86c8
Make test file names consistent
Bellangelo 6abc7ec
Test relative paths
Bellangelo 71ee779
Small code improvements
Bellangelo 3df4d41
Remove unused files
Bellangelo 95e5888
Clean-up files
Bellangelo 4858ceb
Method that works like stream_resolve_include_path but for a specific…
Bellangelo 67ee4d8
Use the working directory that is configured in phpstan
Bellangelo 4e049ea
Allow rule to be ignored
Bellangelo 71d23e4
Use php7.4 syntax
Bellangelo 525a393
Fix return type for < PHP7.4
Bellangelo e861017
Allow PHPStan to statically infer the possible identifiers
Bellangelo 0743c06
Remove unused import
Bellangelo 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
Add identifier in rule
- Loading branch information
commit 903515443f6cbe93b5c59567c4772b055ef3ccfe
There are no files selected for viewing
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
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
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.
One last simple change: I worry the identifier cannot be statically inferred here because of
str_replace
. We need that for https://github.com/phpstan/phpstan/actions/workflows/extract-identifiers.yml which updates https://phpstan.org/error-identifiers.Please assign
$identifier = ...
in the switch in each case, and use that in RuleErrorBuilder.Then I'll merge this. Thank you for the effort!
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.
Fixed in e861017.
Shouldn't this also run as a quality check before merging a PR?
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.
Yes, feel free to contribute this rule 😊