This repository was archived by the owner on Feb 17, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +92
-0
lines changed
Expand file tree Collapse file tree 2 files changed +92
-0
lines changed Original file line number Diff line number Diff line change 1+ <?php
2+
3+ declare (strict_types=1 );
4+
5+ namespace ReactParallel \Psr11ContainerProxy ;
6+
7+ use ReactParallel \ObjectProxy \ProxyListInterface ;
8+
9+ final class OverridesProvider
10+ {
11+ private ProxyListInterface $ proxyList ;
12+
13+ public function __construct (ProxyListInterface $ proxyList )
14+ {
15+ $ this ->proxyList = $ proxyList ;
16+ }
17+
18+ /**
19+ * @return iterable<string>
20+ */
21+ public function list (): iterable
22+ {
23+ $ list = [];
24+
25+ foreach ($ this ->proxyList ->interfaces () as $ interface ) {
26+ $ list [$ interface ] = $ interface ;
27+ }
28+
29+ foreach ($ this ->proxyList ->noPromiseKnownInterfaces () as $ noPromiseInterface => $ interface ) {
30+ $ list [$ noPromiseInterface ] = $ interface ;
31+ }
32+
33+ yield from $ list ;
34+ }
35+ }
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ declare (strict_types=1 );
4+
5+ namespace ReactParallel \Tests \Psr11ContainerProxy ;
6+
7+ use ReactParallel \ObjectProxy \ProxyList \Proxy ;
8+ use ReactParallel \ObjectProxy \ProxyListInterface ;
9+ use ReactParallel \Psr11ContainerProxy \OverridesProvider ;
10+ use WyriHaximus \AsyncTestUtilities \AsyncTestCase ;
11+
12+ use function WyriHaximus \iteratorOrArrayToArray ;
13+
14+ final class OverridesProviderTest extends AsyncTestCase
15+ {
16+ /**
17+ * @test
18+ */
19+ public function list (): void
20+ {
21+ $ proxyList = new class () implements ProxyListInterface {
22+ public function has (string $ interface ): bool
23+ {
24+ return false ;
25+ }
26+
27+ public function get (string $ interface ): Proxy
28+ {
29+ return new Proxy ($ interface , $ interface );
30+ }
31+
32+ /**
33+ * @return iterable<string, string>
34+ */
35+ public function interfaces (): iterable
36+ {
37+ yield 'pizza ' => 'fungi ' ;
38+ yield 'pancake ' => 'pancake ' ;
39+ }
40+
41+ /**
42+ * @return array<string, string>
43+ */
44+ public function noPromiseKnownInterfaces (): array
45+ {
46+ return ['pancake ' => 'cheese union ' ];
47+ }
48+ };
49+
50+ $ list = iteratorOrArrayToArray ((new OverridesProvider ($ proxyList ))->list ());
51+
52+ self ::assertSame ([
53+ 'fungi ' => 'fungi ' ,
54+ 'pancake ' => 'cheese union ' ,
55+ ], $ list );
56+ }
57+ }
You can’t perform that action at this time.
0 commit comments