[PR #8708] Fix ClassMetadaInfo template inference #11136

Closed
opened 2026-01-22 16:09:50 +01:00 by admin · 0 comments
Owner

Original Pull Request: https://github.com/doctrine/orm/pull/8708

State: closed
Merged: Yes


Hi @greg0ire, I saw you fixed some psalm issue recently
6de321cb09

Currently the following code

    /**
     * @phpstan-template T of object
     * @phpstan-param class-string<T> $class
     * @phpstan-return ClassMetadata<T>
     */
    private function getMetadata(string $class): ClassMetadata
    {
        return new ClassMetadata($class);
    }

is not working, since new ClassMetadata($class) is inferred as ClassMetadata<object>.

Which lead to weird static analysis issue in 2.8.5 release.

I fix this in this PR.

**Original Pull Request:** https://github.com/doctrine/orm/pull/8708 **State:** closed **Merged:** Yes --- Hi @greg0ire, I saw you fixed some psalm issue recently https://github.com/doctrine/orm/commit/6de321cb09d7208ff3930db50b0bedaf7ca39d92 Currently the following code ``` /** * @phpstan-template T of object * @phpstan-param class-string<T> $class * @phpstan-return ClassMetadata<T> */ private function getMetadata(string $class): ClassMetadata { return new ClassMetadata($class); } ``` is not working, since `new ClassMetadata($class)` is inferred as `ClassMetadata<object>`. Which lead to weird static analysis issue in 2.8.5 release. I fix this in this PR.
admin added the pull-request label 2026-01-22 16:09:50 +01:00
admin closed this issue 2026-01-22 16:09:51 +01:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#11136