Skip to content

Return value must be of type ?PhpParser\Node\Expr\Variable, PhpParser\Node\Expr\AssignOp\Concat returned" #8130

@smortexa

Description

@smortexa

Reproduction:

Try to refactor:

if ( ! function_exists('formatSizeUnits')) {
    function formatSizeUnits($bytes): string
    {
        if ($bytes >= 1_073_741_824) {
            $bytes = number_format($bytes / 1_073_741_824, 1).' GB';
        } elseif ($bytes >= 1_048_576) {
            $bytes = number_format($bytes / 1_048_576, 1).' MB';
        } elseif ($bytes >= 1024) {
            $bytes = number_format($bytes / 1024, 1).' KB';
        } elseif ($bytes > 1) {
            $bytes .= ' bytes';
        } elseif (1 === $bytes) {
            $bytes .= ' byte';
        } else {
            $bytes = '0 bytes';
        }

        return $bytes;
    }
}
[ERROR] Could not process "/var/www/app/modules/CMS/src/Helpers/functions.php" file, due to:                 
         "System error:                                                                                                 
         "Rector\TypeDeclaration\Rector\ClassMethod\StrictStringParamConcatRector::resolveVariableConcattedFromParam(): 
         Return value must be of type ?PhpParser\Node\Expr\Variable, PhpParser\Node\Expr\AssignOp\Concat returned"

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