Skip to content

Commit

Permalink
[Performance] [TypeDeclaration] No need check parent method when meth…
Browse files Browse the repository at this point in the history
…od is private on AddVoidReturnTypeWhereNoReturnRector (rectorphp#5690)

* [TypeDeclaration] No need check parent method when method is private on AddVoidReturnTypeWhereNoReturnRector

* [TypeDeclaration] No need check parent method when method is private on AddVoidReturnTypeWhereNoReturnRector
  • Loading branch information
samsonasik authored and Arjen Schol committed Mar 6, 2024
1 parent 3ebaa06 commit 77b1a08
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php

namespace Rector\Tests\TypeDeclaration\Rector\ClassMethod\AddVoidReturnTypeWhereNoReturnRector\Fixture;

final class VoidOnPrivateMethod
{
private function getValues()
{
$value = 1000;
return;
}
}

?>
-----
<?php

namespace Rector\Tests\TypeDeclaration\Rector\ClassMethod\AddVoidReturnTypeWhereNoReturnRector\Fixture;

final class VoidOnPrivateMethod
{
private function getValues(): void
{
$value = 1000;
return;
}
}

?>
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ public function __construct(

public function isVendorLocked(ClassMethod $classMethod): bool
{
if ($classMethod->isPrivate()) {
return false;
}

$classReflection = $this->reflectionResolver->resolveClassReflection($classMethod);
if (! $classReflection instanceof ClassReflection) {
return false;
Expand Down

0 comments on commit 77b1a08

Please sign in to comment.