From 2fc67b00097dfe703c4627303a3a7337aadea53b Mon Sep 17 00:00:00 2001 From: Simon Hatt Date: Tue, 18 Aug 2026 13:56:50 +0200 Subject: [PATCH 1/3] Validate subclass in parseType() method Add a check to ensure parseType() is called on a TypedEndpoint subclass. --- server/lib/TypedEndpoint.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/server/lib/TypedEndpoint.php b/server/lib/TypedEndpoint.php index 9d27ab6..6b82322 100644 --- a/server/lib/TypedEndpoint.php +++ b/server/lib/TypedEndpoint.php @@ -31,6 +31,9 @@ public function __construct() { public function parseType(): void { $class_name = get_called_class(); + if (!is_subclass_of($class_name, TypedEndpoint::class)) { + throw new \LogicException("parseType() must be called on a TypedEndpoint subclass"); + } $this->aliasNodes = []; $fn = function (Node $node, string $class_name, array $generic_args) { [$node, $new_exports] = $this->phpStanUtils->rewriteType($node, $class_name, $generic_args); From 15501299da30c1771383a7c04da3086061f1af62 Mon Sep 17 00:00:00 2001 From: Simon Hatt Date: Tue, 18 Aug 2026 13:59:38 +0200 Subject: [PATCH 2/3] Update TypedEndpoint.php --- server/lib/TypedEndpoint.php | 1 + 1 file changed, 1 insertion(+) diff --git a/server/lib/TypedEndpoint.php b/server/lib/TypedEndpoint.php index 6b82322..e00d2f2 100644 --- a/server/lib/TypedEndpoint.php +++ b/server/lib/TypedEndpoint.php @@ -31,6 +31,7 @@ public function __construct() { public function parseType(): void { $class_name = get_called_class(); + // phpstan-ignore function.alreadyNarrowedType if (!is_subclass_of($class_name, TypedEndpoint::class)) { throw new \LogicException("parseType() must be called on a TypedEndpoint subclass"); } From ef397471838a0075d4a8500a6d1a874cea3825d8 Mon Sep 17 00:00:00 2001 From: Simon Hatt Date: Tue, 18 Aug 2026 14:06:38 +0200 Subject: [PATCH 3/3] Update phpstan ignore comment syntax in parseType --- server/lib/TypedEndpoint.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/lib/TypedEndpoint.php b/server/lib/TypedEndpoint.php index e00d2f2..fc247b0 100644 --- a/server/lib/TypedEndpoint.php +++ b/server/lib/TypedEndpoint.php @@ -31,7 +31,7 @@ public function __construct() { public function parseType(): void { $class_name = get_called_class(); - // phpstan-ignore function.alreadyNarrowedType + // @phpstan-ignore-next-line function.alreadyNarrowedType if (!is_subclass_of($class_name, TypedEndpoint::class)) { throw new \LogicException("parseType() must be called on a TypedEndpoint subclass"); }