Skip to content

Commit

Permalink
style: update check for class instance in GeneratorCompilerPass
Browse files Browse the repository at this point in the history
  • Loading branch information
tinect committed Jun 19, 2024
1 parent dc88d75 commit 9a8df64
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions src/DependencyInjection/GeneratorCompilerPass.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
use Symfony\Component\DependencyInjection\ContainerBuilder;

class GeneratorCompilerPass implements CompilerPassInterface
readonly class GeneratorCompilerPass implements CompilerPassInterface
{
public function __construct(
private readonly string $class
private string $class
) {
}

Expand Down Expand Up @@ -139,16 +139,15 @@ private function handleFileSaver(NodeFinder $nodeFinder, array $ast): void
*/
private function getClassMethod(NodeFinder $nodeFinder, string $name, array $ast): ClassMethod
{
/** @var ?ClassMethod $node */
$node = $nodeFinder->findFirst($ast, function ($node) use ($name) {
return $node instanceof ClassMethod && $node->name->toString() === $name;
});

if (empty($node)) {
throw new \RuntimeException(\sprintf('Method %s in class %s is missing', $name, $this->class));
if ($node instanceof ClassMethod) {
return $node;
}

return $node;
throw new \RuntimeException(\sprintf('Method %s in class %s is missing', $name, $this->class));
}

/**
Expand Down

0 comments on commit 9a8df64

Please sign in to comment.