Skip to content

Commit

Permalink
[TypeDeclaration] Skip public method on AddMethodCallBasedStrictParam…
Browse files Browse the repository at this point in the history
…TypeRector (#4659)

* [TypeDeclaration] Skip public method on AddMethodCallBasedStrictParamTypeRector

* rename

* [ci-review] Rector Rectify

* [ci-review] Rector Rectify

---------

Co-authored-by: GitHub Action <actions@github.com>
  • Loading branch information
samsonasik and actions-user committed Aug 5, 2023
1 parent ae89643 commit 8c04f65
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php

declare(strict_types=1);

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

abstract class SkipPublicMethod
{
public function toJson()
{
return $this->toArray(true);
}

public function __toString()
{
return implode(', ', $this->toArray());
}

final public function toArray($cols = false)
{
if ((! is_bool($cols)) && (! is_array($cols))) {
throw new Exception('Invalid value cols');
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -100,11 +100,14 @@ public function refactor(Node $node): ?Node
&& $node->implements === []
)
|| $method->isPrivate();

if (! $isPrivate) {
continue;
}

if ($method->isPublic()) {
continue;
}

$methodCalls = $this->localMethodCallFinder->match($node, $method);
$classMethodParameterTypes = $this->callTypesResolver->resolveStrictTypesFromCalls($methodCalls);

Expand Down

0 comments on commit 8c04f65

Please sign in to comment.