Skip to content

Prevent inheritance of class template types in static methods #2738

Description

@muglug

Instance template parameters should not be made available to static methods – this was a flaw in my implementation, now fixed. If/when generics are available at the language level this can be re-evaluated.

/**
 * @template T
 */
class C {
    /**
     * @param T $t
     */
    public static function foo($t) : void {}
}

https://phpstan.org/r/e00cd9e1-3aba-4e6c-ab9a-8e63da122b94

Expected: some sort of error (in Psalm for now it just treats it as a missing docblock class, you may want something more helpful).

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions