-
-
Notifications
You must be signed in to change notification settings - Fork 740
Closed
rectorphp/rector-src
#4530Labels
Description
Bug Report
| Subject | Details |
|---|---|
| Rector version | last dev-main |
| Installed as | composer dependency |
Minimal PHP Code Causing Issue
See https://getrector.com/demo/d265976d-715f-457e-a632-c07f64481eed
<?php
final class DemoFile
{
public function run( $arg )
{
$arg = preg_replace_callback(
'/([a-z])?([a-z])([a-z]*)/',
static function ( $match ) {
$replace = '';
if ( !empty( $match[1] ) ) {
$replace = 'abc';
}
$replace .= $match[2];
if ( !empty( $match[3] ) ) {
$replace .= 'abc';
}
return $replace;
},
$arg
);
return $arg;
}
}Responsible rules
PreparedValueToEarlyReturnRector
Expected Behavior
There are some options to change this to early return, however I'm not sure if this is wanted here (since it would mean you'd have to concat in the return), so I suggested to not change the code at all (instead of creating invalid code as it does now)
Reactions are currently unavailable