Skip to content

Commit d1771b9

Browse files
lint: Format code using PHP CS Fixer
1 parent 951ec4a commit d1771b9

35 files changed

+294
-170
lines changed

examples/02-discovery-http-userprofile/server.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,15 +67,15 @@ public function log($level, \Stringable|string $message, array $context = []): v
6767

6868
$server = Server::make()
6969
->withServerInfo('HTTP User Profiles', '1.0.0')
70-
->withCapabilities(ServerCapabilities::make(completionsEnabled: true, loggingEnabled: true))
70+
->withCapabilities(ServerCapabilities::make(completions: true, logging: true))
7171
->withLogger($logger)
7272
->withContainer($container)
7373
->build();
7474

7575
$server->discover(__DIR__, ['.']);
7676

77-
// $transport = new HttpServerTransport('127.0.0.1', 8080, 'mcp');
78-
$transport = new StreamableHttpServerTransport('127.0.0.1', 8080, 'mcp');
77+
$transport = new HttpServerTransport('127.0.0.1', 8080, 'mcp');
78+
// $transport = new StreamableHttpServerTransport('127.0.0.1', 8080, 'mcp');
7979

8080
$server->listen($transport);
8181

src/Attributes/CompletionProvider.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,7 @@ class CompletionProvider
1313
/**
1414
* @param class-string<CompletionProviderInterface> $providerClass FQCN of the completion provider class.
1515
*/
16-
public function __construct(public string $providerClass) {}
16+
public function __construct(public string $providerClass)
17+
{
18+
}
1719
}

src/Attributes/Schema.php

Lines changed: 45 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -152,27 +152,57 @@ public function toArray(): array
152152
}
153153

154154
// String
155-
if ($this->minLength !== null) $schema['minLength'] = $this->minLength;
156-
if ($this->maxLength !== null) $schema['maxLength'] = $this->maxLength;
157-
if ($this->pattern !== null) $schema['pattern'] = $this->pattern;
155+
if ($this->minLength !== null) {
156+
$schema['minLength'] = $this->minLength;
157+
}
158+
if ($this->maxLength !== null) {
159+
$schema['maxLength'] = $this->maxLength;
160+
}
161+
if ($this->pattern !== null) {
162+
$schema['pattern'] = $this->pattern;
163+
}
158164

159165
// Numeric
160-
if ($this->minimum !== null) $schema['minimum'] = $this->minimum;
161-
if ($this->maximum !== null) $schema['maximum'] = $this->maximum;
162-
if ($this->exclusiveMinimum !== null) $schema['exclusiveMinimum'] = $this->exclusiveMinimum;
163-
if ($this->exclusiveMaximum !== null) $schema['exclusiveMaximum'] = $this->exclusiveMaximum;
164-
if ($this->multipleOf !== null) $schema['multipleOf'] = $this->multipleOf;
166+
if ($this->minimum !== null) {
167+
$schema['minimum'] = $this->minimum;
168+
}
169+
if ($this->maximum !== null) {
170+
$schema['maximum'] = $this->maximum;
171+
}
172+
if ($this->exclusiveMinimum !== null) {
173+
$schema['exclusiveMinimum'] = $this->exclusiveMinimum;
174+
}
175+
if ($this->exclusiveMaximum !== null) {
176+
$schema['exclusiveMaximum'] = $this->exclusiveMaximum;
177+
}
178+
if ($this->multipleOf !== null) {
179+
$schema['multipleOf'] = $this->multipleOf;
180+
}
165181

166182
// Array
167-
if ($this->items !== null) $schema['items'] = $this->items;
168-
if ($this->minItems !== null) $schema['minItems'] = $this->minItems;
169-
if ($this->maxItems !== null) $schema['maxItems'] = $this->maxItems;
170-
if ($this->uniqueItems !== null) $schema['uniqueItems'] = $this->uniqueItems;
183+
if ($this->items !== null) {
184+
$schema['items'] = $this->items;
185+
}
186+
if ($this->minItems !== null) {
187+
$schema['minItems'] = $this->minItems;
188+
}
189+
if ($this->maxItems !== null) {
190+
$schema['maxItems'] = $this->maxItems;
191+
}
192+
if ($this->uniqueItems !== null) {
193+
$schema['uniqueItems'] = $this->uniqueItems;
194+
}
171195

172196
// Object
173-
if ($this->properties !== null) $schema['properties'] = $this->properties;
174-
if ($this->required !== null) $schema['required'] = $this->required;
175-
if ($this->additionalProperties !== null) $schema['additionalProperties'] = $this->additionalProperties;
197+
if ($this->properties !== null) {
198+
$schema['properties'] = $this->properties;
199+
}
200+
if ($this->required !== null) {
201+
$schema['required'] = $this->required;
202+
}
203+
if ($this->additionalProperties !== null) {
204+
$schema['additionalProperties'] = $this->additionalProperties;
205+
}
176206

