René's URL Explorer Experiment


Title: Read a merged array shape's list-ness in both key orders by gnutix · Pull Request #7000 · phpstan/phpstan-src · GitHub

Open Graph Title: Read a merged array shape's list-ness in both key orders by gnutix · Pull Request #7000 · phpstan/phpstan-src

X Title: Read a merged array shape's list-ness in both key orders by gnutix · Pull Request #7000 · phpstan/phpstan-src

Description: Closes phpstan/phpstan#15679 When two literal arrays with the same keys differ at a single key, TypeCombinator::union() merges them into one shape (ConstantArrayType::mergeWith()). The merged shape keeps $this's key order. To decide whether it is a list, mergeWith() ors the inputs' own list-ness with inferIsListFromShape(), which reads the merged keys in that order. When the other side has the same keys in another order, that reading only describes $this's arrays: [1 => 0, 0 => 0] merged into [0 => 1, 1 => 0] reads as keys 0, 1, so the union became a list (array_is_list() "will always evaluate to true"); the other way round, it reads as 1, 0, so the union became never a list ("will always evaluate to false"), and the else branch of if (array_is_list($x)) was *NEVER*. The fix reads the merged shape in the other side's order too: its keys first, then the rest. If both readings agree, nothing changes. If they disagree, the shape is maybe a list. When both inputs are lists, mergeWith() now skips the shape reading altogether, since or-ing it into yes cannot change anything. legacyMergeWith() (no bleeding edge) gets the same change. The union still merges into a single shape; this PR only fixes what that shape claims about list-ness. Keeping both shapes when the keys come in a different order would be more precise, but it would change which unions merge, well beyond list-ness (string keys included). That is the territory of phpstan/phpstan#11600, which this PR does not touch. Before / after Code Before After $x = $b ? [1 => 0, 0 => 0] : [0 => 1, 1 => 0]; array_is_list($x) true, "will always evaluate to true" bool $b ? [1 => 'a', 0 => 'b'] : [0 => 'c', 1 => 'a'] true, "will always evaluate to true" bool $x = $b ? [0 => 1, 1 => 0] : [1 => 0, 0 => 0]; array_is_list($x) false, "will always evaluate to false" bool same values: $b ? [1 => 0, 0 => 0] : [0 => 0, 1 => 0] true bool same values: $b ? [0 => 0, 1 => 0] : [1 => 0, 0 => 0] false bool else branch of if (array_is_list($x)), first row *NEVER* array{0|1, 0} values differing at two keys (not merged) bool bool (unchanged) same key order: $b ? [0 => 0, 1 => 0] : [0 => 1, 1 => 0] true true (unchanged) Tests: tests/PHPStan/Analyser/nsrt/bug-15679.php covers the rows above, and ConstantArrayTypeTest::testMergeWithRecomputesListnessOfSealedShape() gets five cases: both merge orders on both paths, and a key ahead of the shared one on the other side. Without the fix, six assertType() calls and all five unit cases fail. Turbo ConstantArrayType is shadowed, so turbo-ext/src/ConstantArrayType.cpp gets the same change (inferMergedIsListFromShape(), called from mergeWith() and legacyMergeWith()). Built with make build-turbo (GCC 15.3), no warnings. The checks below ran on 319b28d49; the branch was then rebased onto 48f825b2d, which only changes the benchmark tooling. turbo-ext/tests/smoke.php: ALL OK. turbo-ext/tests/signature-parity.php: OK. turbo-ext/bin/side-by-side.php: all methods paired. Full suite with the extension loaded and without it: 23,571 tests pass each way (2 deprecations and 89 skips, the same as on the base), PHP 8.5.12, 4 workers. Analysis output (--error-format=raw) byte-identical with the extension on and off: the self-analysis of src/ (build/phpstan.neon, 0 errors either way; user CPU 4m59s without, 2m58s with, so the extension was really active), and the issue's snippet plus bug-15679.php. 🤖 Generated with Claude Code (Opus 5.5)

Open Graph Description: Closes phpstan/phpstan#15679 When two literal arrays with the same keys differ at a single key, TypeCombinator::union() merges them into one shape (ConstantArrayType::mergeWith()). The merged shape...

X Description: Closes phpstan/phpstan#15679 When two literal arrays with the same keys differ at a single key, TypeCombinator::union() merges them into one shape (ConstantArrayType::mergeWith()). The merged shape...

Opengraph URL: https://github.com/phpstan/phpstan-src/pull/7000

X: @github

direct link

Domain: github.com

