Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

[Validator] Add the type for ConstraintValidatorTestCase::createValidator #48012

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

Merged
merged 1 commit into from
Nov 9, 2022

Conversation

stof
Copy link
Member

@stof stof commented Oct 27, 2022

Q A
Branch? 6.2
Bug fix? no
New feature? no
Deprecations? no
Tickets n/a
License MIT
Doc PR n/a

@carsonbot carsonbot added this to the 6.2 milestone Oct 27, 2022
@xabbuh
Copy link
Member

xabbuh commented Oct 27, 2022

Do we need to add the changed file in the list of excluded classes in patch-types.php?

@stof
Copy link
Member Author

stof commented Oct 27, 2022

indeed, we should (and ideally, we should update the patcher to account for @template)

@stof
Copy link
Member Author

stof commented Oct 27, 2022

Looking at it, the patcher handles template type only when the method has a native return type.

Maybe this should be typed like that for now, to account for adding a native return type in Symfony 7.0:

    /**
     * @return ConstraintValidatorInterface
     * @psalm-return T
     */
    abstract protected function createValidator();

This way, in 7.0, we can add ConstraintValidatorInterface as a native return type (and switch to @return T for the template).

@nicolas-grekas
Copy link
Member

@stof that'd make sense to me.

@carsonbot carsonbot changed the title Add the type for ConstraintValidatorTestCase::createValidator [Validator] Add the type for ConstraintValidatorTestCase::createValidator Oct 28, 2022
@stof
Copy link
Member Author

stof commented Nov 2, 2022

I updated the PR

nicolas-grekas added a commit that referenced this pull request Nov 2, 2022
…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
@nicolas-grekas
Copy link
Member

rebase needed

@stof
Copy link
Member Author

stof commented Nov 8, 2022

@nicolas-grekas The rebase is done

@nicolas-grekas
Copy link
Member

Thank you @stof.

@nicolas-grekas nicolas-grekas merged commit 36e240c into symfony:6.2 Nov 9, 2022
@stof stof deleted the better_generic branch March 7, 2024 10:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants
Morty Proxy This is a proxified and sanitized view of the page, visit original site.