Skip to content

Add many missing PHPdoc return types #49349

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
merged 1 commit into from
Feb 13, 2023

Conversation

wouterj
Copy link
Member

@wouterj wouterj commented Feb 12, 2023

Q A
Branch? 6.3
Bug fix? no
New feature? no
Deprecations? yes
Tickets Ref #47551, continues #49342
License MIT
Doc PR -

This PR adds lots of @return PHPdoc that we missed in the 5.4 branch. These will produce new deprecation warnings, if applications override one of these methods. It will not break backwards compatibility.
Adding these PHPdoc in 6.3 already allow the community to test all these annotations for 6 months in stable version, before committing to adding them as PHP types in 7.0. This way, I hope we patch out any wrong type.

This PR is done using a slightly modified Psalter script, based on Psalm's type inference. See #49348 for the counter PR adding real PHP types to private, final or internal methods.

@nicolas-grekas nicolas-grekas force-pushed the issue-47551/return-types-phpdoc branch 2 times, most recently from 93bc639 to b6621b6 Compare February 13, 2023 08:31
@nicolas-grekas nicolas-grekas force-pushed the issue-47551/return-types-phpdoc branch from b6621b6 to e23d8be Compare February 13, 2023 08:44
Copy link
Member

@nicolas-grekas nicolas-grekas left a comment

Choose a reason for hiding this comment

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

(I fixed my review comments + synced expected missing return types)

@nicolas-grekas
Copy link
Member

Thank you @wouterj.

@nicolas-grekas nicolas-grekas merged commit 81b08c6 into symfony:6.3 Feb 13, 2023
@wouterj wouterj deleted the issue-47551/return-types-phpdoc branch February 13, 2023 09:02
nicolas-grekas added a commit that referenced this pull request Feb 13, 2023
This PR was merged into the 6.3 branch.

Discussion
----------

Add PHP types to private methods and functions

| Q             | A
| ------------- | ---
| Branch?       | 6.3
| Bug fix?      | no
| New feature?  | no
| Deprecations? | yes
| Tickets       | Ref #47551, continues #49342
| License       | MIT
| Doc PR        | -

This PR adds real PHP types to private, internal or final (excluding ``@final``) methods based on Psalm's type inference. Many more return types are missing still, but let's do them in other contributions.

This change can result in BC breaks in multiple ways, so we should carefully review the changes:

* A method may wrongly be considered "safe" by Psalter. If the method is unsafe (e.g. ``@final``, but not yet real `final`), we should instead add a PHPdoc return type (see #49349)
* Psalm may not infer the correct set of return types. If an unexpected type is returned, this will result in a PHP error.

Commits
-------

384c9a6 Add PHP types to private methods and functions
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants