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

[PHP 74] Add ChangeReflectionTypeToStringToGetNameRector #2182

Merged
merged 2 commits into from Oct 24, 2019

Conversation

TomasVotruba
Copy link
Member

@TomasVotruba TomasVotruba commented Oct 18, 2019

Changes deprecated TypeReflection::__toString() method:

 public function go(ReflectionFunction $reflectionFunction)
 {
     $parameterReflection = $reflectionFunction->getParameters()[0];
-    $paramType = (string) $parameterReflection->getType();
+    $paramType = (string) ($parameterReflection->getType() ? $parameterReflection->getType()->getName() : null);

-    $stringValue = 'hey' . $reflectionFunction->getReturnType();
+    $stringValue = 'hey' . ($reflectionFunction->getReturnType() ? $reflectionFunction->getReturnType()->getName() : null);
 }

Closes #2160

Should cover cases like:

@TomasVotruba TomasVotruba force-pushed the php74-ref-type branch 2 times, most recently from 7fb5f47 to 6f36f58 Compare October 18, 2019 21:57
@TomasVotruba TomasVotruba force-pushed the php74-ref-type branch 2 times, most recently from b85537c to 190f4c6 Compare October 23, 2019 23:21
@TomasVotruba TomasVotruba merged commit 080f07e into master Oct 24, 2019
@TomasVotruba TomasVotruba deleted the php74-ref-type branch October 24, 2019 07:44
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 7.4] Function ReflectionType::__toString() is deprecated
2 participants