Skip to content

Commit e2f22eb

Browse files
author
Anne-Julia Seitz
committed
fix(composer): docblocks
1 parent 24e7701 commit e2f22eb

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/Tool/Composer.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
namespace Dazz\PhpMcpTools\Tool;
66

77
use Dazz\PhpMcpTools\Exception\InvalidArgumentException;
8+
use PhpLlm\LlmChain\Chain\JsonSchema\Attribute\With;
89
use PhpLlm\LlmChain\Chain\Toolbox\Attribute\AsTool;
910
use Webmozart\Assert\Assert;
1011

@@ -17,6 +18,9 @@ public function __construct(
1718
) {
1819
}
1920

21+
/**
22+
* @return string Result of checking if executable exists
23+
*/
2024
public function exists(): string
2125
{
2226
return $this->isExecutableExisting() ? 'composer executable exists' : 'composer executable not found';
@@ -33,6 +37,7 @@ public function exists(): string
3337
* @throws \InvalidArgumentException If composer executable is not found
3438
*/
3539
public function execute(
40+
#[With(pattern: '/^[a-z\-]+$/')]
3641
string $command = 'list',
3742
array $options = [],
3843
array $arguments = [],
@@ -42,7 +47,7 @@ public function execute(
4247
throw new InvalidArgumentException('Composer executable not found. Please install Composer.');
4348
}
4449

45-
if (!preg_match('/^[a-zA-Z0-9_\-]+$/', $command)) {
50+
if (!preg_match('/^[a-z\-]+$/', $command)) {
4651
throw new InvalidArgumentException('Invalid Composer command. Only alphanumeric characters, underscores, and hyphens are allowed.');
4752
}
4853

0 commit comments

Comments
 (0)