[Composer] Target lowest version for any distributed package type, only 'project' is an application - #8363
Merged
Merged
Conversation
TomasVotruba
marked this pull request as ready for review
August 22, 2026 17:53
TomasVotruba
force-pushed
the
extend-composer-library-types
branch
from
August 22, 2026 17:55
0e47b0d to
2aa8814
Compare
samsonasik
reviewed
Aug 22, 2026
| $type = $projectComposerJson['type'] ?? null; | ||
|
|
||
| return ($projectComposerJson['type'] ?? null) === 'library'; | ||
| return is_string($type) && $type !== 'project'; |
Member
There was a problem hiding this comment.
I think additional requirement check is needed, when the package has php version range, eg: has
"php": "^8.1 || ^8.2"Then should follow lowest.
That will usually verify that multiple major version of requirment test eg: phpunit 10 or 11 n CI is needed.
Member
Author
There was a problem hiding this comment.
This is already handled by PHP version and the min php version interface. Different area.
TomasVotruba
force-pushed
the
extend-composer-library-types
branch
from
August 22, 2026 19:35
6374cd4 to
511f269
Compare
…iven by a test-provided composer.json Treat any non-'project' composer type as a distributed package, resolving version-bound rules to the lowest declared version. Resolve those versions via the container-bound InstalledPackageResolver, so a test-provided composer.json (AbstractRectorTestCase::provideComposerJsonFilePath) drives the version instead of the project root.
TomasVotruba
force-pushed
the
extend-composer-library-types
branch
from
August 22, 2026 19:43
511f269 to
19c473a
Compare
TomasVotruba
enabled auto-merge (squash)
August 22, 2026 19:43
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.
What
Two related changes to how composer-package versions drive version-bound rules.
1. Lowest declared version for distributed packages
InstalledPackageResolvertreated only"type": "library"as a distributed package. Now any non-projecttype (library,symfony-bundle,rector-extension, ...) targets the lowest declared version, while a missing type or an explicit"project"stays an application on the installed version.2. Honor a test-provided composer.json for composer-bound rules
RectorConfig::ruleWithConfigurationComposerVersionBound()resolved the version through a privatenew InstalledPackageResolver()reading the project root, ignoring the resolver a test configures viaAbstractRectorTestCase::provideComposerJsonFilePath(). It now resolves through the container-bound singleton, so a test-specificcomposer.jsondrives the version:Without this, an extension package (e.g.
rector-doctrine,"type": "rector-extension") resolved its version-bound rules from its own rootcomposer.json— so change #1 dropped it to the lowest declared floor and deactivated newer-version rules in the extension's own test suite. With this,rector-doctrine'stests/ComposerBased/composer.json(rectorphp/rector-doctrine#513) drives the version deterministically; its rootcomposer.jsonand fixtures stay untouched.Tests
InstalledPackageResolverTest: library test is a data provider overlibrary+symfony-bundle; newproject_composer_jsonfixture proves an explicit"project"keeps the installed version.main:ComposerBasedTest3/3 green, fixtures unchanged.