Skip to content

Psalm type-related issues #20453

@s1lver

Description

@s1lver

The recent type additions appear somewhat questionable in several places. Many aspects are concerning. For instance, we're running Psalm at error level 1 (with one exception - MixedAssignment) - while 2.0.52 shows no errors, 2.0.53 suddenly reports 197 new errors! Given that Psalm serves as our CI quality gate, these typing changes effectively break backward compatibility.

Yii 2.0.53

 * @psalm-type RegisterJsFileOptions = array{
 *     depends?: class-string[],
 *     position?: int,
 *     appendTimestamp?: boolean
 * }

Code

$this->jsOptions = [
    'type' => 'module',
    'crossorigin' => true,
];

Psalm error level 1:

ERROR: InvalidPropertyAssignmentValue - $this->jsOptions with declared type 'array{appendTimestamp?: bool, depends?: array<array-key, class-string>, position?: int}' cannot be assigned type 'array{crossorigin: true, type: 'module'}' (see https://psalm.dev/145)

We should either be more cautious with such additions or at minimum document them properly in UPGRADE.md

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions