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

PHPDoc: use @return $this for fluent methods #1362

Merged
merged 1 commit into from
Mar 2, 2020
Merged

PHPDoc: use @return $this for fluent methods #1362

merged 1 commit into from
Mar 2, 2020

Conversation

caugner
Copy link
Contributor

@caugner caugner commented Feb 16, 2020

This is:

- [x] a bugfix
- [ ] a new feature

Checklist:

Why this change is needed?

  • Some @return annotations used wrong casing (e.g. @return CSV instead of @return Csv)
  • Most classes can be extended and therefore the annotation @return static would be more appropriate to avoid inadvertent type narrowing.
  • The @return $this annotation is more explicit than @return static.

@caugner
Copy link
Contributor Author

caugner commented Feb 29, 2020

@PowerKiKi Any chance to get this merged? This fixes errors reported by Psalm like this:

ERROR: InvalidClass - src/.../ExcelExport.php:135:17 - Class or interface PhpOffice\PhpSpreadsheet\Writer\CSV has wrong casing
                $writer->setDelimiter(',')

Fluent methods, especially setters, return the object on which are
called. This is documented in PHPDoc using the `$this` keyword, which
is equivalent to `static` with the additional notion of object identity.
This helps IDEs and static analysis tools provide more meaningful output.
@PowerKiKi PowerKiKi merged commit ffb0d21 into PHPOffice:master Mar 2, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants