Rector v0.5.5
Config file: /my-project/rector.yml
3/3 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%
[ERROR] Could not process "Support/Localization/LocaleAccessor.php" file by "Rector\Rector\AbstractRector", due to:
"Argument 2 passed to Rector\Rector\AbstractRector::isName() must be of the type string, integer given, called
in /my-project/vendor/rector/rector/src/Rector/Argument/ArgumentRemoverRector.php on line 78".
Minimal PHP Code Causing Issue
<?php
use Illuminate\Foundation\Application;
class SomeClass
{
/** @var Application */
protected $application;
public function __construct()
{
$this->application->asd();
}
}
Expected Behaviour
I'm not sure what the configured rule is trying to accomplish:
But looking at the refactor method of ArgumentRemoverRector:
public function refactor(Node $node): ?Node
{
foreach ($this->positionsByMethodNameByClassType as $type => $positionByMethodName) {
if (! $this->isType($node, $type)) {
continue;
}
foreach ($positionByMethodName as $methodName => $positions) {
if (! $this->isName($node, $methodName)) {
continue;
}
foreach ($positions as $position => $match) {
$this->processPosition($node, $position, $match);
}
}
}
return $node;
}
we can determine the following:
$this->positionsByMethodNameByClassType = [
'Illuminate\Foundation\Application' => [1 => ['name' => 'options]]
]
// which means in foreach $this->positionsByMethodNameByClassType
$type = 'Illuminate\Foundation\Application'
$positionByMethodName = [1 => ['name' => 'options]]
// and within foreach $positionByMethodName
$methodName = 1
$positions = ['name' => 'options]
// which crashes
$this->isName($node, $methodName);
// since second parameter of isName should be string, (int)(1) given
That is - if I'm correct.
Can you check what is supposed to happen?
The internal rule causing incorrect behaviour:
See: https://github.com/rectorphp/rector/blob/master/config/set/laravel/laravel57.yaml#L23
Current Behaviour
Minimal PHP Code Causing Issue
Expected Behaviour
I'm not sure what the configured rule is trying to accomplish:
But looking at the
refactor
method ofArgumentRemoverRector
:we can determine the following:
That is - if I'm correct. Can you check what is supposed to happen?