Skip to content

Commit bbd09ab

Browse files
authored
[TypeDeclaration] Handle with other method from parent on KnownMagicClassMethodTypeRector (#7423)
* [TypeDeclaration] Handle with other method from parent on KnownMagicClassMethodTypeRector * Fix * fix * fix
1 parent 6016355 commit bbd09ab

4 files changed

Lines changed: 50 additions & 2 deletions

File tree

composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,8 @@
9090
"classmap": [
9191
"stubs",
9292
"rules-tests/CodingStyle/Rector/Namespace_/ImportFullyQualifiedNamesRector/Source",
93-
"rules-tests/Renaming/Rector/Name/RenameClassRector/Source"
93+
"rules-tests/Renaming/Rector/Name/RenameClassRector/Source",
94+
"rules-tests/TypeDeclaration/Rector/ClassMethod/KnownMagicClassMethodTypeRector/Source"
9495
],
9596
"files": [
9697
"tests/debug_functions.php",
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<?php
2+
3+
namespace Rector\Tests\TypeDeclaration\Rector\ClassMethod\KnownMagicClassMethodTypeRector\Fixture;
4+
5+
use Rector\Tests\TypeDeclaration\Rector\ClassMethod\KnownMagicClassMethodTypeRector\Source\ParentClassWithOtherMethod;
6+
7+
final class WithOtherMethodFromParent extends ParentClassWithOtherMethod
8+
{
9+
public function __invoke()
10+
{
11+
}
12+
13+
public function __call($method, $args)
14+
{
15+
}
16+
}
17+
18+
?>
19+
-----
20+
<?php
21+
22+
namespace Rector\Tests\TypeDeclaration\Rector\ClassMethod\KnownMagicClassMethodTypeRector\Fixture;
23+
24+
use Rector\Tests\TypeDeclaration\Rector\ClassMethod\KnownMagicClassMethodTypeRector\Source\ParentClassWithOtherMethod;
25+
26+
final class WithOtherMethodFromParent extends ParentClassWithOtherMethod
27+
{
28+
public function __invoke()
29+
{
30+
}
31+
32+
public function __call(string $method, array $args)
33+
{
34+
}
35+
}
36+
37+
?>
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?php
2+
3+
namespace Rector\Tests\TypeDeclaration\Rector\ClassMethod\KnownMagicClassMethodTypeRector\Source;
4+
5+
abstract class ParentClassWithOtherMethod
6+
{
7+
public function __invoke()
8+
{
9+
}
10+
}

rules/TypeDeclaration/Rector/ClassMethod/KnownMagicClassMethodTypeRector.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ public function refactor(Node $node): ?Node
8080
}
8181

8282
if ($this->parentClassMethodTypeOverrideGuard->hasParentClassMethod($classMethod)) {
83-
return null;
83+
continue;
8484
}
8585

8686
if ($this->isNames($classMethod, [MethodName::CALL, MethodName::CALL_STATIC])) {

0 commit comments

Comments
 (0)