← 输入框|github.com|刷新
Skip to content

Limit associative array cast checks to matching keys - #6578

Merged
ondrejmirtes merged 1 commit into
phpstan:2.3.xfrom
midhunmonachan:fix-array-diff-assoc-key-overlap
Nov 1, 2026
Merged

ondrejmirtes merged 1 commit into
phpstan:2.3.xfrom
midhunmonachan:fix-array-diff-assoc-key-overlap

Conversation

@midhunmonachan

@midhunmonachan midhunmonachan commented Sep 24, 2026 •

Copy link
Copy Markdown
Contributor

array_diff_assoc() and array_intersect_assoc() only compare values when their keys can match. PHPStan was checking every value and could report on unrelated non-stringable values.

This narrows the castability check to values under overlapping keys and adds a regression test for the reported case while keeping errors for shared non-stringable values.

Closes phpstan/phpstan#15261

Checks:

  • Full test suite: 22,071 tests, 67 skipped
  • bin/phpstan -v
  • PHPStan coding standard on changed files

The current 2.3.x base also has a pre-existing Turbo version-pin check failure after commit 17972fe; this PR does not touch turbo-ext.

@midhunmonachan
midhunmonachan force-pushed the fix-array-diff-assoc-key-overlap branch from 5072c0f to fd968ae Compare September 24, 2026 17:55
@midhunmonachan
midhunmonachan force-pushed the fix-array-diff-assoc-key-overlap branch from fd968ae to b9efac7 Compare September 24, 2026 18:08
@ondrejmirtes
ondrejmirtes merged commit d992768 into phpstan:2.3.x Nov 1, 2026
496 of 534 checks passed
@ondrejmirtes

Copy link
Copy Markdown
Member

Thank you.

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.

False positive on array_diff_assoc with non-string values in the first array

2 participants