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

Provide Psalm integration #29

Merged

Conversation

weierophinney
Copy link
Contributor

  • Adds Psalm and psalm PHPUnit plugin as dev requirements.
  • Adds Psalm configuration.
  • Fixes low-hanging fruit reported by Psalm.
  • Adds Psalm baseline file.

Among the low-hanging fruit were the following LinkCollection signature changes:

  • getLinks() gets an array return typehint
  • getLinksByRel() gets an array return typehint
  • withLink() gets a self return typehint
  • withoutLink() gets a self return typehint

These are all backwards compatible, but extensions will need to provide them.

Fixes #17

- Adds Psalm and psalm PHPUnit plugin as dev requirements.
- Adds Psalm configuration.
- Fixes low-hanging fruit reported by Psalm.
- Adds Psalm baseline file.

Among the low-hanging fruit were the following `LinkCollection` signature changes:
- `getLinks()` gets an `array` return typehint
- `getLinksByRel()` gets an `array` return typehint
- `withLink()` gets a `self` return typehint
- `withoutLink()` gets a `self` return typehint

These are all backwards compatible, but extensions will need to provide them.

Signed-off-by: Matthew Weier O'Phinney <matthew@weierophinney.net>
@weierophinney weierophinney added this to the 2.0.0 milestone Dec 22, 2020
@weierophinney weierophinney added BC Break Enhancement New feature or request labels Dec 22, 2020
@weierophinney weierophinney added this to To do in Psalm via automation Dec 22, 2020
@weierophinney weierophinney moved this from To do to In progress in Psalm Dec 22, 2020
Signed-off-by: Matthew Weier O'Phinney <matthew@weierophinney.net>
@@ -360,7 +360,7 @@ private function aggregateEmbeddedCollection(string $name, array $collection, st
* Exists as array_shift is destructive, and we cannot necessarily know the
* index of the first element.
*
* @param null|HalResource[] $resources
* @param array $resources
Copy link
Member

Choose a reason for hiding this comment

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

This is the same information like in the method signature therefore it can be omitted.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm a bit surprised that Psalm did that...

@@ -43,8 +49,10 @@ public function getLinksByRel($rel)

/**
* {@inheritDoc}
*
* @return HalResource
Copy link
Member

Choose a reason for hiding this comment

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

The same here. self as return type should be enough.

Signed-off-by: Matthew Weier O'Phinney <matthew@weierophinney.net>
@weierophinney weierophinney merged commit bf947cf into mezzio:2.0.x Dec 22, 2020
Psalm automation moved this from In progress to Done Dec 22, 2020
@weierophinney weierophinney deleted the feature/17-psalm-integration branch December 22, 2020 19:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
BC Break Enhancement New feature or request
Projects
Psalm
  
Done
Development

Successfully merging this pull request may close these issues.

Psalm integration
2 participants