mirror of
https://github.com/rectorphp/rector.git
synced 2025-01-19 14:27:14 +01:00
Updated Rector to commit bc544cf6f72f9296403ae906a3be83093ba08076
bc544cf6f7
[TypeDeclaration] Skip has child return different type on ReturnNeverTypeRector (#5343)
This commit is contained in:
parent
5fbad6d865
commit
ba2d636bcd
@ -9,7 +9,10 @@ use PHPStan\Analyser\Scope;
|
||||
use PHPStan\Reflection\ClassReflection;
|
||||
use PHPStan\Reflection\FunctionVariantWithPhpDocs;
|
||||
use PHPStan\Reflection\MethodReflection;
|
||||
use PHPStan\Reflection\ParametersAcceptorSelector;
|
||||
use PHPStan\Reflection\Php\PhpMethodReflection;
|
||||
use PHPStan\Type\MixedType;
|
||||
use PHPStan\Type\Type;
|
||||
use Rector\Core\FileSystem\FilePathHelper;
|
||||
use Rector\Core\NodeAnalyzer\MagicClassMethodAnalyzer;
|
||||
use Rector\Core\Reflection\ReflectionResolver;
|
||||
@ -87,7 +90,26 @@ final class ClassMethodReturnTypeOverrideGuard
|
||||
return \true;
|
||||
}
|
||||
$returnType = $this->returnTypeInferer->inferFunctionLike($classMethod);
|
||||
return !$returnType->isVoid()->yes();
|
||||
return $this->hasChildrenDifferentTypeClassMethod($classMethod, $childrenClassReflections, $returnType);
|
||||
}
|
||||
/**
|
||||
* @param ClassReflection[] $childrenClassReflections
|
||||
*/
|
||||
private function hasChildrenDifferentTypeClassMethod(ClassMethod $classMethod, array $childrenClassReflections, Type $returnType) : bool
|
||||
{
|
||||
$methodName = $classMethod->name->toString();
|
||||
foreach ($childrenClassReflections as $childClassReflection) {
|
||||
$methodReflection = $childClassReflection->getNativeMethod($methodName);
|
||||
if (!$methodReflection instanceof PhpMethodReflection) {
|
||||
continue;
|
||||
}
|
||||
$parametersAcceptor = ParametersAcceptorSelector::combineAcceptors($methodReflection->getVariants());
|
||||
$childReturnType = $parametersAcceptor->getNativeReturnType();
|
||||
if (!$returnType->isSuperTypeOf($childReturnType)->yes()) {
|
||||
return \true;
|
||||
}
|
||||
}
|
||||
return \false;
|
||||
}
|
||||
private function isReturnTypeChangeAllowed(ClassMethod $classMethod, Scope $scope) : bool
|
||||
{
|
||||
|
@ -19,12 +19,12 @@ final class VersionResolver
|
||||
* @api
|
||||
* @var string
|
||||
*/
|
||||
public const PACKAGE_VERSION = '6a63c6376124c9604097d85aa4cc77c190bdacd2';
|
||||
public const PACKAGE_VERSION = 'bc544cf6f72f9296403ae906a3be83093ba08076';
|
||||
/**
|
||||
* @api
|
||||
* @var string
|
||||
*/
|
||||
public const RELEASE_DATE = '2023-12-08 16:09:33';
|
||||
public const RELEASE_DATE = '2023-12-09 21:29:50';
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
|
Loading…
x
Reference in New Issue
Block a user