Skip to content

Commit fadede3

Browse files
mowens3claude
andcommitted
Add @codeCoverageIgnore for optional dependency guards
Runtime guards for mcp/sdk cannot be tested when the package is installed, so mark them for coverage exclusion. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 37f7056 commit fadede3

File tree

3 files changed

+10
-1
lines changed

3 files changed

+10
-1
lines changed

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
88
## [1.2.3] - 2026-01-09
99

1010
### Fixed
11-
- Remove unreachable code branch in `toJsonRpcError()` for 100% test coverage
11+
- Achieve 100% test coverage by excluding optional dependency guards
12+
- Remove unreachable code branch in `toJsonRpcError()`
1213

1314
## [1.2.0] - 2025-01-09
1415

src/ErrorBag.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,11 +244,13 @@ public function getSummaryMessage(): string
244244
*/
245245
public function toCallToolResult(): object
246246
{
247+
// @codeCoverageIgnoreStart
247248
if (!class_exists(\Mcp\Schema\Result\CallToolResult::class)) {
248249
throw new \RuntimeException(
249250
'mcp/sdk package is required for toCallToolResult(). Install with: composer require mcp/sdk'
250251
);
251252
}
253+
// @codeCoverageIgnoreEnd
252254

253255
if (empty($this->errors)) {
254256
return new \Mcp\Schema\Result\CallToolResult(
@@ -272,11 +274,13 @@ public function toCallToolResult(): object
272274
*/
273275
public function toJsonRpcError(): object
274276
{
277+
// @codeCoverageIgnoreStart
275278
if (!class_exists(\Mcp\Schema\JsonRpc\Error::class)) {
276279
throw new \RuntimeException(
277280
'mcp/sdk package is required for toJsonRpcError(). Install with: composer require mcp/sdk'
278281
);
279282
}
283+
// @codeCoverageIgnoreEnd
280284

281285
if (empty($this->errors)) {
282286
throw new \RuntimeException('Cannot convert empty ErrorBag to JsonRpcError');

src/McpError.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -352,11 +352,13 @@ public function toArray(): array
352352
*/
353353
public function toCallToolResult(): object
354354
{
355+
// @codeCoverageIgnoreStart
355356
if (!class_exists(\Mcp\Schema\Result\CallToolResult::class)) {
356357
throw new \RuntimeException(
357358
'mcp/sdk package is required for toCallToolResult(). Install with: composer require mcp/sdk'
358359
);
359360
}
361+
// @codeCoverageIgnoreEnd
360362

361363
$content = [new \Mcp\Schema\Content\TextContent($this->getMessage())];
362364
$structured = $this->toArray();
@@ -374,11 +376,13 @@ public function toCallToolResult(): object
374376
*/
375377
public function toJsonRpcError(): object
376378
{
379+
// @codeCoverageIgnoreStart
377380
if (!class_exists(\Mcp\Schema\JsonRpc\Error::class)) {
378381
throw new \RuntimeException(
379382
'mcp/sdk package is required for toJsonRpcError(). Install with: composer require mcp/sdk'
380383
);
381384
}
385+
// @codeCoverageIgnoreEnd
382386

383387
$data = $this->toArray();
384388
unset($data['success'], $data['error']);

0 commit comments

Comments
 (0)