mirror of
https://github.com/rectorphp/rector.git
synced 2025-01-18 22:08:00 +01:00
widening - skip if no method is present (#5898)
This commit is contained in:
parent
33daf1de2e
commit
1bdc6e588a
@ -0,0 +1,18 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Rector\Tests\DowngradePhp72\Rector\ClassMethod\DowngradeParameterTypeWideningRector\Fixture;
|
||||||
|
|
||||||
|
use PhpParser\Node\Param;
|
||||||
|
use PHPStan\Type\Type;
|
||||||
|
use Rector\TypeDeclaration\Contract\TypeInferer\ParamTypeInfererInterface;
|
||||||
|
|
||||||
|
final class SkipRequiredRemoval implements ParamTypeInfererInterface
|
||||||
|
{
|
||||||
|
public function autowireSomething(\PHPStan\Type\Type $input)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public function inferParam(Param $param): Type
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
@ -38,9 +38,6 @@ final class NativeTypeClassTreeResolver
|
|||||||
int $position
|
int $position
|
||||||
): Type {
|
): Type {
|
||||||
$nativeReflectionClass = $classReflection->getNativeReflection();
|
$nativeReflectionClass = $classReflection->getNativeReflection();
|
||||||
if (! $nativeReflectionClass->hasMethod($methodName)) {
|
|
||||||
return new MixedType();
|
|
||||||
}
|
|
||||||
|
|
||||||
$reflectionMethod = $nativeReflectionClass->getMethod($methodName);
|
$reflectionMethod = $nativeReflectionClass->getMethod($methodName);
|
||||||
$parameterReflection = $reflectionMethod->getParameters()[$position] ?? null;
|
$parameterReflection = $reflectionMethod->getParameters()[$position] ?? null;
|
||||||
|
@ -236,6 +236,10 @@ CODE_SAMPLE
|
|||||||
$parameterTypesByParentClassLikes = [];
|
$parameterTypesByParentClassLikes = [];
|
||||||
|
|
||||||
foreach ($classReflection->getAncestors() as $ancestorClassReflection) {
|
foreach ($classReflection->getAncestors() as $ancestorClassReflection) {
|
||||||
|
if (! $ancestorClassReflection->hasMethod($methodName)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
$parameterType = $this->nativeTypeClassTreeResolver->resolveParameterReflectionType(
|
$parameterType = $this->nativeTypeClassTreeResolver->resolveParameterReflectionType(
|
||||||
$ancestorClassReflection,
|
$ancestorClassReflection,
|
||||||
$methodName,
|
$methodName,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user