-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
Turn @return
into real types on PHP 8
#40154
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
Comments
ideally, we would need to be able to turn that on based on a target PHP version which is not the current runtime. Otherwise, if your CI runs tests on both 7.4 and 8.0, a run on 8.0 would complain that you don't declare an actual return type somewhere, while declaring it would break support for PHP 7.4. We need to account for the min target version here. |
Actually, DebugClassLoader doesn't trigger a deprecation anymore as soon as the annotation is explicitly added to the method. We designed it this way to allow silencing the deprecation. So: adjusting the behavior based on the current runtime would be OK. Each line in the CI matrix would apply the return types it can understand. |
This PR was merged into the 4.4 branch. Discussion ---------- [PHPDoc] Fix some union type cases | Q | A | ------------- | --- | Branch? | 4.4 | Bug fix? | no | New feature? | no | Deprecations? | no | Tickets | - | License | MIT | Doc PR | - While working on #40154, I discovered some PHPDoc issues, I'm going to comment in the review. Upper branches will need some fixes too. Commits ------- dd14816 [PHPDoc] Fix some union type cases
This PR was merged into the 4.4 branch. Discussion ---------- [PHPDoc] Fix some union type cases | Q | A | ------------- | --- | Branch? | 4.4 | Bug fix? | no | New feature? | no | Deprecations? | no | Tickets | - | License | MIT | Doc PR | - While working on symfony/symfony#40154, I discovered some PHPDoc issues, I'm going to comment in the review. Upper branches will need some fixes too. Commits ------- dd1481642b [PHPDoc] Fix some union type cases
This PR was merged into the 4.4 branch. Discussion ---------- [PHPDoc] Fix some union type cases | Q | A | ------------- | --- | Branch? | 4.4 | Bug fix? | no | New feature? | no | Deprecations? | no | Tickets | - | License | MIT | Doc PR | - While working on symfony/symfony#40154, I discovered some PHPDoc issues, I'm going to comment in the review. Upper branches will need some fixes too. Commits ------- dd1481642b [PHPDoc] Fix some union type cases
This PR was merged into the 4.4 branch. Discussion ---------- [PHPDoc] Fix some union type cases | Q | A | ------------- | --- | Branch? | 4.4 | Bug fix? | no | New feature? | no | Deprecations? | no | Tickets | - | License | MIT | Doc PR | - While working on symfony/symfony#40154, I discovered some PHPDoc issues, I'm going to comment in the review. Upper branches will need some fixes too. Commits ------- dd1481642b [PHPDoc] Fix some union type cases
This PR was merged into the 4.4 branch. Discussion ---------- [PHPDoc] Fix some union type cases | Q | A | ------------- | --- | Branch? | 4.4 | Bug fix? | no | New feature? | no | Deprecations? | no | Tickets | - | License | MIT | Doc PR | - While working on symfony/symfony#40154, I discovered some PHPDoc issues, I'm going to comment in the review. Upper branches will need some fixes too. Commits ------- dd1481642b [PHPDoc] Fix some union type cases
This PR was merged into the 4.4 branch. Discussion ---------- [PHPDoc] Fix some union type cases | Q | A | ------------- | --- | Branch? | 4.4 | Bug fix? | no | New feature? | no | Deprecations? | no | Tickets | - | License | MIT | Doc PR | - While working on symfony/symfony#40154, I discovered some PHPDoc issues, I'm going to comment in the review. Upper branches will need some fixes too. Commits ------- dd1481642b [PHPDoc] Fix some union type cases
This PR was merged into the 4.4 branch. Discussion ---------- [PHPDoc] Fix some union type cases | Q | A | ------------- | --- | Branch? | 4.4 | Bug fix? | no | New feature? | no | Deprecations? | no | Tickets | - | License | MIT | Doc PR | - While working on symfony/symfony#40154, I discovered some PHPDoc issues, I'm going to comment in the review. Upper branches will need some fixes too. Commits ------- dd1481642b [PHPDoc] Fix some union type cases
This PR was merged into the 4.4 branch. Discussion ---------- [PHPDoc] Fix some union type cases | Q | A | ------------- | --- | Branch? | 4.4 | Bug fix? | no | New feature? | no | Deprecations? | no | Tickets | - | License | MIT | Doc PR | - While working on symfony/symfony#40154, I discovered some PHPDoc issues, I'm going to comment in the review. Upper branches will need some fixes too. Commits ------- dd1481642b [PHPDoc] Fix some union type cases
This PR was merged into the 4.4 branch. Discussion ---------- [PHPDoc] Fix some union type cases | Q | A | ------------- | --- | Branch? | 4.4 | Bug fix? | no | New feature? | no | Deprecations? | no | Tickets | - | License | MIT | Doc PR | - While working on symfony/symfony#40154, I discovered some PHPDoc issues, I'm going to comment in the review. Upper branches will need some fixes too. Commits ------- dd1481642b [PHPDoc] Fix some union type cases
This PR was merged into the 4.4 branch. Discussion ---------- [PHPDoc] Fix some union type cases | Q | A | ------------- | --- | Branch? | 4.4 | Bug fix? | no | New feature? | no | Deprecations? | no | Tickets | - | License | MIT | Doc PR | - While working on symfony/symfony#40154, I discovered some PHPDoc issues, I'm going to comment in the review. Upper branches will need some fixes too. Commits ------- dd1481642b [PHPDoc] Fix some union type cases
This PR was merged into the 4.4 branch. Discussion ---------- [PHPDoc] Fix some union type cases | Q | A | ------------- | --- | Branch? | 4.4 | Bug fix? | no | New feature? | no | Deprecations? | no | Tickets | - | License | MIT | Doc PR | - While working on symfony/symfony#40154, I discovered some PHPDoc issues, I'm going to comment in the review. Upper branches will need some fixes too. Commits ------- dd1481642b [PHPDoc] Fix some union type cases
This PR was merged into the 4.4 branch. Discussion ---------- [PHPDoc] Fix some union type cases | Q | A | ------------- | --- | Branch? | 4.4 | Bug fix? | no | New feature? | no | Deprecations? | no | Tickets | - | License | MIT | Doc PR | - While working on symfony/symfony#40154, I discovered some PHPDoc issues, I'm going to comment in the review. Upper branches will need some fixes too. Commits ------- dd1481642b [PHPDoc] Fix some union type cases
Thank you for this issue. |
We're still working on that, @carsonbot! |
This PR was merged into the 6.0 branch. Discussion ---------- Add return types to bundles | Q | A | ------------- | --- | Branch? | 6.0 | Bug fix? | no | New feature? | yes | Deprecations? | no | Tickets | #40154 | License | MIT | Doc PR | - Extracted from #42496 Bundles should be the safest to patch since their classes should be more rarely extended. Commits ------- 89e3927 Add return types to bundles
This PR was merged into the 6.0 branch. Discussion ---------- Add return types to bridges | Q | A | ------------- | --- | Branch? | 6.0 | Bug fix? | no | New feature? | yes | Deprecations? | no | Tickets | #40154 | License | MIT | Doc PR | - Extracted from #42496 Commits ------- 1ea501d Add return types to bridges
This PR was merged into the 6.0 branch. Discussion ---------- Add return types - batch 1/n | Q | A | ------------- | --- | Branch? | 6.0 | Bug fix? | no | New feature? | yes | Deprecations? | no | Tickets | #40154 | License | MIT | Doc PR | - Extracted from #42496 for components that shouldn't be extended very often. Commits ------- 1564887 Add return types - batch 1/n
This PR was merged into the 6.0 branch. Discussion ---------- Add return types - batch 2/n | Q | A | ------------- | --- | Branch? | 6.0 | Bug fix? | no | New feature? | yes | Deprecations? | no | Tickets | #40154 | License | MIT | Doc PR | - Extracted from #42496 for components that shouldn't be extended very often. Commits ------- 606775c Add return types - batch 2/n
This PR was merged into the 6.0 branch. Discussion ---------- Add return types - batch 3/n | Q | A | ------------- | --- | Branch? | 6.0 | Bug fix? | no | New feature? | yes | Deprecations? | no | Tickets | #40154 | License | MIT | Doc PR | - Extracted from #42496 for components that shouldn't be extended very often. Commits ------- aef9069 Add return types - batch 3/n
This PR was merged into the 6.0 branch. Discussion ---------- Add return types - batch 4/n | Q | A | ------------- | --- | Branch? | 6.0 | Bug fix? | no | New feature? | yes | Deprecations? | no | Tickets | #40154 | License | MIT | Doc PR | - Extracted from #42496 Not all possible return types are patched for the attached components, to save breaking BC cross-components, for now at least. Commits ------- bad9b7d Add return types - batch 4/n
This PR was merged into the 6.0 branch. Discussion ---------- Add return types - batch 5/n | Q | A | ------------- | --- | Branch? | 6.0 | Bug fix? | no | New feature? | yes | Deprecations? | no | Tickets | #40154 | License | MIT | Doc PR | - Extracted from #42496 Not all possible return types are patched for the attached components, to save breaking BC cross-components, for now at least. Commits ------- 00f08e4 Add return types - batch 5/n
This PR was merged into the 6.0 branch. Discussion ---------- Add return types - batch 6/n | Q | A | ------------- | --- | Branch? | 6.0 | Bug fix? | no | New feature? | yes | Deprecations? | no | Tickets | #40154 | License | MIT | Doc PR | - Extracted from #42496 Not all possible return types are patched for the attached components, to save breaking BC cross-components, for now at least. Commits ------- df6b42e Add return types - batch 6/n
This PR was merged into the 6.0 branch. Discussion ---------- [Serializer] add return types | Q | A | ------------- | --- | Branch? | 6.0 | Bug fix? | no | New feature? | yes | Deprecations? | no | Tickets | #40154 | License | MIT | Doc PR | - Extracted from #42496 Not all possible return types are patched for the attached components, to save breaking BC cross-components, for now at least. Serializer's test fails. Help wanted 🙏 Commits ------- b2090d0 [Serializer] add return types
This PR was merged into the 6.0 branch. Discussion ---------- [Security] add return types | Q | A | ------------- | --- | Branch? | 6.0 | Bug fix? | no | New feature? | yes | Deprecations? | no | Tickets | #40154 | License | MIT | Doc PR | - Extracted from #42496 Not all possible return types are patched for the attached components, to save breaking BC cross-components, for now at least. Commits ------- 8871327 [Security] add return types
…o native types (nicolas-grekas) This PR was merged into the 6.0 branch. Discussion ---------- [CI] Ensure that all possible ``@return`` are turned into native types | Q | A | ------------- | --- | Branch? | 6.0 | Bug fix? | no | New feature? | yes | Deprecations? | no | Tickets | #40154 | License | MIT | Doc PR | - This PR is the final step to close the topic of return types for Symfony 6. It replaces #42496 by *not* adding return types to the classes/interfaces that break cross-component deps. It enforces that all ``@return`` from 5.4 are turned into native types in 6.0, with the known list of exceptions from #42496. Commits ------- 2b5cd7a [CI] Ensure that all possible ``@return`` are turned into native types
Task completed! We skipped adding return types were this would break BC too badly. |
This PR was merged into the 4.4 branch. Discussion ---------- [PHPDoc] Fix some union type cases | Q | A | ------------- | --- | Branch? | 4.4 | Bug fix? | no | New feature? | no | Deprecations? | no | Tickets | - | License | MIT | Doc PR | - While working on symfony/symfony#40154, I discovered some PHPDoc issues, I'm going to comment in the review. Upper branches will need some fixes too. Commits ------- dd1481642b [PHPDoc] Fix some union type cases
This PR was merged into the 4.4 branch. Discussion ---------- [PHPDoc] Fix some union type cases | Q | A | ------------- | --- | Branch? | 4.4 | Bug fix? | no | New feature? | no | Deprecations? | no | Tickets | - | License | MIT | Doc PR | - While working on symfony/symfony#40154, I discovered some PHPDoc issues, I'm going to comment in the review. Upper branches will need some fixes too. Commits ------- dd1481642b [PHPDoc] Fix some union type cases
DebugClassCloader is already able to turn
@return
annotations into real return types.We run it in the CI to ensure that type-declarations are in sync with the behavior of the code.
This can be reproduced locally by running:
But this doesn't work on union types:
symfony/src/Symfony/Component/ErrorHandler/DebugClassLoader.php
Line 861 in 37e1823
CodeExtension::getFileLink
is one example of a method that should be patched, but isn't right now.I'm opening this PR to ask for help: this limitation should be removed when PHP 8 is used.
PR welcome :)
The text was updated successfully, but these errors were encountered: