Skip to content

[PHP 8.0] Add union types#2331

Merged
TomasVotruba merged 2 commits intomasterfrom
union-types
Nov 17, 2019
Merged

[PHP 8.0] Add union types#2331
TomasVotruba merged 2 commits intomasterfrom
union-types

Conversation

@TomasVotruba
Copy link
Copy Markdown
Member

@TomasVotruba TomasVotruba commented Nov 17, 2019

Closes #2290

 <?php

 class SomeClass
 {
-    /**
-     * @param array|int $number
-     * @return bool|float
-     */
-    public function go($number)
+    public function go(array|int $number): bool|float
     {
     }
 }

* @param int $b
* @param int|void $c
*/
function someFunction(float|int $a, int $b, int|void $c) {
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

@nikic Hi, is int|void legal for paramter? I didn't find it excluded in: nikic/PHP-Parser@664c101
If not, what should be used here?

@TomasVotruba TomasVotruba merged commit 47025a9 into master Nov 17, 2019
@TomasVotruba TomasVotruba deleted the union-types branch November 17, 2019 21:20
@TomasVotruba
Copy link
Copy Markdown
Member Author

Agreed. I think Rector is taking care of this.

Could you send failing test case to verify?

TomasVotruba added a commit that referenced this pull request May 19, 2022
rectorphp/rector-src@30a53bf [DowngradePhp80] Add in arrow function in return support on DowngradeMatchToSwitchRector (#2331)
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 15, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[PHP 8] Add Union type support

2 participants