Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Treat array-shapes without keys as tuples #3872

Draft
wants to merge 4 commits into
base: 2.1.x
Choose a base branch
from

Conversation

zonuexe
Copy link
Contributor

@zonuexe zonuexe commented Mar 11, 2025

@zonuexe zonuexe marked this pull request as draft March 11, 2025 11:52
@zonuexe zonuexe changed the title Impl keyless array-shapes as Tuple Treat array-shapes without keys as tuples Mar 11, 2025
@zonuexe
Copy link
Contributor Author

zonuexe commented Mar 11, 2025

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 zonuexe force-pushed the feature/keyless-constant-as-tuple branch from dbc452f to c044612 Compare March 11, 2025 12:42
@ondrejmirtes
Copy link
Member

We tried something similar here but decided against it #3381

@ondrejmirtes
Copy link
Member

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants