Skip to content

Commit 68ce0e5

Browse files
committed
Merge branch 'develop'
* develop: specify next release allow to use Service references everywhere fix class name in changelog fix psalm errors
2 parents e37a516 + e723eb4 commit 68ce0e5

4 files changed

Lines changed: 34 additions & 11 deletions

File tree

CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
11
# Changelog
22

3+
## 2.3.0 - 2024-08-01
4+
5+
### Added
6+
7+
- `Innmind\DI\Service` can now be used everywhere a service can be referenced
8+
9+
### Fixed
10+
11+
- `Innmind\Framework\Http\To` no longer raise Psalm errors when used as argument to `Application::route()`
12+
313
## 2.2.0 - 2024-03-24
414

515
### Added

src/Cli/Command/Defer.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,17 @@
77
Command,
88
Console,
99
};
10-
use Innmind\DI\Container;
10+
use Innmind\DI\{
11+
Container,
12+
Service,
13+
};
1114

1215
/**
1316
* @internal
1417
*/
1518
final class Defer implements Command
1619
{
17-
private string $service;
20+
private string|Service $service;
1821
private Container $locate;
1922
/** @var callable(Command): Command */
2023
private $map;
@@ -24,7 +27,7 @@ final class Defer implements Command
2427
* @param callable(Command): Command $map
2528
*/
2629
public function __construct(
27-
string $service,
30+
string|Service $service,
2831
Container $locate,
2932
callable $map,
3033
) {

src/Http/Service.php

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,18 @@
77
ServerRequest,
88
Response,
99
};
10-
use Innmind\DI\Container;
10+
use Innmind\DI\{
11+
Container,
12+
Service as Ref,
13+
};
1114
use Innmind\Router\Route\Variables;
1215

1316
final class Service
1417
{
1518
private Container $container;
16-
private string $service;
19+
private string|Ref $service;
1720

18-
private function __construct(Container $container, string $service)
21+
private function __construct(Container $container, string|Ref $service)
1922
{
2023
$this->container = $container;
2124
$this->service = $service;
@@ -30,7 +33,7 @@ public function __invoke(ServerRequest $request, Variables $variables): Response
3033
return ($this->container)($this->service)($request, $variables);
3134
}
3235

33-
public static function of(Container $container, string $service): self
36+
public static function of(Container $container, string|Ref $service): self
3437
{
3538
return new self($container, $service);
3639
}

src/Http/To.php

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,23 @@
33

44
namespace Innmind\Framework\Http;
55

6+
use Innmind\Framework\Environment;
67
use Innmind\Http\{
78
ServerRequest,
89
Response,
910
};
10-
use Innmind\DI\Container;
11+
use Innmind\DI\{
12+
Container,
13+
Service,
14+
};
15+
use Innmind\OperatingSystem\OperatingSystem;
1116
use Innmind\Router\Route\Variables;
1217

1318
final class To
1419
{
15-
private string $service;
20+
private string|Service $service;
1621

17-
private function __construct(string $service)
22+
private function __construct(string|Service $service)
1823
{
1924
$this->service = $service;
2025
}
@@ -23,6 +28,8 @@ public function __invoke(
2328
ServerRequest $request,
2429
Variables $variables,
2530
Container $container,
31+
OperatingSystem $os = null, // these arguments are not used, there here
32+
Environment $env = null, // to satisfy Psalm when used in Framework::route()
2633
): Response {
2734
/**
2835
* @psalm-suppress InvalidFunctionCall If it fails here then the service doesn't conform to the signature callable(ServerRequest, Variables): Response
@@ -31,7 +38,7 @@ public function __invoke(
3138
return $container($this->service)($request, $variables);
3239
}
3340

34-
public static function service(string $service): self
41+
public static function service(string|Service $service): self
3542
{
3643
return new self($service);
3744
}

0 commit comments

Comments
 (0)