8000 [TypeDeclaration] Skip __destruct() from add return type based on par… · rectorphp/rector-src@c6df7f5 · GitHub
[go: up one dir, main page]

Skip to content

Commit c6df7f5

Browse files
authored
[TypeDeclaration] Skip __destruct() from add return type based on parent on AddReturnTypeDeclarationBasedOnParentClassMethodRector (#6883)
* [TypeDeclaration] Skip __destruct() from add return type based on parent on AddReturnTypeDeclarationBasedOnParentClassMethodRector * Fix
1 parent 7d245b7 commit c6df7f5

File tree

3 files changed

+17
-1
lines changed

3 files changed

+17
-1
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?php
2+
3+
namespace Rector\Tests\TypeDeclaration\Rector\ClassMethod\AddReturnTypeDeclarationBasedOnParentClassMethodRector\Fixture;
4+
5+
use Rector\Tests\TypeDeclaration\Rector\ClassMethod\AddReturnTypeDeclarationBasedOnParentClassMethodRector\Source\SomeClassWithoutReturnType;
6+
7+
class SkipDestruct extends SomeClassWithoutReturnType
8+
{
9+
public function __destruct()
10+
{
11+
}
12+
}

rules-tests/TypeDeclaration/Rector/ClassMethod/AddReturnTypeDeclarationBasedOnParentClassMethodRector/Source/SomeClassWithoutReturnType.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,8 @@ public funct 8000 ion run()
1010
{
1111
return 5;
1212
}
13+
14+
public function __destruct()
15+
{
16+
}
1317
}

rules/TypeDeclaration/Rector/ClassMethod/AddReturnTypeDeclarationBasedOnParentClassMethodRector.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ public function refactor(Node $node): ?Node
9393
$hasChanged = false;
9494

9595
foreach ($node->getMethods() as $classMethod) {
96-
if ($this->isName($classMethod, MethodName::CONSTRUCT)) {
96+
if ($this->isNames($classMethod, [MethodName::CONSTRUCT, MethodName::DESCTRUCT])) {
9797
continue;
9898
}
9999

0 commit comments

Comments
 (0)
0