From 74517902c470c1f2c59919aad610d67472b86bb5 Mon Sep 17 00:00:00 2001 From: Baptiste Langlade Date: Thu, 1 Aug 2024 14:10:17 +0200 Subject: [PATCH 1/4] fix psalm errors --- CHANGELOG.md | 6 ++++++ src/Http/To.php | 4 ++++ 2 files changed, 10 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index a6906d4..db44ca3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # Changelog +## [Unreleased] + +### Fixed + +- `Innmind\Framework\Http\To` no longer raise Psalm errors when used as argument to `Framework::route()` + ## 2.2.0 - 2024-03-24 ### Added diff --git a/src/Http/To.php b/src/Http/To.php index 012f9cb..ce32335 100644 --- a/src/Http/To.php +++ b/src/Http/To.php @@ -3,11 +3,13 @@ namespace Innmind\Framework\Http; +use Innmind\Framework\Environment; use Innmind\Http\{ ServerRequest, Response, }; use Innmind\DI\Container; +use Innmind\OperatingSystem\OperatingSystem; use Innmind\Router\Route\Variables; final class To @@ -23,6 +25,8 @@ public function __invoke( ServerRequest $request, Variables $variables, Container $container, + OperatingSystem $os = null, // these arguments are not used, there here + Environment $env = null, // to satisfy Psalm when used in Framework::route() ): Response { /** * @psalm-suppress InvalidFunctionCall If it fails here then the service doesn't conform to the signature callable(ServerRequest, Variables): Response From 88b1668891344b119fe27f1730b7a5acb96d7a55 Mon Sep 17 00:00:00 2001 From: Baptiste Langlade Date: Thu, 1 Aug 2024 14:11:48 +0200 Subject: [PATCH 2/4] fix class name in changelog --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index db44ca3..ca34977 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,7 +4,7 @@ ### Fixed -- `Innmind\Framework\Http\To` no longer raise Psalm errors when used as argument to `Framework::route()` +- `Innmind\Framework\Http\To` no longer raise Psalm errors when used as argument to `Application::route()` ## 2.2.0 - 2024-03-24 From d9f17e8c952ae9ab8909011780e7453b1ffed091 Mon Sep 17 00:00:00 2001 From: Baptiste Langlade Date: Thu, 1 Aug 2024 14:28:50 +0200 Subject: [PATCH 3/4] allow to use Service references everywhere --- CHANGELOG.md | 4 ++++ src/Cli/Command/Defer.php | 9 ++++++--- src/Http/Service.php | 11 +++++++---- src/Http/To.php | 11 +++++++---- 4 files changed, 24 insertions(+), 11 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ca34977..b3f4ca2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ ## [Unreleased] +### Added + +- `Innmind\DI\Service` can now be used everywhere a service can be referenced + ### Fixed - `Innmind\Framework\Http\To` no longer raise Psalm errors when used as argument to `Application::route()` diff --git a/src/Cli/Command/Defer.php b/src/Cli/Command/Defer.php index 44e1243..ff32142 100644 --- a/src/Cli/Command/Defer.php +++ b/src/Cli/Command/Defer.php @@ -7,14 +7,17 @@ Command, Console, }; -use Innmind\DI\Container; +use Innmind\DI\{ + Container, + Service, +}; /** * @internal */ final class Defer implements Command { - private string $service; + private string|Service $service; private Container $locate; /** @var callable(Command): Command */ private $map; @@ -24,7 +27,7 @@ final class Defer implements Command * @param callable(Command): Command $map */ public function __construct( - string $service, + string|Service $service, Container $locate, callable $map, ) { diff --git a/src/Http/Service.php b/src/Http/Service.php index b29716c..f974f19 100644 --- a/src/Http/Service.php +++ b/src/Http/Service.php @@ -7,15 +7,18 @@ ServerRequest, Response, }; -use Innmind\DI\Container; +use Innmind\DI\{ + Container, + Service as Ref, +}; use Innmind\Router\Route\Variables; final class Service { private Container $container; - private string $service; + private string|Ref $service; - private function __construct(Container $container, string $service) + private function __construct(Container $container, string|Ref $service) { $this->container = $container; $this->service = $service; @@ -30,7 +33,7 @@ public function __invoke(ServerRequest $request, Variables $variables): Response return ($this->container)($this->service)($request, $variables); } - public static function of(Container $container, string $service): self + public static function of(Container $container, string|Ref $service): self { return new self($container, $service); } diff --git a/src/Http/To.php b/src/Http/To.php index ce32335..888b15a 100644 --- a/src/Http/To.php +++ b/src/Http/To.php @@ -8,15 +8,18 @@ ServerRequest, Response, }; -use Innmind\DI\Container; +use Innmind\DI\{ + Container, + Service, +}; use Innmind\OperatingSystem\OperatingSystem; use Innmind\Router\Route\Variables; final class To { - private string $service; + private string|Service $service; - private function __construct(string $service) + private function __construct(string|Service $service) { $this->service = $service; } @@ -35,7 +38,7 @@ public function __invoke( return $container($this->service)($request, $variables); } - public static function service(string $service): self + public static function service(string|Service $service): self { return new self($service); } From e723eb46db81f535902086f1d17066acbfedd236 Mon Sep 17 00:00:00 2001 From: Baptiste Langlade Date: Thu, 1 Aug 2024 14:35:19 +0200 Subject: [PATCH 4/4] specify next release --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b3f4ca2..d7452ac 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,6 @@ # Changelog -## [Unreleased] +## 2.3.0 - 2024-08-01 ### Added