File tree Expand file tree Collapse file tree 5 files changed +11
-3
lines changed
examples/stdio-logging-showcase Expand file tree Collapse file tree 5 files changed +11
-3
lines changed Original file line number Diff line number Diff line change 2929
3030$ transport = new StdioTransport (logger: logger ());
3131
32- $ server ->connect ($ transport );
32+ $ server ->run ($ transport );
3333
3434logger ()->info ('Logging Showcase Server is ready! ' );
3535logger ()->info ('This example demonstrates auto-injection of McpLogger into capability handlers. ' );
Original file line number Diff line number Diff line change 2828 */
2929final class NotificationSender
3030{
31+ /**
32+ * @param TransportInterface<mixed>|null $transport
33+ */
3134 public function __construct (
3235 private readonly NotificationHandler $ notificationHandler ,
3336 private ?TransportInterface $ transport = null ,
@@ -37,6 +40,8 @@ public function __construct(
3740
3841 /**
3942 * Sets the transport interface for sending notifications.
43+ *
44+ * @param TransportInterface<mixed> $transport
4045 */
4146 public function setTransport (TransportInterface $ transport ): void
4247 {
Original file line number Diff line number Diff line change @@ -77,6 +77,10 @@ public function methodWithReturn(): string
7777 */
7878 public function methodWithMultipleTags (float $ value ): bool
7979 {
80+ if ($ value < 0 ) {
81+ throw new \RuntimeException ('Processing failed for negative values ' );
82+ }
83+
8084 return true ;
8185 }
8286
Original file line number Diff line number Diff line change 2727final class NotificationSenderTest extends TestCase
2828{
2929 private NotificationHandler $ notificationHandler ;
30+ /** @var TransportInterface<mixed>&MockObject */
3031 private TransportInterface &MockObject $ transport ;
3132 private LoggerInterface &MockObject $ logger ;
3233 private ReferenceProviderInterface &MockObject $ referenceProvider ;
Original file line number Diff line number Diff line change @@ -48,7 +48,5 @@ public function testJsonExceptions()
4848 $ notificationSender = new NotificationSender ($ notificationHandler );
4949 $ server = new Server ($ handler , $ notificationSender );
5050 $ server ->run ($ transport );
51-
52- $ transport ->listen ();
5351 }
5452}
You can’t perform that action at this time.
0 commit comments