Skip to content

Commit

Permalink
Use "*" to match declarations without implementes
Browse files Browse the repository at this point in the history
  • Loading branch information
koriym committed Oct 5, 2023
1 parent b47e7cd commit 80b587f
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/AopCodeGenNewCode.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public function insert(string $code): void

public function implementsInterface(string $interfaceName): void
{
$pattern = '@(class\s+\w+\s*(?:extends\s+\w+)?)\s*(implements\s+[\w]+)@';
$pattern = '@(class\s+\w+\s*(?:extends\s+\w+)?)\s*(implements\s+[\w]+)*@';

$this->code = (string) preg_replace_callback($pattern, static function ($matches) use ($interfaceName) {
if (isset($matches[2])) {
Expand All @@ -52,7 +52,7 @@ public function implementsInterface(string $interfaceName): void
}

// implements が存在しない場合
return rtrim($matches[1], "\n") . 'implements \\' . $interfaceName;
return rtrim($matches[1], "\n") . ' implements \\' . $interfaceName;
}, $this->code);
}

Expand Down

0 comments on commit 80b587f

Please sign in to comment.