You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
<?phptrait StreamDecoratorTrait
{
protectedfunctioncreateStream()
{
// ...
}
}
class MultipartStream
{
use StreamDecoratorTrait;
protectedfunctioncreateStream(array$elements)
{
// ...
}
}
Responsible rules
DowngradeParameterTypeWideningRector
Expected Behavior
The rule is currently doing this:
class MultipartStream
{
use StreamDecoratorTrait;
- protected function createStream(array $elements)+ protected function createStream($elements)
{
// ...
}
}
Instead, it should do nothing:
class MultipartStream
{
use StreamDecoratorTrait;
protected function createStream(array $elements)
{
// ...
}
}
DowngradeParameterTypeWideningRector should not remove the type array of the param $elements, because the different method comes from a trait. But only parent classes and interfaces should be considered, not traits.
Debugging DowngradeParameterTypeWideningRector, I found out this:
// Remove the types in:// - all ancestors + their descendant classes// - all implemented interfaces + their implementing classes$parameterTypesByParentClassLikes = $this->resolveParameterTypesByClassLike(
$classReflection,
$methodName,
$position
);
var_dump($parameterTypesByParentClassLikes);
Bug Report
Minimal PHP Code Causing Issue
See https://getrector.org/demo/1b8ee6a0-7d50-4fae-8e15-f19d19591fc5
Responsible rules
DowngradeParameterTypeWideningRector
Expected Behavior
The rule is currently doing this:
Instead, it should do nothing:
DowngradeParameterTypeWideningRector
should not remove the typearray
of the param$elements
, because the different method comes from a trait. But only parent classes and interfaces should be considered, not traits.Debugging
DowngradeParameterTypeWideningRector
, I found out this:Prints:
Hence,
StreamDecoratorTrait
is also being picked byresolveParameterTypesByClassLike
, that's the problem.The text was updated successfully, but these errors were encountered: