-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Form] Add generics to DataTransformerInterface #47412
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
Hey! To help keep things organized, we don't allow "Draft" pull requests. Could you please click the "ready for review" button or close this PR and open a new one when you are done? Note that a pull request does not have to be "perfect" or "ready for merge" when you first open it. We just want it to be ready for a first review. Cheers! Carsonbot |
b5a2479
to
0a19d7a
Compare
@@ -40,8 +42,8 @@ public function transform(mixed $dateTime): string | |||
return ''; | |||
} | |||
|
|||
if (!$dateTime instanceof \DateTime && !$dateTime instanceof \DateTimeInterface) { |
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.
DateTime implements DateTimeInterface
@@ -95,7 +97,7 @@ public function transform(mixed $dateTime): string | |||
/** | |||
* Transforms a localized date string/array into a normalized date. | |||
* | |||
* @param string|array $value Localized date string/array |
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 method start with if (!\is_string($value)) {
Hey! I think @mvorisek has recently worked with this code. Maybe they can help review this? Cheers! Carsonbot |
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.
LGTM, here are some comments to iterate.
...ny/Component/Form/Extension/Core/DataTransformer/DateTimeToHtml5LocalDateTimeTransformer.php
Outdated
Show resolved
Hide resolved
8f90ccf
to
f9e36ab
Compare
Thank you @VincentLanglet. |
f9e36ab
to
dff26d3
Compare
…t the patcher (stof) This PR was merged into the 6.2 branch. Discussion ---------- Fix the DataTransformerInterface generic types to support the patcher | Q | A | ------------- | --- | Branch? | 6.2 | Bug fix? | no | New feature? | no | Deprecations? | no | Tickets | | License | MIT | Doc PR | n/a The type patcher adding return types handles template types only for methods that already have a return type. As `DataTransformerInterface` is not typed yet in Symfony 6.x, we need to keep the future native types in ``@return`` for the patcher tool. This puts the generic type (introduced in #47412) in ``@psalm`-return`, as done in #48012 (I detected this issue when regenerating the return type for that other PR) Commits ------- d9fd5c7 Fix the DataTransformerInterface generic types to support the patcher
Now that some generics are added to the Symfony codebase, I think we could add more.
For people using phpstan/psalm this will be helpful:
You can look at the current generic definition
for psalm https://github.com/psalm/psalm-plugin-symfony/blob/master/src/Stubs/common/Component/Form/DataTransformerInterface.stubphp
for phpstan https://github.com/phpstan/phpstan-symfony/blob/1.2.x/stubs/Symfony/Component/Form/DataTransformerInterface.stub