From 6678ca05d45f5a63a9523239ef992b655aad20dd Mon Sep 17 00:00:00 2001 From: Tomas Votruba Date: Fri, 5 Apr 2024 18:04:27 +0000 Subject: [PATCH] Updated Rector to commit 4a77565302216f6fde71232600cd175422a00965 https://github.com/rectorphp/rector-src/commit/4a77565302216f6fde71232600cd175422a00965 ExplicitReturnNullRector should skip never return (#5802) --- .../Rector/ClassMethod/ExplicitReturnNullRector.php | 11 +++++++++-- src/Application/VersionResolver.php | 4 ++-- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/rules/CodeQuality/Rector/ClassMethod/ExplicitReturnNullRector.php b/rules/CodeQuality/Rector/ClassMethod/ExplicitReturnNullRector.php index 6cf5d3d168c..1a5db41f471 100644 --- a/rules/CodeQuality/Rector/ClassMethod/ExplicitReturnNullRector.php +++ b/rules/CodeQuality/Rector/ClassMethod/ExplicitReturnNullRector.php @@ -20,6 +20,7 @@ use Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfoFactory; use Rector\BetterPhpDocParser\PhpDocManipulator\PhpDocTypeChanger; use Rector\NodeTypeResolver\PHPStan\Type\TypeFactory; use Rector\Rector\AbstractRector; +use Rector\TypeDeclaration\NodeAnalyzer\NeverFuncCallAnalyzer; use Rector\TypeDeclaration\TypeInferer\ReturnTypeInferer; use Rector\TypeDeclaration\TypeInferer\SilentVoidResolver; use Rector\ValueObject\MethodName; @@ -50,17 +51,23 @@ final class ExplicitReturnNullRector extends AbstractRector * @var \Rector\BetterPhpDocParser\PhpDocManipulator\PhpDocTypeChanger */ private $phpDocTypeChanger; + /** + * @readonly + * @var \Rector\TypeDeclaration\NodeAnalyzer\NeverFuncCallAnalyzer + */ + private $neverFuncCallAnalyzer; /** * @readonly * @var \Rector\TypeDeclaration\TypeInferer\ReturnTypeInferer */ private $returnTypeInferer; - public function __construct(SilentVoidResolver $silentVoidResolver, PhpDocInfoFactory $phpDocInfoFactory, TypeFactory $typeFactory, PhpDocTypeChanger $phpDocTypeChanger, ReturnTypeInferer $returnTypeInferer) + public function __construct(SilentVoidResolver $silentVoidResolver, PhpDocInfoFactory $phpDocInfoFactory, TypeFactory $typeFactory, PhpDocTypeChanger $phpDocTypeChanger, NeverFuncCallAnalyzer $neverFuncCallAnalyzer, ReturnTypeInferer $returnTypeInferer) { $this->silentVoidResolver = $silentVoidResolver; $this->phpDocInfoFactory = $phpDocInfoFactory; $this->typeFactory = $typeFactory; $this->phpDocTypeChanger = $phpDocTypeChanger; + $this->neverFuncCallAnalyzer = $neverFuncCallAnalyzer; $this->returnTypeInferer = $returnTypeInferer; } public function getRuleDefinition() : RuleDefinition @@ -132,7 +139,7 @@ CODE_SAMPLE } return null; }); - if (!$this->silentVoidResolver->hasSilentVoid($node)) { + if (!$this->silentVoidResolver->hasSilentVoid($node) || $this->neverFuncCallAnalyzer->hasNeverFuncCall($node)) { if ($hasChanged) { $this->transformDocUnionVoidToUnionNull($node); return $node; diff --git a/src/Application/VersionResolver.php b/src/Application/VersionResolver.php index b4ef53b8979..96ec8fc30e7 100644 --- a/src/Application/VersionResolver.php +++ b/src/Application/VersionResolver.php @@ -19,12 +19,12 @@ final class VersionResolver * @api * @var string */ - public const PACKAGE_VERSION = '1.0.4'; + public const PACKAGE_VERSION = '4a77565302216f6fde71232600cd175422a00965'; /** * @api * @var string */ - public const RELEASE_DATE = '2024-04-04 20:57:17'; + public const RELEASE_DATE = '2024-04-05 20:02:11'; /** * @var int */