Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -81,12 +81,12 @@ public function getNodeTypes(): array
*/
public function refactor(Node $node): ?Node
{
if ($node->getMethods() === []) {
// unreliable to detect on anonymous class: doesn't make sense
if ($node->isAnonymous()) {
return null;
}

// unreliable to detect on anonymous class: doesn't make sense
if ($node->isAnonymous()) {
if (! $this->hasPrivateMethod($node)) {
return null;
}

Expand Down Expand Up @@ -145,6 +145,11 @@ public function refactor(Node $node): ?Node
return null;
}

private function hasPrivateMethod(Class_ $class): bool
{
return array_any($class->getMethods(), fn(ClassMethod $classMethod): bool => $classMethod->isPrivate());
}

private function shouldSkip(ClassMethod $classMethod, ClassReflection $classReflection): bool
{
// unreliable to detect trait, interface: doesn't make sense
Expand Down
Loading