-
Notifications
You must be signed in to change notification settings - Fork 523
Add dynamic return type extension for date_create #1413
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
Conversation
5a2d950
to
20d5398
Compare
20d5398
to
5cbc0b7
Compare
use function in_array; | ||
|
||
class DateTimeDynamicReturnTypeExtension implements DynamicFunctionReturnTypeExtension | ||
{ | ||
|
||
public function isFunctionSupported(FunctionReflection $functionReflection): bool | ||
{ | ||
return in_array($functionReflection->getName(), ['date_create_from_format', 'date_create_immutable_from_format'], true); | ||
return in_array($functionReflection->getName(), ['date_create', 'date_create_immutable'], true); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can't read this diff. Please give a different name to your new extension and don't change an existing file.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Diff should be better now.
$datetime = $scope->getType($functionCall->getArgs()[0]->value); | ||
|
||
if (!$datetime instanceof ConstantStringType) { | ||
return $defaultReturnType; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The code of the extension can be simplified now. Instead of $defaultReturnType
, you can simply return null
here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it better now ?
Thank you! |
No description provided.