Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Prevent use of existing userland classes as template names #2578

@muglug

Description

@muglug

Bug report

Perhaps this is just a problem with the online playground (as Throwable is prevented), but...

Code snippet that reproduces the problem

namespace Foo;

class Bar {}

/**
 * @template Bar of \DOMNode
 *
 * @param class-string<Bar> $foo
 */
function Foo(string $foo) : string {
	return $foo;
}

https://phpstan.org/r/4e2bb93c-0397-488f-b58d-d0c146d0f1ea

Expected output

Cannot use Bar as template name since the class already exists

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions