Skip to content

generics support (phpstan) #1992

@etshy

Description

@etshy
Subject Details
Plugin Php Inspections (EA Extended), 5.4.0
Language level php 8.1

Current behaviour

generics with @template of Interface not working correctly.
Here is my following phpDoc

   /**
     * @template T of TestInterface
     * @param T $test
     * @return T
     */
    public function callTest(TestInterface $test): TestInterface

In a method where $test is typehinted to a specific class, implementing TestInterface

public function (Test1 $test)
{
     $test = $otherClass->callTest($test);
}

Here, PhpStorm understand $test is still an instance of Test1 but EA gives me a warning

[EA] New value type (TestInterface) is not matching the resolved parameter type and might introduce types-related false-positives. 

Expected behaviour

EA should interpret generics and that the returned object is of the same instance as the one passed in argument.

Environment details

Build #PS-252.27397.112, built on October 24, 2025

Metadata

Metadata

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions