Skip to content

AddArrowFunctionReturnTypeRectorTest will fail with next PHPStan version #9763

Description

@VincentLanglet

Hi @TomasVotruba @samsonasik

Because of recent merge on PHPStan the test https://github.com/rectorphp/rector-src/blob/5be8f82d019842fb56fd0338da0b0569dbdf0bcb/rules-tests/TypeDeclaration/Rector/ArrowFunction/AddArrowFunctionReturnTypeRector/Fixture/return_by_array_shape_type.php.inc will fail on next PHPStan release.

To me, this seems to be expected since you're calling getNativeType
https://github.com/rectorphp/rector-src/blob/5be8f82d019842fb56fd0338da0b0569dbdf0bcb/rules/TypeDeclaration/Rector/ArrowFunction/AddArrowFunctionReturnTypeRector.php#L61

And in

/**
     * @param array<int, array{bar: int}> $values
     */
    private function foo(array $values): void
    {
        $bars = array_map(fn($value) => $value['bar'], $values);
    }

the native type of $value['bar'] was fixed from int to mixed. (Cause $values is just an array)

I dunno if you want to

  • change your implementation
  • remove/update the test

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions