Skip to content

Preserve source types during destructuring assignments - #6760

Open
Gabrieljr42 wants to merge 2 commits into
phpstan:2.3.xfrom
Gabrieljr42:fix/destructuring-rhs-types
Open

Gabrieljr42 wants to merge 2 commits into
phpstan:2.3.xfrom
Gabrieljr42:fix/destructuring-rhs-types

Conversation

@Gabrieljr42

Copy link
Copy Markdown

Fixes phpstan/phpstan#15091.
Also covers the case in phpstan/phpstan#15181.

Destructuring now keeps the original source types while assigning each item. Reusing the source variable in an earlier item no longer changes the inferred types of the remaining items. I applied the same fix to the Turbo implementation and updated its expected version.

The regression fails on the original code and passes after the fix. I ran the full suite on PHP 8.3 with and without Turbo: 22,340 tests in each run, 204 skipped, no failures. The native run uses one worker with batches of 10 files to keep memory usage down.

The strict native build, smoke test, signature check and regression walk trace also pass. The side-by-side script reports the same diagnostics on the base and this branch, with identical output.

I used AI assistance for the implementation and tests.

@Gabrieljr42

Copy link
Copy Markdown
Author

I checked the two E2E failures. The parse-error case has the same "expected 1, got 0" failure on the current 2.3.x base.

The other job stopped while downloading the bashunit checksum, before running its tests. Both local full suites passed, with and without Turbo.

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.

Destructuring reassignment loses type info

1 participant