Skip to content

Template references in the same class #29

@dpi

Description

@dpi

As referred by #17 (comment)

The library doesn't know what to do about template references in the same class, as in:

https://phpstan.org/r/9f0ab119-cd14-47f0-8a5a-ac8cb69f3b6c

The last three examples here have Generic<T> where T is defined in the same class.


/**
 * @template T
 */
class A {
	/**
	 * @return T
	 */
	public function m() {
		// @phpstan-ignore-next-line
		return '';
	}
}

/**
 * @extends A<Z>
 * @template Z of int
 */
class C extends A {}

Library thinks m() returns a Z, instead of int.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions