From 3fc510ca164ba214917f61f1f6678a2463d60071 Mon Sep 17 00:00:00 2001 From: Abdul Malik Ikhsan Date: Mon, 5 May 2025 19:09:19 +0700 Subject: [PATCH 1/2] [TypeDeclaration] Skip __destruct() from add return type based on parent on AddReturnTypeDeclarationBasedOnParentClassMethodRector --- .../Fixture/skip_destruct.php.inc | 12 ++++++++++++ .../Source/SomeClassWithoutReturnType.php | 4 ++++ 2 files changed, 16 insertions(+) create mode 100644 rules-tests/TypeDeclaration/Rector/ClassMethod/AddReturnTypeDeclarationBasedOnParentClassMethodRector/Fixture/skip_destruct.php.inc diff --git a/rules-tests/TypeDeclaration/Rector/ClassMethod/AddReturnTypeDeclarationBasedOnParentClassMethodRector/Fixture/skip_destruct.php.inc b/rules-tests/TypeDeclaration/Rector/ClassMethod/AddReturnTypeDeclarationBasedOnParentClassMethodRector/Fixture/skip_destruct.php.inc new file mode 100644 index 00000000000..53440202b9d --- /dev/null +++ b/rules-tests/TypeDeclaration/Rector/ClassMethod/AddReturnTypeDeclarationBasedOnParentClassMethodRector/Fixture/skip_destruct.php.inc @@ -0,0 +1,12 @@ + Date: Mon, 5 May 2025 19:11:34 +0700 Subject: [PATCH 2/2] Fix --- .../AddReturnTypeDeclarationBasedOnParentClassMethodRector.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rules/TypeDeclaration/Rector/ClassMethod/AddReturnTypeDeclarationBasedOnParentClassMethodRector.php b/rules/TypeDeclaration/Rector/ClassMethod/AddReturnTypeDeclarationBasedOnParentClassMethodRector.php index 320104c7432..e1f5dc75f35 100644 --- a/rules/TypeDeclaration/Rector/ClassMethod/AddReturnTypeDeclarationBasedOnParentClassMethodRector.php +++ b/rules/TypeDeclaration/Rector/ClassMethod/AddReturnTypeDeclarationBasedOnParentClassMethodRector.php @@ -93,7 +93,7 @@ public function refactor(Node $node): ?Node $hasChanged = false; foreach ($node->getMethods() as $classMethod) { - if ($this->isName($classMethod, MethodName::CONSTRUCT)) { + if ($this->isNames($classMethod, [MethodName::CONSTRUCT, MethodName::DESCTRUCT])) { continue; }