Skip to content

[Sets] Deprecate ComposerTriggeredSet in favor of ComposerPackageConstraintInterface - #8296

Open
TomasVotruba wants to merge 2 commits into
mainfrom
deprecate-composer-triggered-set
Open

[Sets] Deprecate ComposerTriggeredSet in favor of ComposerPackageConstraintInterface#8296
TomasVotruba wants to merge 2 commits into
mainfrom
deprecate-composer-triggered-set

Conversation

@TomasVotruba

@TomasVotruba TomasVotruba commented Aug 5, 2026

Copy link
Copy Markdown
Member

ComposerPackageConstraintInterface from #7877 turned out to replace ComposerTriggeredSet outright, not just complement it, so the class is now marked deprecated.

/**
 * @deprecated Bond the rules themselves instead, by implementing the ComposerPackageConstraintInterface. A set
 * triggered on a single major version has to be repeated for every version an upgrade passes through, while a bonded
 * rule states the exact package version its target API is available from and applies from there upwards.
 *
 * @see \Rector\VersionBonding\Contract\ComposerPackageConstraintInterface
 */
final readonly class ComposerTriggeredSet implements SetInterface

The comparison table in #7877 framed the triggered set as the tool for upgrade paths — one set per version jump. In practice that is the weakness: a project going from PHPUnit 6 to 12 had to pick up six sets in order, and every rule had to be repeated in each of them to survive a direct jump. A bonded rule needs none of that:

public function provideComposerPackageConstraint(): ComposerPackageConstraint
{
    // createMock() was added in PHPUnit 5.4, so this applies to 5.4 and everything after
    return new ComposerPackageConstraint('phpunit/phpunit', '>=5.4');
}

It is also more precise than ^ matching allows — >=12.0.3, >=13.2, or >=8.4 <10.0 for an API that was later removed.

Both extensions have moved:

Twig is the last user, through TwigSetProvider. So the class keeps working, and the internal resolving in SetManager and SetProviderCollector is ignored in phpstan.neon rather than rewritten, until that one moves over too.

The rest of the set object machinery goes with it

A set described as an object only ever existed so it could be matched against the installed packages. Once the rules carry that information themselves, a plain set file is enough, so these are deprecated too:

  • SetInterface and Set
  • SetProviderInterface, SetManager, SetProviderCollector
  • CoreSetProvider and PHPSetProvider

Every note links back to this PR, so anyone hitting the deprecation in an IDE can read the reasoning here.

Nothing is removed and nothing changes at runtime — the sets are still served from these classes, so their internal use is ignored in phpstan.neon rather than rewritten.

Green: 5373 tests, PHPStan and ECS clean.

…traintInterface

A set triggered on a single major version has to be repeated for every version an upgrade passes through. A rule bonded with ComposerPackageConstraintInterface, added in #7877, states the exact package version its target API is available from and applies from there upwards, so one set covers every upgrade path.

rectorphp/rector-symfony#1010 and rectorphp/rector-phpunit#758 moved both extensions over, leaving Twig as the only remaining user. The internal resolving of the class is kept working and ignored in phpstan.neon until that lands too.
@TomasVotruba
TomasVotruba force-pushed the deprecate-composer-triggered-set branch from 8213aca to 1b70019 Compare August 5, 2026 11:56
SetInterface, Set, SetProviderInterface, SetManager, SetProviderCollector and the two core providers exist to describe a set as an object, so it can be matched against the installed packages. A rule bonded with ComposerPackageConstraintInterface needs none of that: it states the package version its target API is available from, and a plain set file registers it.

Every note links to this PR, so the reasoning is one click away.

Internal resolving keeps working and is ignored in phpstan.neon, as the sets are still served from here.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant