-
-
Notifications
You must be signed in to change notification settings - Fork 35
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
Introduce Static Analysis Checking System #90
Introduce Static Analysis Checking System #90
Conversation
It seems that I've always been reluctant to add it because I haven't found a proper way to do the I'm not so keen on leaving the resource open without closing them. |
Challenge accepted! 😄 Let me know if this looks good: e000805 |
I realised that this iterator is also used in fromResource, where the user already provides a resource. We might not want to close it in that case as it should be up to the caller, so I'm thinking to add a boolean parameter to ResourceIterator with default value |
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.
I realised that this iterator is also used in fromResource, where the user already provides a resource. We might not want to close it in that case as it should be up to the caller, so I'm thinking to add a boolean parameter to ResourceIterator with default value
false
that should be used to check if the resource should be closed. Does that sound good?
This is exactly why it is done like that, I let the user close its resource
.
In overall, I'm ok with the pull request, feel free to submit it!
Ok so we don't want Also, I'll add the static analysis check for |
Maybe a new extra parameter to ResourceIterator ? |
@@ -415,15 +415,14 @@ public static function fromIterable(iterable $iterable): self | |||
|
|||
/** | |||
* @param resource $resource | |||
* | |||
* @return self<int, string> |
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.
@drupol I see a mix of annotations in this project, but I'm not sure why that is. Should we use the psalm ones or the "normal" ones everywhere?
A. @param
, @return
, @template
B. @psalm-param
, @psalm-return
, @psalm-template
For the analysers it doesn't matter because they support both. And in an IDE like PHPStorm / IntelliJ both are properly highlighted.
I personally favour A just because of a couple small reasons:
- less characters to write. And easier to mentally parse when reading 😄
- doesn't tie the code to a specific developer tool (though, again, doesn't really matter because both are supported)
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.
This is also on my Todo list! Option A for the win :)
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.
Excellent!
This PR aims to kickstart improvements to static analysis
Follows #89.
Overall
tests/static-analysis
Checks added