Skip to content

Commit 68c8e2c

Browse files
Improved Exception syntax
Signed-off-by: Tom Wright <[email protected]>
1 parent 50a2b5f commit 68c8e2c

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

CHANGELOG.md

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
* Improved Exception syntax
2+
13
## v0.3.8 (2025-02-12)
24
* Upgraded PHPStan to v2
35
* Added @phpstan-require-implements constraints

src/Handler.php

+12-4
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,9 @@ public function register(
8080
!interface_exists($interface) &&
8181
!class_exists($interface)
8282
) {
83-
throw Exceptional::NotFound('Interface ' . $interface . ' does not exist');
83+
throw Exceptional::NotFound(
84+
message: 'Interface ' . $interface . ' does not exist'
85+
);
8486
}
8587

8688
if (
@@ -200,7 +202,9 @@ public function resolve(
200202
$names = implode(', ', $names);
201203
}
202204

203-
throw Exceptional::NotFound('Could not resolve ' . ($names ? '"' . $names . '"' : 'default') . ' for interface ' . $interface);
205+
throw Exceptional::NotFound(
206+
message: 'Could not resolve ' . ($names ? '"' . $names . '"' : 'default') . ' for interface ' . $interface
207+
);
204208
}
205209

206210
return $class;
@@ -385,7 +389,9 @@ public function findFile(
385389
}
386390
}
387391

388-
throw Exceptional::NotFound('Could not find file "' . $name . '" in namespace ' . $interface);
392+
throw Exceptional::NotFound(
393+
message: 'Could not find file "' . $name . '" in namespace ' . $interface
394+
);
389395
}
390396

391397

@@ -431,7 +437,9 @@ protected function ensureResolver(
431437
if ($interface === Resolver::class) {
432438
$class = ArchetypeResolver::class;
433439
} elseif (!$class = $this->resolve(Resolver::class, $interface)) {
434-
throw Exceptional::NotFound('Interface ' . $interface . ' has no Archetype resolver');
440+
throw Exceptional::NotFound(
441+
message: 'Interface ' . $interface . ' has no Archetype resolver'
442+
);
435443
}
436444

437445
/** @var class-string<Resolver> $class */

0 commit comments

Comments
 (0)