Skip to content
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

Static Analysis Checks: Common Operations (III) #114

Merged
merged 5 commits into from
Jun 21, 2021

Conversation

AlexandruGG
Copy link
Collaborator

This PR adds more static analysis checks for commonly-used methods, and fixes a few type hints in the process.

  • every
  • get
  • key
  • keys
  • normalize
  • squash

Follows #109.

Comment on lines +442 to 446
/**
* @param TKey $key
* @param T|null $default
*/
public function get($key, $default = null): CollectionInterface
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the @param T|null $default annotation is needed here because otherwise Psalm interprets $default as type T and T as null because of the default null value.

Because of that it thinks that Collection::fromIterable([1, 2, 3])->get(1) is always Collection<int, null> instead of Collection<int, int|null>

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fair enough, good for me.

@AlexandruGG AlexandruGG marked this pull request as ready for review June 21, 2021 18:02
@drupol drupol merged commit 9f13526 into master Jun 21, 2021
@drupol drupol deleted the feature/more-static-analysis-checks branch June 21, 2021 18:15
@drupol
Copy link
Collaborator

drupol commented Jun 21, 2021

All good :) Thanks !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants