Skip to content

Conversation

@HypeMC
Copy link
Member

@HypeMC HypeMC commented Oct 5, 2025

Q A
Branch? 7.3
Bug fix? yes
New feature? no
Deprecations? no
Issues -
License MIT

#61752 broke the resolution of templated types.

Consider the following code:

/**
 * @template T of object
 */
abstract class ParentClass
{
    /**
     * @param list<T> $items
     */
    public function __construct(
        public array $items,
    ) {
    }
}

/**
 * @template T of SomeClass
 *
 * @extends ParentClass<T>
 */
class ChildClass extends ParentClass
{
}

$serializer->deserialize($jsonPayload, ChildClass::class, 'json');

Before that PR, after deserialization, $items would correctly contain a list of SomeClass instances.
Now it no longer works, $items is a list of associative arrays instead.

@HypeMC HypeMC requested a review from mtarld October 5, 2025 18:48
@HypeMC HypeMC requested a review from dunglas as a code owner October 5, 2025 18:48
@carsonbot carsonbot added this to the 7.3 milestone Oct 5, 2025
@HypeMC HypeMC force-pushed the fix-constructor-type-with-template branch from d94d1c4 to 9b85dd4 Compare October 5, 2025 21:54
@HypeMC HypeMC force-pushed the fix-constructor-type-with-template branch from 9b85dd4 to 7ad51ea Compare October 5, 2025 22:12
@nicolas-grekas
Copy link
Member

Thank you @HypeMC.

@nicolas-grekas nicolas-grekas merged commit bc93e57 into symfony:7.3 Oct 6, 2025
9 of 11 checks passed
@HypeMC HypeMC deleted the fix-constructor-type-with-template branch October 6, 2025 07:32
@nicolas-grekas
Copy link
Member

Can you please submit to 7.4? I didn't merge the change up from 7.3. Too heavy conflict :)

xabbuh added a commit that referenced this pull request Oct 6, 2025
… (HypeMC)

This PR was merged into the 7.4 branch.

Discussion
----------

[TypeInfo] Fix resolving constructor type with templates

| Q             | A
| ------------- | ---
| Branch?       | 7.4
| Bug fix?      | no
| New feature?  | no
| Deprecations? | no
| Issues        | #61964 (comment)
| License       | MIT

Applies changes from #61964 to the 7.4 branch.

Commits
-------

51ccc9f [TypeInfo] Fix resolving constructor type with templates
@fabpot fabpot mentioned this pull request Oct 28, 2025
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.

3 participants