-
-
Notifications
You must be signed in to change notification settings - Fork 725
Closed
rectorphp/rector-src
#6912Labels
Description
Bug Report
Subject | Details |
---|---|
Rector version | 2.0.16 |
When I enable dead code elimination and rector removes a parameter then it copies the type of the removed parameter to the next argument. My rector configuration is:
<?php
declare(strict_types=1);
use Rector\Config\RectorConfig;
return RectorConfig::configure()
->withPaths([__DIR__ . '/public', __DIR__ . '/src'])
->withPhpSets(php84: true)
->withPreparedSets(
deadCode: true,
codeQuality: true,
codingStyle: true,
typeDeclarations: true,
privatization: true
);
Minimal PHP Code Causing Issue
https://getrector.com/demo/0b532578-8ad1-4597-bc58-1cc18edbf481
<?php
class test {
private static function just_a_test(string $foo, array $bar, $used_parameter): void
{
\external::whatever($foo, $used_parameter);
}
public static function trigger(): void
{
self::just_a_test('hello', [], 'test');
}
}
After running rector, I get this completely wrong output:
<?php
class test {
private static function just_a_test(string $foo, array $used_parameter): void
{
\external::whatever($foo, $used_parameter);
}
public static function trigger(): void
{
self::just_a_test('hello', [], 'test');
}
}
Expected Behaviour
The $used_parameter
should not have the type array
(string would be acceptable). And in a perfect world, the call to it should have the second parameter removed automatically. The output should therefore be:
<?php
class test {
private static function just_a_test(string $foo, $used_parameter): void
{
\external::whatever($foo, $used_parameter);
}
public static function trigger(): void
{
self::just_a_test('hello', 'test');
}
}
or
<?php
class test {
private static function just_a_test(string $foo, string $used_parameter): void
{
\external::whatever($foo, $used_parameter);
}
public static function trigger(): void
{
self::just_a_test('hello', 'test');
}
}