Skip to content

Fix bug with composer-based command and Symfony configuration - #8280

Merged
TomasVotruba merged 2 commits into
mainfrom
composer-based-symfony
Aug 3, 2026
Merged

Fix bug with composer-based command and Symfony configuration#8280
TomasVotruba merged 2 commits into
mainfrom
composer-based-symfony

Conversation

@TomasVotruba

@TomasVotruba TomasVotruba commented Aug 3, 2026

Copy link
Copy Markdown
Member

Spotted in: #8246 (comment)


Adds symfony: true to withComposerBased() in rector.php, so rector-src is covered by the Symfony composer-bound rules.

Fix: fatal error in bin/rector composer-based

The Symfony composer-based.php set builds a UnionType via newInstanceWithoutConstructor() and only sets types, leaving $normalized uninitialized. Rendering the configuration table then crashed:

PHP Fatal error:  Uncaught Error: Typed property PHPStan\Type\UnionType::$normalized
must not be accessed before initialization in src/Console/Command/ComposerBasedCommand.php:205
 foreach ($reflectionObject->getProperties() as $reflectionProperty) {
+    // lazy-initialized property, e.g. PHPStan UnionType::$normalized
+    if (! $reflectionProperty->isInitialized($value)) {
+        continue;
+    }
+
     $printedPropertyValues[] = $this->printConfigurationValue($reflectionProperty->getValue($value));
 }

@TomasVotruba
TomasVotruba force-pushed the composer-based-symfony branch from 95b53e4 to fe2a075 Compare August 3, 2026 17:11
- add symfony: true to withComposerBased()
- fix fatal error in "composer-based" command on lazily-initialized
  typed properties (PHPStan UnionType::$normalized)
- skip ConsoleExecuteReturnIntRector, it adds a redundant (int) cast that
  RecastingRemovalRector removes again
@TomasVotruba
TomasVotruba force-pushed the composer-based-symfony branch from 85897d8 to 1d338ac Compare August 3, 2026 17:17
@TomasVotruba TomasVotruba changed the title Enable symfony composer-based set in rector.php Fix bug with composer-based command and Symfony configuration Aug 3, 2026
@TomasVotruba
TomasVotruba merged commit 16be33c into main Aug 3, 2026
64 checks passed
@TomasVotruba
TomasVotruba deleted the composer-based-symfony branch August 3, 2026 17:26
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