Skip to content

WrapEncapsedVariableInCurlyBracesRector does not recognize concatenated variables #9274

@Art4

Description

@Art4

Bug Report

Subject Details
Rector version 2.1.2

Multiple concatenated variables (like "$prefix$main$suffix") are not recognized by the WrapEncapsedVariableInCurlyBracesRector rule.

Minimal PHP Code Causing Issue

The following code:

$prefix = '';
$main = '';
$suffix = '';
      
return "$prefix$main$suffix";

is changed to

$prefix = '';
$main = '';
$suffix = '';
      
return "{$prefix}$main{$suffix}";

https://getrector.com/demo/1768739e-e051-4725-98e7-7282ed049b1e

Expected Behaviour

$prefix = '';
$main = '';
$suffix = '';

- return "{$prefix}$main{$suffix}";
+ return "{$prefix}{$main}{$suffix}";

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