Skip to content

[TypeDeclaration] Handle nullable intersection on TypedPropertyFromAssignsRector#3372

Merged
TomasVotruba merged 9 commits intomainfrom
fix/7692-types-property-from-assigns-rector
Feb 12, 2023
Merged

[TypeDeclaration] Handle nullable intersection on TypedPropertyFromAssignsRector#3372
TomasVotruba merged 9 commits intomainfrom
fix/7692-types-property-from-assigns-rector

Conversation

@samsonasik
Copy link
Copy Markdown
Member

@samsonasik samsonasik commented Feb 12, 2023

Closes #3244
Fixes rectorphp/rector#7692

  • Use nullable MockObject on php 7.4 Skip Intersection MockObject even nullable on php 7.4
  • Use Union nullable with MockObject&TargetType => (MockObject&TargetType)|null on php 8.1
  • Use Exact Intersection type MockObject&TargetType on property assigned in setUp() method on php 8.1

@samsonasik
Copy link
Copy Markdown
Member Author

All checks have passed 🎉 @TomasVotruba it is ready for review.

@samsonasik samsonasik force-pushed the fix/7692-types-property-from-assigns-rector branch from e68d991 to 5368ae5 Compare February 12, 2023 15:41
@samsonasik
Copy link
Copy Markdown
Member Author

@VincentLanglet @puniserv after some thinking, I think it is indeed correct, that on php 7.4, the Mock object intersection can just be skipped, even nullable, then in php 8.1, real intersection type can be applied with include nullable if applicable 👍

I applied the change so it skipped on php 7.4, and applied intersection on php 8.1, so the type will be applied when the language is actually ready.

@samsonasik
Copy link
Copy Markdown
Member Author

All checks have passed 🎉 @TomasVotruba I think it is ready.

@TomasVotruba TomasVotruba merged commit db4ec02 into main Feb 12, 2023
@TomasVotruba TomasVotruba deleted the fix/7692-types-property-from-assigns-rector branch February 12, 2023 17:30
@TomasVotruba
Copy link
Copy Markdown
Member

Thanks 👏

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.

TypedPropertyFromAssignsRector - intersection types PHP 7.4.30

3 participants