Skip to content

Crash: System error: "Unsupported operand types: string & int" #9559

@fcharrier

Description

@fcharrier

Hello

I get this error when in run rector on my code:

 [ERROR] Could not process "/srv/app/src/Command/Alarms/AckAlarmCommand.php" file, due to:                              
         "System error: "Unsupported operand types: string & int"                                                       
                                                                                                                        
         Stack trace:                                                                                                   
         #0                                                                                                             
         vendor/rector/rector/vendor/rector/rector-symfony/rules/Symfony73/NodeAnalyzer/CommandOptionsResolver.php(44): 
         Rector\Symfony\Symfony73\NodeAnalyzer\CommandOptionsResolver->isImplicitBoolean()                              
         #1                                                                                                             
         vendor/rector/rector/vendor/rector/rector-symfony/rules/Symfony73/Rector/Class_/InvokableCommandInputAttributeR
         ector.php(174): Rector\Symfony\Symfony73\NodeAnalyzer\CommandOptionsResolver->resolve()                        
         #2 vendor/rector/rector/src/Rector/AbstractRector.php(115):                                                    
         Rector\Symfony\Symfony73\Rector\Class_\InvokableCommandInputAttributeRector->refactor()                        
         #3 vendor/rector/rector/src/PhpParser/NodeTraverser/AbstractImmutableNodeTraverser.php(160):                   
         Rector\Rector\AbstractRector->enterNode()                                                                      
         #4 vendor/rector/rector/src/PhpParser/NodeTraverser/AbstractImmutableNodeTraverser.php(78):                    
         Rector\PhpParser\NodeTraverser\AbstractImmutableNodeTraverser->traverseArray()                                 
         #5 vendor/rector/rector/src/PhpParser/NodeTraverser/AbstractImmutableNodeTraverser.php(187):                   
         Rector\PhpParser\NodeTraverser\AbstractImmutableNodeTraverser->traverseNode()                                  
         #6 vendor/rector/rector/src/PhpParser/NodeTraverser/AbstractImmutableNodeTraverser.php(60):                    
         Rector\PhpParser\NodeTraverser\AbstractImmutableNodeTraverser->traverseArray()                                 
         #7 vendor/rector/rector/src/PhpParser/NodeTraverser/RectorNodeTraverser.php(51):                               
         Rector\PhpParser\NodeTraverser\AbstractImmutableNodeTraverser->traverse()                                      
         #8 vendor/rector/rector/src/Application/FileProcessor.php(95):                                                 
         Rector\PhpParser\NodeTraverser\RectorNodeTraverser->traverse()                                                 
         #9 vendor/rector/rector/src/Application/ApplicationFileProcessor.php(178):                                     
         Rector\Application\FileProcessor->processFile()                                                                
         #10 vendor/rector/rector/src/Application/ApplicationFileProcessor.php(152):                                    
         Rector\Application\ApplicationFileProcessor->processFile()                                                     
         #11 vendor/rector/rector/src/Application/ApplicationFileProcessor.php(128):                                    
         Rector\Application\ApplicationFileProcessor->processFiles()                                                    
         #12 vendor/rector/rector/src/Console/Command/ProcessCommand.php(182):                                          
         Rector\Application\ApplicationFileProcessor->run()                                                             
         #13 vendor/rector/rector/vendor/symfony/console/Command/Command.php(289):                                      
         Rector\Console\Command\ProcessCommand->execute()                                                               
         #14 vendor/rector/rector/vendor/symfony/console/Application.php(899):                                          
         RectorPrefix202512\Symfony\Component\Console\Command\Command->run()                                            
         #15 vendor/rector/rector/vendor/symfony/console/Application.php(279):                                          
         RectorPrefix202512\Symfony\Component\Console\Application->doRunCommand()                                       
         #16 vendor/rector/rector/src/Console/ConsoleApplication.php(60):                                               
         RectorPrefix202512\Symfony\Component\Console\Application->doRun()                                              
         #17 vendor/rector/rector/vendor/symfony/console/Application.php(162):                                          
         Rector\Console\ConsoleApplication->doRun()                                                                     
         #18 vendor/rector/rector/bin/rector.php(130): RectorPrefix202512\Symfony\Component\Console\Application->run()  
         #19 vendor/rector/rector/bin/rector(5): require_once('...')                                                    
         #20 vendor/bin/rector(119): include('...')                                                                     
         #21 {main}". On line: 84

I try to remove as much code as possible from my command, to reproduce the problem. I can reproduce it with this sample code:

<?php

namespace App\Command\Alarms;

use Symfony\Component\Console\Attribute\AsCommand;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;

#[AsCommand(
    name: 'ack:alarm',
    description: '',
)]
class AckAlarmCommand extends Command
{
    #[\Override]
    protected function configure(): void
    {
        $this
            ->addOption(
                name: 'startDate',
                mode: InputOption::VALUE_REQUIRED,
                description: 'non empty description needed to reproduce the bug',
            );
    }

    #[\Override]
    protected function execute(InputInterface $input, OutputInterface $output): int
    {
        return Command::SUCCESS;
    }
}

Surprisingly, a non empty description for the startDate option is needed to reproduce the bug !

I hope it helps (I just followed rector instructions when there is a crash)

Thanks!
Fred

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions