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

[TypeDeclaration] Skip possible void and return by docblock on ReturnTypeFromMockObjectRector #6170

Merged
merged 2 commits into from
Jul 22, 2024

Conversation

samsonasik
Copy link
Member

  • Use ReturnAnalyzer to verify possible void
  • Use getNativeType() to ensure it returns native type

@samsonasik
Copy link
Member Author

All checks have passed 🎉 @TomasVotruba I am merging it ;)

@samsonasik samsonasik merged commit ecdb0d4 into main Jul 22, 2024
34 checks passed
@samsonasik samsonasik deleted the skip-possible-void-doc branch July 22, 2024 00:21
@TomasVotruba
Copy link
Member

👍

return null;
}

$returnType = $this->getType($soleReturn->expr);
Copy link
Contributor

Choose a reason for hiding this comment

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

I wonder whethere there are real use-cases for getType() anymore, or whether this method should be deprecated in favor of getNativeType...?

Copy link
Member Author

@samsonasik samsonasik Jul 22, 2024

Choose a reason for hiding this comment

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

getType() is stil usefull for:

  • get type from php native function/methods, yes, it got mixed on getNativeType()
  • downgrade process
  • get object type from method call / static call
  • verify transformation that too much for only native check, eg,
/** @var string $var */
trim($var)

that cast (string) is not needed on that case.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ok, said differently: its only useful in very few edge cases but the name misleads even rector-src core developers to use it wrongly in lots of situations

Copy link
Member

Choose a reason for hiding this comment

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

Given rare context, this is used on purpose here 👍

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.

3 participants