phpstan-src icon indicating copy to clipboard operation
phpstan-src copied to clipboard

Treat array-shapes without keys as tuples

Open zonuexe opened this issue 11 months ago • 3 comments

refs https://github.com/phpstan/phpstan/issues/12725

zonuexe avatar Mar 11 '25 11:03 zonuexe

I'm a bit surprised that this single change digs up list-shapes that were previously imported from Psalm.

2) PHPStan\Analyser\NodeScopeResolverTest::testFile with data set "tests/PHPStan/Analyser/nsrt/list-shapes.php" ('/home/runner/work/phpstan-src...es.php')
Failed assertions in /home/runner/work/phpstan-src/phpstan-src/tests/PHPStan/Analyser/nsrt/list-shapes.php:

Line 21:
Expected: array{'a'}
Actual:   list{'a'}

Line 22:
Expected: array{'a', 'b'}
Actual:   list{'a', 'b'}

Line 23:
Expected: array{0: 'a', 1?: 'b'}
Actual:   list{0: 'a', 1?: 'b'}

zonuexe avatar Mar 11 '25 12:03 zonuexe

We tried something similar here but decided against it https://github.com/phpstan/phpstan-src/pull/3381

ondrejmirtes avatar Mar 11 '25 15:03 ondrejmirtes

I don't think we should make any difference between array{int} and array{0: int}`. It should be the same thing...

ondrejmirtes avatar Mar 11 '25 15:03 ondrejmirtes