From 7f899b3bc8a4debcde2d4f4b81d9044221718292 Mon Sep 17 00:00:00 2001 From: Carl Schwan Date: Fri, 13 May 2022 16:14:01 +0200 Subject: [PATCH] Improve psalm annotation to make it stricter Now using class-string as input will only return T, and any other string will return mixed Signed-off-by: Carl Schwan --- build/psalm-baseline.xml | 1 - lib/public/Server.php | 5 +++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/build/psalm-baseline.xml b/build/psalm-baseline.xml index c35d71a79ae..84030160d7b 100644 --- a/build/psalm-baseline.xml +++ b/build/psalm-baseline.xml @@ -1371,7 +1371,6 @@ - $e->getCode() $e->getCode() diff --git a/lib/public/Server.php b/lib/public/Server.php index be6b6a49236..f4522e8ae10 100644 --- a/lib/public/Server.php +++ b/lib/public/Server.php @@ -41,8 +41,9 @@ use Psr\Container\NotFoundExceptionInterface; final class Server { /** * @template T - * @param class-string|string $serviceName - * @return T|mixed + * @template S as class-string|string + * @param S $serviceName + * @return (S is class-string ? T : mixed) * @throws ContainerExceptionInterface * @throws NotFoundExceptionInterface * @since 25.0.0 -- 2.39.5