-
-
Notifications
You must be signed in to change notification settings - Fork 737
Closed
rectorphp/rector-src
#6881Labels
Description
Bug Report
Rector flags many issues and proposes behavior-breaking changes.
| Subject | Details |
|---|---|
| Rector version | last dev-main |
| Installed as | composer dependency |
Minimal PHP Code Causing Issue
See https://getrector.com/demo/8db2fa14-878e-4509-abc4-f701957a0692
<?php
class RectorTest
{
/**
* @var stdClass[]
*/
private array $secondaries = [];
/**
* @return stdClass[]
*/
public function test(): iterable
{
$primary = new stdClass();
$this->secondaries = [
new stdClass(),
new stdClass(),
];
return $this->assemble($primary);
}
/**
* @return stdClass[]
*/
private function assemble(
stdClass $primary,
): iterable {
$assembled = [
$primary,
];
foreach ($this->secondaries as $secondary) {
$assembled[] = $secondary;
}
return $assembled;
}
}Rector config
<?php
use Rector\Config\RectorConfig;
use Rector\TypeDeclaration\Rector\Property\TypedPropertyFromAssignsRector;
return RectorConfig::configure()
->withPreparedSets(
deadCode: true,
codeQuality: true,
privatization: true,
);Responsible rules
-
ForeachItemsAssignToEmptyArrayToAssignRector -
SimplifyUselessVariableRector -
RemoveDoubleAssignRector -
RemoveUnusedVariableAssignRector -
RemoveUnusedPrivateMethodParameterRector -
RemoveUnusedPrivateMethodRector -
PrivatizeLocalGetterToPropertyRector
Expected Behavior
No issue flagged, and no change to processed code.