feat: propagate config.platform from core's composer.json#24
Open
mstrelan wants to merge 3 commits into
Open
Conversation
composer-merge-plugin does not merge the config section, only package metadata. This means config.platform.php from core's composer.json is not visible to tools like PHPStan when running via composer.local.json as the root, causing PHPStan to analyse against the running PHP version (e.g. 8.5) instead of the declared target version (e.g. 8.3 on 11.x). Hoist the core composer.json read out of the installer-paths block and propagate config.platform via Config::merge() alongside it, using the same pattern already used for installer-paths and root version pinning.
PHPStan reads platform.php directly from the file pointed to by the $COMPOSER env var (e.g. composer.local.json) in a separate process. The in-memory Config::merge() is not visible to it. Add syncPlatformToRootFile() which writes config.platform from composer.json into composer.local.json on disk whenever the two differ, so PHPStan (and any other tool that reads the root file directly) picks up the correct platform PHP version without needing a phpVersion setting in phpstan.neon.
Assert that after composer install: - config.platform.php in composer.local.json matches the value from core's composer.json - PHPStan reports the platform version for analysis rather than falling back to the runtime PHP version
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This aims to solve https://www.drupal.org/project/drupal/issues/3605599 without waiting for core.
Disclaimer - this is entirely vibe coded.
Below is the description that Claude came up with, which is an accurate summary of what I'm trying to do:
I ran some tests on
main, as well as11.xand11.4.xbut it wasn't working, so I had Claude fix it:So now if you switch branch and run
ddev composer updateit will syncconfig.platform.phpfrom core in tocomposer.local.jsonso phpstan detects it. You can see the output by adding-vvvto the phpstan command:I've also added a bats test to verify.