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

Support native union return typing #467

Merged
merged 2 commits into from
May 22, 2022
Merged

Conversation

aszenz
Copy link
Contributor

@aszenz aszenz commented Apr 24, 2022

Fixes #462

@@ -77,6 +101,10 @@ private function dummy() {

}

private function objectUnion(): TestObject|TestObject2 {
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 also tried null|TestObject|TestObject2 but that failed, not sure if the library needs to support that

@codecov-commenter
Copy link

codecov-commenter commented Apr 24, 2022

Codecov Report

Merging #467 (65cbf11) into master (da8a377) will decrease coverage by 0.03%.
The diff coverage is 100.00%.

@@             Coverage Diff              @@
##             master     #467      +/-   ##
============================================
- Coverage     96.36%   96.33%   -0.04%     
- Complexity     1631     1638       +7     
============================================
  Files           146      146              
  Lines          4100     4115      +15     
============================================
+ Hits           3951     3964      +13     
- Misses          149      151       +2     
Impacted Files Coverage Δ
src/Mappers/Parameters/TypeHandler.php 97.61% <100.00%> (-0.45%) ⬇️
src/Mappers/CannotMapTypeException.php 98.21% <0.00%> (-1.79%) ⬇️
src/Mappers/Root/BaseTypeMapper.php 100.00% <0.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update da8a377...65cbf11. Read the comment docs.

@aszenz
Copy link
Contributor Author

aszenz commented Apr 29, 2022

@oojacoboo Any idea how to fix the test for php 7.4

@oojacoboo oojacoboo changed the title fix: Allows union types in native returns Support native union return typing Apr 29, 2022
@oojacoboo
Copy link
Collaborator

oojacoboo commented Apr 29, 2022

@aszenz PHP didn't support union types until 8.0. The parser for 7.4 doesn't understand the syntax. Make sure the tests are only running for 8.0. You can look at how tests/Fixtures81 is implemented. If necessary, create a new Fixtures80 directory.

Tests are run through .github/workflows/continuous_integration.yml

@aszenz
Copy link
Contributor Author

aszenz commented May 21, 2022

@aszenz PHP didn't support union types until 8.0. The parser for 7.4 doesn't understand the syntax. Make sure the tests are only running for 8.0. You can look at how tests/Fixtures81 is implemented. If necessary, create a new Fixtures80 directory.

Tests are run through .github/workflows/continuous_integration.yml

Done 👍

@oojacoboo
Copy link
Collaborator

@aszenz awesome thanks and for the PR!

@oojacoboo oojacoboo merged commit dc6e07d into thecodingmachine:master May 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

PHP 8 Union type fails while union type in doc block works
3 participants