Skip to content

[composer-based] Report rule configuration bound to installed package version - #8247

Merged
TomasVotruba merged 3 commits into
mainfrom
composer-based-command-configurations
Jul 31, 2026
Merged

[composer-based] Report rule configuration bound to installed package version#8247
TomasVotruba merged 3 commits into
mainfrom
composer-based-command-configurations

Conversation

@TomasVotruba

Copy link
Copy Markdown
Member

Follow up to #8246. The composer-based command listed rules that declare a ComposerPackageConstraint, but not the configuration registered through ruleWithConfigurationComposerVersionBound(). That configuration is exactly the interesting part - it is what decides whether e.g. one AnnotationToAttribute pair is applied or not, and there was no way to see it.

RectorConfig::ruleWithConfigurationComposerVersionBound() now records every call as a ComposerBoundRuleConfiguration, including the ones that do not match, and the command prints a second table:

Composer package bound rule configuration
=========================================

 --------------------------------------------------- ----------------- -------------- ----------- -------- ------------------------------------------------------------------------------
  Rule                                                Package           Requires       Installed   Active   Configuration
 --------------------------------------------------- ----------------- -------------- ----------- -------- ------------------------------------------------------------------------------
  ...\Class_\AnnotationWithValueToAttributeRector     phpunit/phpunit   >=10.0         13.2.6.0    yes      AnnotationWithValueToAttribute(backupStaticProperties, PHPUnit\Framework\Attributes\BackupStaticProperties, [true, false], false)
                                                                                                            AnnotationWithValueToAttribute(excludeGlobalVariableFromBackup, PHPUnit\Framework\Attributes\ExcludeGlobalVariableFromBackup, [], false)
  Rector\Php80\Rector\Class_\AnnotationToAttributeRector   phpunit/phpunit   >=10.0 <13.0   13.2.6.0    no       AnnotationToAttribute(runClassInSeparateProcess, PHPUnit\Framework\Attributes\RunClassInSeparateProcess, [], false)
 --------------------------------------------------- ----------------- -------------- ----------- -------- ------------------------------------------------------------------------------

 ! [NOTE] 11 of 12 composer package bound items are active

That last row is the point: on PHPUnit 13 the RunClassInSeparateProcess attribute no longer exists, the pair is bound to >=10.0 <13.0, and the command shows it as inactive together with the exact pair it would have applied.

Configuration values are printed compactly - value objects as ShortClassName(prop, prop, ...), arrays as [a, b], string keys as key: value.

Output above is a real run against rector-phpunit with PHPUnitSetList::COMPOSER_BASED.

Covered by two more cases in ComposerBasedCommandTest - an active configuration and one whose package is not installed.

@TomasVotruba
TomasVotruba merged commit 34c04f5 into main Jul 31, 2026
65 checks passed
@TomasVotruba
TomasVotruba deleted the composer-based-command-configurations branch July 31, 2026 20:07
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.

2 participants