react-profiling0
react-import-mapreact,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322
route-pattern/:user_id/:repository/pull/:id/files(.:format)
route-controllerpull_requests
route-actionfiles
fetch-noncev2:592371ad-71b2-0b77-9f9c-73db04de92f2
current-catalog-service-hashae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b
request-idC858:1D865F:48D449:639420:6B007085
html-safe-nonce6051ea575652d2fbe32ac6c25661eae77ba7564297cc9afb9521f4924598bf7d
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDODU4OjFEODY1Rjo0OEQ0NDk6NjM5NDIwOjZCMDA3MDg1IiwidmlzaXRvcl9pZCI6IjYxMTgyOTQzNzc0OTI2MTMiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ==
visitor-hmac9d2196fbf900f4fb685d302f3b638a8bcfff3e611f25390573313d63f643f52c
hovercard-subject-tagpull_request:5202124634
github-keyboard-shortcutsrepository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///pull_requests/show/files
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/phpstan/phpstan-src/pull/7000/files
twitter:imagehttps://avatars.githubusercontent.com/u/310134?s=400&v=4
twitter:cardsummary_large_image
og:imagehttps://avatars.githubusercontent.com/u/310134?s=400&v=4
og:image:altCloses phpstan/phpstan#15679 When two literal arrays with the same keys differ at a single key, TypeCombinator::union() merges them into one shape (ConstantArrayType::mergeWith()). The merged shape...
og:site_nameGitHub
og:typeobject
hostnamegithub.com
expected-hostnamegithub.com
None6527e91c60c0b29d16606ff32ac5df8ecdc37a2a62205ea057a14d7762c870fa
turbo-cache-controlno-preview
diff-viewunified
go-importgithub.com/phpstan/phpstan-src git https://github.com/phpstan/phpstan-src.git
octolytics-dimension-user_id16435710
octolytics-dimension-user_loginphpstan
octolytics-dimension-repository_id219334214
octolytics-dimension-repository_nwophpstan/phpstan-src
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id219334214
octolytics-dimension-repository_network_root_nwophpstan/phpstan-src
turbo-body-classeslogged-out env-production page-responsive full-width
disable-turbotrue
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release46f1cd2ae3cd8ae1a81019b5d619742e76f13bbd
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/phpstan/phpstan-src/pull/7000/changes#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fphpstan%2Fphpstan-src%2Fpull%2F7000%2Ffiles
GitHubRepository hosting, code review, and collaborationhttps://github.com/platform
CopilotAI coding agent for tasks, projects, and automated workhttps://github.com/features/copilot
ActionsCI/CD and automationhttps://github.com/features/actions
Code QualityQuality analysis, fixes, and enforcementhttps://github.com/features/code-quality
CodespacesCloud development environmentshttps://github.com/features/codespaces
Code SecurityVulnerability detection and remediationhttps://github.com/security/advanced-security/code-security
Secret ProtectionSecret scanning and leak preventionhttps://github.com/security/advanced-security/secret-protection
All Featureshttps://github.com/features
Documentationhttps://docs.github.com/en
Traininghttps://learn.github.com/skills
Certificationshttps://learn.github.com/credentials
Build with Copilothttps://github.com/features/ai
Customize Copilothttps://docs.github.com/en/copilot/how-tos/copilot-on-github/customize-copilot/customize-copilot-overview
Integrationshttps://github.com/marketplace
Trending reposhttps://github.com/trending
GitHub Sponsorshttps://github.com/open-source/sponsors
Developer articleshttps://github.com/resources/articles
ChangelogYour source for the latest features, improvements, and fixes across GitHub products, all in one place.https://github.blog/changelog/
Enterpriseshttps://github.com/enterprise
Teamhttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
See all industrieshttps://github.com/solutions/industry
Why GitHubhttps://github.com/why-github
Customer Storieshttps://github.com/customer-stories
Business insightshttps://github.com/solutions/executive-insights
Trust Centerhttps://github.com/trust-center
GitHub Advanced SecurityEnterprise-grade code securityhttps://github.com/security/advanced-security
Copilot for businessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Documentationhttps://docs.github.com/en
Resource centerhttps://github.com/resources
Bloghttps://github.blog/
Events & webinarshttps://github.com/resources/events
Community Forumhttps://github.com/orgs/community/discussions
Customer Storieshttps://github.com/customer-stories
Integrationshttps://github.com/marketplace
Customer supporthttps://help.github.com/
Traininghttps://learn.github.com/skills
GitHub Statushttps://www.githubstatus.com/
Abouthttps://github.com/about
Partnershttps://github.com/partners
Changeloghttps://github.blog/changelog/
GitHub UniverseThe event for developers, by developers — talks, workshops, and what’s next for GitHub.https://githubuniverse.com/
Pricinghttps://github.com/pricing
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fphpstan%2Fphpstan-src%2Fpull%2F7000%2Ffiles
Sign uphttps://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fpull_requests%2Fshow%2Ffiles&source=header-repo&source_repo=phpstan%2Fphpstan-src
Reloadhttps://github.com/phpstan/phpstan-src/pull/7000/changes
Reloadhttps://github.com/phpstan/phpstan-src/pull/7000/changes
Reloadhttps://github.com/phpstan/phpstan-src/pull/7000/changes
phpstanhttps://github.com/phpstan
phpstan-srchttps://github.com/phpstan/phpstan-src
Codehttps://github.com/phpstan/phpstan-src
Pull requests185 (185)https://github.com/phpstan/phpstan-src/pulls
Actionshttps://github.com/phpstan/phpstan-src/actions
Security and qualityhttps://github.com/phpstan/phpstan-src/security
Insightshttps://github.com/phpstan/phpstan-src/insights
Sign up for GitHub https://github.com/signup?return_to=%2Fphpstan%2Fphpstan-src%2Fissues%2Fnew%2Fchoose
terms of servicehttps://docs.github.com/terms
privacy statementhttps://docs.github.com/privacy
Sign inhttps://github.com/login?return_to=%2Fphpstan%2Fphpstan-src%2Fissues%2Fnew%2Fchoose
gnutixhttps://github.com/gnutix
phpstan:2.3.xhttps://github.com/phpstan/phpstan-src/tree/2.3.x
gnutix:union-constant-arrays-key-orderhttps://github.com/gnutix/phpstan-src/tree/union-constant-arrays-key-order
Conversation 0 https://github.com/phpstan/phpstan-src/pull/7000
Commits 2 https://github.com/phpstan/phpstan-src/pull/7000/commits
Checks 892 https://github.com/phpstan/phpstan-src/pull/7000/checks
Files changed https://github.com/phpstan/phpstan-src/pull/7000/files
Please reload this pagehttps://github.com/phpstan/phpstan-src/pull/7000/changes
Read a merged array shape's list-ness in both key orders https://github.com/phpstan/phpstan-src/pull/7000/changes#top
Show all changes 2 commits https://github.com/phpstan/phpstan-src/pull/7000/files
2132f32 Read a merged array shape's list-ness in both key orders gnutix Nov 7, 2026 https://github.com/phpstan/phpstan-src/pull/7000/commits/2132f32494dc130364d638bf12788bd4e686fe34
c766c75 Regenerate the turbo declarations of ConstantArrayType gnutix Nov 7, 2026 https://github.com/phpstan/phpstan-src/pull/7000/commits/c766c75bd428a41a9a6f123d8ed58a361a64fb44
Clear filters https://github.com/phpstan/phpstan-src/pull/7000/files
Please reload this pagehttps://github.com/phpstan/phpstan-src/pull/7000/changes
Please reload this pagehttps://github.com/phpstan/phpstan-src/pull/7000/changes
ConstantArrayType.php https://github.com/phpstan/phpstan-src/pull/7000/changes#diff-2e28cc3b285eae2b224df51cda5d6d532675e945e2995e2cd76293bca56799d6
bug-15679.php https://github.com/phpstan/phpstan-src/pull/7000/changes#diff-16ac7b84b5061ca925b742053f257d58edda82c784a5a604639a90991c28304e
ConstantArrayTypeTest.php https://github.com/phpstan/phpstan-src/pull/7000/changes#diff-b09770c07117bc80dc346dc14ecb289919046fce9042c741ea5070dac7298c9b
ConstantArrayType.cpp https://github.com/phpstan/phpstan-src/pull/7000/changes#diff-b0d6b2f8b95681b17dfd30ce9b49ffc51257ca5544e579fd6a41a2db178c9260
ConstantArrayType.h https://github.com/phpstan/phpstan-src/pull/7000/changes#diff-3a6e281ef367aec8016e14cfe991ca4625e428017352fc3908ab13b331d36e9f
src/Type/Constant/ConstantArrayType.phphttps://github.com/phpstan/phpstan-src/pull/7000/changes#diff-2e28cc3b285eae2b224df51cda5d6d532675e945e2995e2cd76293bca56799d6
View file https://github.com/phpstan/phpstan-src/blob/c766c75bd428a41a9a6f123d8ed58a361a64fb44/src/Type/Constant/ConstantArrayType.php
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/phpstan/phpstan-src/pull/7000/{{ revealButtonHref }}
https://github.com/phpstan/phpstan-src/pull/7000/changes#diff-2e28cc3b285eae2b224df51cda5d6d532675e945e2995e2cd76293bca56799d6
https://github.com/phpstan/phpstan-src/pull/7000/changes#diff-2e28cc3b285eae2b224df51cda5d6d532675e945e2995e2cd76293bca56799d6
https://github.com/phpstan/phpstan-src/pull/7000/changes#diff-2e28cc3b285eae2b224df51cda5d6d532675e945e2995e2cd76293bca56799d6
https://github.com/phpstan/phpstan-src/actions/runs/42378525786/job/128422346356?pr=7000
https://github.com/phpstan/phpstan-src/actions/runs/42378525786/job/128422346366?pr=7000
https://github.com/phpstan/phpstan-src/pull/7000/changes#diff-2e28cc3b285eae2b224df51cda5d6d532675e945e2995e2cd76293bca56799d6
https://github.com/phpstan/phpstan-src/pull/7000/changes#diff-2e28cc3b285eae2b224df51cda5d6d532675e945e2995e2cd76293bca56799d6
https://github.com/phpstan/phpstan-src/pull/7000/changes#diff-2e28cc3b285eae2b224df51cda5d6d532675e945e2995e2cd76293bca56799d6
tests/PHPStan/Analyser/nsrt/bug-15679.phphttps://github.com/phpstan/phpstan-src/pull/7000/changes#diff-16ac7b84b5061ca925b742053f257d58edda82c784a5a604639a90991c28304e
View file https://github.com/phpstan/phpstan-src/blob/c766c75bd428a41a9a6f123d8ed58a361a64fb44/tests/PHPStan/Analyser/nsrt/bug-15679.php
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/phpstan/phpstan-src/pull/7000/{{ revealButtonHref }}
tests/PHPStan/Type/Constant/ConstantArrayTypeTest.phphttps://github.com/phpstan/phpstan-src/pull/7000/changes#diff-b09770c07117bc80dc346dc14ecb289919046fce9042c741ea5070dac7298c9b
View file https://github.com/phpstan/phpstan-src/blob/c766c75bd428a41a9a6f123d8ed58a361a64fb44/tests/PHPStan/Type/Constant/ConstantArrayTypeTest.php
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/phpstan/phpstan-src/pull/7000/{{ revealButtonHref }}
https://github.com/phpstan/phpstan-src/pull/7000/changes#diff-b09770c07117bc80dc346dc14ecb289919046fce9042c741ea5070dac7298c9b
https://github.com/phpstan/phpstan-src/pull/7000/changes#diff-b09770c07117bc80dc346dc14ecb289919046fce9042c741ea5070dac7298c9b
turbo-ext/src/ConstantArrayType.cpphttps://github.com/phpstan/phpstan-src/pull/7000/changes#diff-b0d6b2f8b95681b17dfd30ce9b49ffc51257ca5544e579fd6a41a2db178c9260
View file https://github.com/phpstan/phpstan-src/blob/c766c75bd428a41a9a6f123d8ed58a361a64fb44/turbo-ext/src/ConstantArrayType.cpp
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/phpstan/phpstan-src/pull/7000/{{ revealButtonHref }}
https://github.com/phpstan/phpstan-src/pull/7000/changes#diff-b0d6b2f8b95681b17dfd30ce9b49ffc51257ca5544e579fd6a41a2db178c9260
https://github.com/phpstan/phpstan-src/pull/7000/changes#diff-b0d6b2f8b95681b17dfd30ce9b49ffc51257ca5544e579fd6a41a2db178c9260
https://github.com/phpstan/phpstan-src/pull/7000/changes#diff-b0d6b2f8b95681b17dfd30ce9b49ffc51257ca5544e579fd6a41a2db178c9260
https://github.com/phpstan/phpstan-src/pull/7000/changes#diff-b0d6b2f8b95681b17dfd30ce9b49ffc51257ca5544e579fd6a41a2db178c9260
https://github.com/phpstan/phpstan-src/pull/7000/changes#diff-b0d6b2f8b95681b17dfd30ce9b49ffc51257ca5544e579fd6a41a2db178c9260
https://github.com/phpstan/phpstan-src/pull/7000/changes#diff-b0d6b2f8b95681b17dfd30ce9b49ffc51257ca5544e579fd6a41a2db178c9260
https://github.com/phpstan/phpstan-src/pull/7000/changes#diff-b0d6b2f8b95681b17dfd30ce9b49ffc51257ca5544e579fd6a41a2db178c9260
https://github.com/phpstan/phpstan-src/pull/7000/changes#diff-b0d6b2f8b95681b17dfd30ce9b49ffc51257ca5544e579fd6a41a2db178c9260
Please reload this pagehttps://github.com/phpstan/phpstan-src/pull/7000/changes
Please reload this pagehttps://github.com/phpstan/phpstan-src/pull/7000/changes
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.