From 06a8e6394a1621a8d1aa596d5fd3120ec16ee786 Mon Sep 17 00:00:00 2001 From: Tomas Votruba Date: Sun, 24 Dec 2023 01:21:59 +0000 Subject: [PATCH] Updated Rector to commit 012e8bb2ed77516c792e3fb9c777066c3776abcc https://github.com/rectorphp/rector-src/commit/012e8bb2ed77516c792e3fb9c777066c3776abcc Skip non-final class method with no content in AddVoidReturnTypeWhereNoReturnRector (#5386) --- .../AddVoidReturnTypeWhereNoReturnRector.php | 14 +++++++++++++- src/Application/VersionResolver.php | 4 ++-- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/rules/TypeDeclaration/Rector/ClassMethod/AddVoidReturnTypeWhereNoReturnRector.php b/rules/TypeDeclaration/Rector/ClassMethod/AddVoidReturnTypeWhereNoReturnRector.php index 27b07ad169b..289b03a82f4 100644 --- a/rules/TypeDeclaration/Rector/ClassMethod/AddVoidReturnTypeWhereNoReturnRector.php +++ b/rules/TypeDeclaration/Rector/ClassMethod/AddVoidReturnTypeWhereNoReturnRector.php @@ -86,7 +86,8 @@ CODE_SAMPLE */ public function refactor(Node $node) : ?Node { - if ($node->returnType !== null) { + // already has return type → skip + if ($node->returnType instanceof Node) { return null; } if ($this->shouldSkipClassMethod($node)) { @@ -123,6 +124,10 @@ CODE_SAMPLE if ($this->isNotFinalAndHasExceptionOnly($functionLike)) { return \true; } + // possibly required by child implementation + if ($this->isNotFinalAndEmpty($functionLike)) { + return \true; + } if ($functionLike->isProtected()) { return !$this->classModifierChecker->isInsideFinalClass($functionLike); } @@ -139,4 +144,11 @@ CODE_SAMPLE $onlyStmt = $classMethod->stmts[0] ?? null; return $onlyStmt instanceof Throw_; } + private function isNotFinalAndEmpty(ClassMethod $classMethod) : bool + { + if ($this->classModifierChecker->isInsideFinalClass($classMethod)) { + return \false; + } + return $classMethod->stmts === []; + } } diff --git a/src/Application/VersionResolver.php b/src/Application/VersionResolver.php index aa47e15b679..5cfcf96e2c3 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 = '00b442f2d79f1536e9dc59c2fa7ff541a0cba1e8'; + public const PACKAGE_VERSION = '012e8bb2ed77516c792e3fb9c777066c3776abcc'; /** * @api * @var string */ - public const RELEASE_DATE = '2023-12-24 01:49:14'; + public const RELEASE_DATE = '2023-12-24 02:19:52'; /** * @var int */