Skip to content

Commit 39564a7

Browse files
committed
[Server] Address review: cover listChanged-only kinds, clarify bus docblock
1 parent 69b8eaf commit 39564a7

2 files changed

Lines changed: 29 additions & 5 deletions

File tree

‎src/Server/Builder.php‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -313,11 +313,11 @@ public function setServerInfo(
313313
* runtimes; under PHP-FPM, where they are different workers, use
314314
* {@see Psr16NotificationBus} or an implementation over your own broker.
315315
*
316-
* Registry changes are published automatically, with or without an event
317-
* dispatcher, unless you pass your own registry with setRegistry(), and
318-
* only then is `listChanged` announced. Anything
319-
* else, `notifications/resources/updated` for example, is published by the
320-
* application calling {@see NotificationBusInterface::publish()}.
316+
* With the built-in registry, registry changes are published automatically,
317+
* with or without an event dispatcher, and `listChanged` is announced. A
318+
* registry passed with setRegistry() is neither published nor announced.
319+
* Anything else, `notifications/resources/updated` for example, is
320+
* published by the application calling {@see NotificationBusInterface::publish()}.
321321
*/
322322
public function setNotificationBus(NotificationBusInterface $bus): self
323323
{

‎tests/Unit/Schema/ServerCapabilitiesTest.php‎

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -429,4 +429,28 @@ public function testWithExtensionsKeepsTasks(): void
429429

430430
$this->assertSame(['list' => []], $capabilities->tasks);
431431
}
432+
433+
public function testWithoutListChangedKeepsKindsAnnouncedOnlyThroughListChanged(): void
434+
{
435+
$capabilities = (new ServerCapabilities(
436+
tools: false,
437+
toolsListChanged: true,
438+
resources: false,
439+
resourcesListChanged: true,
440+
prompts: false,
441+
promptsListChanged: true,
442+
))->withoutListChanged();
443+
444+
$this->assertTrue($capabilities->tools);
445+
$this->assertFalse($capabilities->toolsListChanged);
446+
$this->assertTrue($capabilities->resources);
447+
$this->assertFalse($capabilities->resourcesListChanged);
448+
$this->assertTrue($capabilities->prompts);
449+
$this->assertFalse($capabilities->promptsListChanged);
450+
$this->assertEquals([
451+
'prompts' => new \stdClass(),
452+
'resources' => new \stdClass(),
453+
'tools' => new \stdClass(),
454+
], $capabilities->jsonSerialize());
455+
}
432456
}

0 commit comments

Comments
 (0)