Skip to content

[TypeDeclaration] Add return static object support on ReturnTypeFromStrictFluentReturnRector#4916

Merged
samsonasik merged 5 commits intomainfrom
return-statuc
Sep 5, 2023
Merged

[TypeDeclaration] Add return static object support on ReturnTypeFromStrictFluentReturnRector#4916
samsonasik merged 5 commits intomainfrom
return-statuc

Conversation

@samsonasik
Copy link
Copy Markdown
Member

@samsonasik samsonasik commented Sep 5, 2023

@staabm continue of :

This will return static on php 8.x, and return self on php 7.x when it returns new static.

The self return is happen on:

  • anonymous class
  • final class
  • not yet supported (php 7.x)

otherwise, it will return static.

@samsonasik
Copy link
Copy Markdown
Member Author

Github actions seems has issue showing latest commit, I just committed latest clean up commit but not shown, the change is Ready actually 👍

@samsonasik samsonasik enabled auto-merge (squash) September 5, 2023 16:57
@samsonasik samsonasik merged commit aa72821 into main Sep 5, 2023
@samsonasik samsonasik deleted the return-statuc branch September 5, 2023 17:00
Copy link
Copy Markdown
Contributor

@staabm staabm left a comment

Choose a reason for hiding this comment

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

Nice 😊

ClassMethod $classMethod,
ClassReflection $classReflection
): ClassMethod {
$classMethod->returnType = $this->shouldSelf($classReflection)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Maybe we could additionally add static phpdoc type on php7?

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.

That seems can be an improvement next 👍 with check not support static, but not final class and not anonymous class.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants