Skip to content

RectorPHP breaks with PHPStan 2.1.34 #9604

@michaljusiega

Description

@michaljusiega

Bug Report

Subject Details
Rector version 2.3.1
PHPStan version 2.1.34
PHP 8.5.2

Hello!

Today (2026-01-19) was released PHPStan version 2.1.34 (see https://github.com/phpstan/phpstan/releases/tag/2.1.34)
But it's breaks a comptability with rector throws a weird issue (and also throws deprecations).

Minimal PHP Code Causing Issue

Just add to composer.json a two components:

{
        "phpstan/phpstan": "2.1.33",
        "rector/rector": "2.3.1"
 }

and run dry-run on rector process

root@0e1d192c3a98:/var/www/smarthome# php -dxdebug.mode=off /var/www/smarthome/vendor/bin/rector process --dry-run --config=/var/www/smarthome/rector.php /var/www/smarthome/src /var/www/smarthome/tests

Warning: Undefined array key 0 in /var/www/smarthome/vendor/rector/rector/src/DependencyInjection/PHPStan/PHPStanContainerMemento.php on line 35

Deprecated: Using null as an array offset is deprecated, use an empty string instead in /var/www/smarthome/vendor/rector/rector/src/DependencyInjection/PHPStan/PHPStanContainerMemento.php on line 35

Warning: Undefined array key 0 in /var/www/smarthome/vendor/rector/rector/src/DependencyInjection/PHPStan/PHPStanContainerMemento.php on line 35

Deprecated: Using null as an array offset is deprecated, use an empty string instead in /var/www/smarthome/vendor/rector/rector/src/DependencyInjection/PHPStan/PHPStanContainerMemento.php on line 35


  16/821 [░░░░░░░░░░░░░░░░░░░░░░░░░░░░]   1%Fatal error: Uncaught Error: Typed property RectorPrefix202601\Symplify\EasyParallel\ValueObject\ParallelProcess::$encoder must not be accessed before initialization in /var/www/smarthome/vendor/rector/rector/vendor/symplify/easy-parallel/src/ValueObject/ParallelProcess.php:108
Stack trace:
#0 /var/www/smarthome/vendor/rector/rector/vendor/symplify/easy-parallel/src/ValueObject/ProcessPool.php(48): RectorPrefix202601\Symplify\EasyParallel\ValueObject\ParallelProcess->quit()
#1 /var/www/smarthome/vendor/rector/rector/vendor/symplify/easy-parallel/src/ValueObject/ProcessPool.php(58): RectorPrefix202601\Symplify\EasyParallel\ValueObject\ProcessPool->quitProcess('qjmavxs8e8')
#2 /var/www/smarthome/vendor/rector/rector/src/Parallel/Application/ParallelFileProcessor.php(146): RectorPrefix202601\Symplify\EasyParallel\ValueObject\ProcessPool->quitAll()
#3 /var/www/smarthome/vendor/rector/rector/vendor/symplify/easy-parallel/src/ValueObject/ParallelProcess.php(118): Rector\Parallel\Application\ParallelFileProcessor->{closure:{closure:Rector\Parallel\Application\ParallelFileProcessor::process():115}:122}(Array)
#4 /var/www/smarthome/vendor/rector/rector/vendor/evenement/evenement/src/EventEmitterTrait.php(111): RectorPrefix202601\Symplify\EasyParallel\ValueObject\ParallelProcess->{closure:RectorPrefix202601\Symplify\EasyParallel\ValueObject\ParallelProcess::bindConnection():112}(Array)
#5 /var/www/smarthome/vendor/rector/rector/vendor/clue/ndjson-react/src/Decoder.php(117): RectorPrefix202601\Evenement\EventEmitter->emit('data', Array)
#6 /var/www/smarthome/vendor/rector/rector/vendor/evenement/evenement/src/EventEmitterTrait.php(111): RectorPrefix202601\Clue\React\NDJson\Decoder->handleData(Array)
#7 /var/www/smarthome/vendor/rector/rector/vendor/react/stream/src/Util.php(62): RectorPrefix202601\Evenement\EventEmitter->emit('data', Array)
#8 /var/www/smarthome/vendor/rector/rector/vendor/evenement/evenement/src/EventEmitterTrait.php(111): RectorPrefix202601\React\Stream\Util::{closure:RectorPrefix202601\React\Stream\Util::forwardEvents():61}('{"action":"resu...')
#9 /var/www/smarthome/vendor/rector/rector/vendor/react/stream/src/DuplexResourceStream.php(168): RectorPrefix202601\Evenement\EventEmitter->emit('data', Array)
#10 /var/www/smarthome/vendor/rector/rector/vendor/react/event-loop/src/StreamSelectLoop.php(201): RectorPrefix202601\React\Stream\DuplexResourceStream->handleData(Resource id #3465)
#11 /var/www/smarthome/vendor/rector/rector/vendor/react/event-loop/src/StreamSelectLoop.php(173): RectorPrefix202601\React\EventLoop\StreamSelectLoop->waitForStreamActivity(2776)
#12 /var/www/smarthome/vendor/rector/rector/src/Parallel/Application/ParallelFileProcessor.php(185): RectorPrefix202601\React\EventLoop\StreamSelectLoop->run()
#13 /var/www/smarthome/vendor/rector/rector/src/Application/ApplicationFileProcessor.php(234): Rector\Parallel\Application\ParallelFileProcessor->process(Object(RectorPrefix202601\Symplify\EasyParallel\ValueObject\Schedule), '/var/www/smarth...', Object(Closure), Object(RectorPrefix202601\Symfony\Component\Console\Input\ArgvInput))
#14 /var/www/smarthome/vendor/rector/rector/src/Application/ApplicationFileProcessor.php(126): Rector\Application\ApplicationFileProcessor->runParallel(Array, Object(RectorPrefix202601\Symfony\Component\Console\Input\ArgvInput), Object(Closure))
#15 /var/www/smarthome/vendor/rector/rector/src/Console/Command/ProcessCommand.php(182): Rector\Application\ApplicationFileProcessor->run(Object(Rector\ValueObject\Configuration), Object(RectorPrefix202601\Symfony\Component\Console\Input\ArgvInput))
#16 /var/www/smarthome/vendor/rector/rector/vendor/symfony/console/Command/Command.php(289): Rector\Console\Command\ProcessCommand->execute(Object(RectorPrefix202601\Symfony\Component\Console\Input\ArgvInput), Object(RectorPrefix202601\Symfony\Component\Console\Output\ConsoleOutput))
#17 /var/www/smarthome/vendor/rector/rector/vendor/symfony/console/Application.php(899): RectorPrefix202601\Symfony\Component\Console\Command\Command->run(Object(RectorPrefix202601\Symfony\Component\Console\Input\ArgvInput), Object(RectorPrefix202601\Symfony\Component\Console\Output\ConsoleOutput))
#18 /var/www/smarthome/vendor/rector/rector/vendor/symfony/console/Application.php(279): RectorPrefix202601\Symfony\Component\Console\Application->doRunCommand(Object(Rector\Console\Command\ProcessCommand), Object(RectorPrefix202601\Symfony\Component\Console\Input\ArgvInput), Object(RectorPrefix202601\Symfony\Component\Console\Output\ConsoleOutput))
#19 /var/www/smarthome/vendor/rector/rector/src/Console/ConsoleApplication.php(60): RectorPrefix202601\Symfony\Component\Console\Application->doRun(Object(RectorPrefix202601\Symfony\Component\Console\Input\ArgvInput), Object(RectorPrefix202601\Symfony\Component\Console\Output\ConsoleOutput))
#20 /var/www/smarthome/vendor/rector/rector/vendor/symfony/console/Application.php(162): Rector\Console\ConsoleApplication->doRun(Object(RectorPrefix202601\Symfony\Component\Console\Input\ArgvInput), Object(RectorPrefix202601\Symfony\Component\Console\Output\ConsoleOutput))
#21 /var/www/smarthome/vendor/rector/rector/bin/rector.php(130): RectorPrefix202601\Symfony\Component\Console\Application->run()
#22 /var/www/smarthome/vendor/rector/rector/bin/rector(5): require_once('/var/www/smarth...')
#23 /var/www/smarthome/vendor/bin/rector(119): include('/var/www/smarth...')
#24 {main}
  thrown in /var/www/smarthome/vendor/rector/rector/vendor/symplify/easy-parallel/src/ValueObject/ParallelProcess.php on line 108

Downgrading/blocks to 2.1.33 PHPStan works for me.

Expected Behaviour

Process of rector dry-run or fixer should be successfully.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions