Skip to content

WeakMap does not accept template parameters #5311

@iggyvolz

Description

@iggyvolz

When marking the template types of WeakMap, Psalm will notify you that WeakMap has no template params.

https://psalm.dev/r/b8cfb54105 (it appears WeakMap is not loaded on this environment - may be running 7.4):

ERROR: TooManyTemplateParams - src/test.php:4:11 - WeakMap<x, int> has too many template params, expecting 0 (see https://psalm.dev/184)
 * @param WeakMap<x,int> $wm

PHPStan reports a failure when template params are omitted for WeakMap, and a success when two template types are given.

Metadata

Metadata

Assignees

No one assigned

    Labels

    easy problemsIssues that can be fixed without background knowledge of Psalmenhancement

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions