Removes useless variable assigns
function () {
- $a = true;
- return $a;
+ return true;
};
Configure your rector.php
:
<?php
use Rector\CodeQuality\Rector\FunctionLike\SimplifyUselessVariableRector;
use Rector\Config\RectorConfig;
return RectorConfig::configure()
->withConfiguredRule(SimplifyUselessVariableRector::class, [
'only_direct_assign' => true,
]);
function () {
$a = 'Hello, ';
- $a .= 'World!';
- return $a;
+ return $a . 'World!';
};
Configure your rector.php
:
<?php
use Rector\CodeQuality\Rector\FunctionLike\SimplifyUselessVariableRector;
use Rector\Config\RectorConfig;
return RectorConfig::configure()
->withConfiguredRule(SimplifyUselessVariableRector::class, [
'only_direct_assign' => false,
]);