Skip to content

Commit

Permalink
Updated Rector to commit d17d3e814eada2fa3ada3601034407df01d84568
Browse files Browse the repository at this point in the history
rectorphp/rector-src@d17d3e8 [TypeDeclaration] Better approach for native type check on ReturnStrictTypeAnalyzer (#6343)
  • Loading branch information
TomasVotruba committed Oct 1, 2024
1 parent cdbdb1b commit b555bd2
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 11 deletions.
14 changes: 5 additions & 9 deletions rules/TypeDeclaration/TypeAnalyzer/ReturnStrictTypeAnalyzer.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
use PhpParser\Node\Stmt\Return_;
use PHPStan\Analyser\Scope;
use PHPStan\Reflection\ClassReflection;
use PHPStan\Reflection\FunctionVariantWithPhpDocs;
use PHPStan\Reflection\Native\NativeFunctionReflection;
use PHPStan\Reflection\ParametersAcceptorWithPhpDocs;
use PHPStan\Type\MixedType;
use PHPStan\Type\StaticType;
use PHPStan\Type\Type;
Expand Down Expand Up @@ -116,18 +117,13 @@ public function resolveMethodCallReturnType($call) : ?Type
return null;
}
$parametersAcceptorWithPhpDocs = ParametersAcceptorSelectorVariantsWrapper::select($methodReflection, $call, $scope);
if ($parametersAcceptorWithPhpDocs instanceof FunctionVariantWithPhpDocs) {
if ($methodReflection instanceof NativeFunctionReflection) {
$returnType = $parametersAcceptorWithPhpDocs->getReturnType();
} elseif ($parametersAcceptorWithPhpDocs instanceof ParametersAcceptorWithPhpDocs) {
// native return type is needed, as docblock can be false
$returnType = $parametersAcceptorWithPhpDocs->getNativeReturnType();
} else {
$returnType = $parametersAcceptorWithPhpDocs->getReturnType();
// around PHPStan 1.12.4+ handling
if (\method_exists($parametersAcceptorWithPhpDocs, 'getNativeReturnType')) {
$nativeReturnType = $parametersAcceptorWithPhpDocs->getNativeReturnType();
if ($nativeReturnType instanceof MixedType && !$nativeReturnType->isExplicitMixed()) {
$returnType = $nativeReturnType;
}
}
}
if ($returnType instanceof MixedType) {
if ($returnType->isExplicitMixed()) {
Expand Down
4 changes: 2 additions & 2 deletions src/Application/VersionResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ final class VersionResolver
* @api
* @var string
*/
public const PACKAGE_VERSION = '697b37b340c3b4c73ad6f8e4cea26b7bf60ddf62';
public const PACKAGE_VERSION = 'd17d3e814eada2fa3ada3601034407df01d84568';
/**
* @api
* @var string
*/
public const RELEASE_DATE = '2024-10-01 18:10:51';
public const RELEASE_DATE = '2024-10-01 20:02:39';
/**
* @var int
*/
Expand Down

0 comments on commit b555bd2

Please sign in to comment.