177207
return $schema;
178208
}

src/Dispatcher.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,7 @@ public function handleCompletionComplete(CompletionCompleteRequest $request, Ses
342342
}
343343

344344
$providerClass = $registeredPrompt->getCompletionProvider($argumentName);
345-
} else if ($ref->type === 'ref/resource') {
345+
} elseif ($ref->type === 'ref/resource') {
346346
$identifier = $ref->uri;
347347
$registeredResourceTemplate = $this->registry->getResourceTemplate($identifier);
348348
if (! $registeredResourceTemplate) {

src/Elements/RegisteredElement.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ public function __construct(
2121
public readonly string $handlerClass,
2222
public readonly string $handlerMethod,
2323
public readonly bool $isManual = false,
24-
) {}
24+
) {
25+
}
2526

2627
public function handle(ContainerInterface $container, array $arguments): mixed
2728
{
@@ -117,7 +118,7 @@ private function castArgumentType(mixed $argument, ReflectionParameter $paramete
117118
return $case;
118119
}
119120
}
120-
$validNames = array_map(fn($c) => $c->name, $typeName::cases());
121+
$validNames = array_map(fn ($c) => $c->name, $typeName::cases());
121122
throw new InvalidArgumentException(
122123
"Invalid value '{$argument}' for unit enum {$typeName}. Expected one of: " . implode(', ', $validNames) . "."
123124
);

src/Elements/RegisteredResource.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public static function make(Resource $schema, string $handlerClass, string $hand
3030

3131
/**
3232
* Reads the resource content.
33-
*
33+
*
3434
* @return array<TextResourceContents|BlobResourceContents> Array of ResourceContents objects.
3535
*/
3636
public function read(ContainerInterface $container, string $uri): array
@@ -99,7 +99,7 @@ protected function formatResult(mixed $readResult, string $uri, ?string $mimeTyp
9999
}
100100

101101
if ($allAreEmbeddedResource && $hasEmbeddedResource) {
102-
return array_map(fn($item) => $item->resource, $readResult);
102+
return array_map(fn ($item) => $item->resource, $readResult);
103103
}
104104

105105
if ($hasResourceContents || $hasEmbeddedResource) {

src/Elements/RegisteredResourceTemplate.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public static function make(ResourceTemplate $schema, string $handlerClass, stri
3737

3838
/**
3939
* Gets the resource template.
40-
*
40+
*
4141
* @return array<TextResourceContents|BlobResourceContents> Array of ResourceContents objects.
4242
*/
4343
public function read(ContainerInterface $container, string $uri): array
@@ -156,7 +156,7 @@ protected function formatResult(mixed $readResult, string $uri, ?string $mimeTyp
156156
}
157157

158158
if ($allAreEmbeddedResource && $hasEmbeddedResource) {
159-
return array_map(fn($item) => $item->resource, $readResult);
159+
return array_map(fn ($item) => $item->resource, $readResult);
160160
}
161161

162162
if ($hasResourceContents || $hasEmbeddedResource) {

src/Registry.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -438,24 +438,24 @@ public function getPrompt(string $name): ?RegisteredPrompt
438438
/** @return array<string, Tool> */
439439
public function getTools(): array
440440
{
441-
return array_map(fn($tool) => $tool->schema, $this->tools);
441+
return array_map(fn ($tool) => $tool->schema, $this->tools);
442442
}
443443

444444
/** @return array<string, Resource> */
445445
public function getResources(): array
446446
{
447-
return array_map(fn($resource) => $resource->schema, $this->resources);
447+
return array_map(fn ($resource) => $resource->schema, $this->resources);
448448
}
449449

450450
/** @return array<string, Prompt> */
451451
public function getPrompts(): array
452452
{
453-
return array_map(fn($prompt) => $prompt->schema, $this->prompts);
453+
return array_map(fn ($prompt) => $prompt->schema, $this->prompts);
454454
}
455455

456456
/** @return array<string, ResourceTemplate> */
457457
public function getResourceTemplates(): array
458458
{
459-
return array_map(fn($template) => $template->schema, $this->resourceTemplates);
459+
return array_map(fn ($template) => $template->schema, $this->resourceTemplates);
460460
}
461461
}

src/Server.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,8 @@ public function __construct(
4141
protected readonly Registry $registry,
4242
protected readonly Protocol $protocol,
4343
protected readonly SessionManager $sessionManager,
44-
) {}
44+
) {
45+
}
4546

4647
public static function make(): ServerBuilder
4748
{

src/ServerBuilder.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,9 @@ final class ServerBuilder
8888
* > */
8989
private array $manualPrompts = [];
9090

91-
public function __construct() {}
91+
public function __construct()
92+
{
93+
}
9294

9395
/**
9496
* Sets the server's identity. Required.

0 commit comments

Comments
 (0)