Skip to content

Commit a8ce109

Browse files
committed
Align signatures with Container Interop v2
1 parent e0a2bd2 commit a8ce109

20 files changed

+47
-181
lines changed

src/AliasingContainer.php

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -49,23 +49,17 @@ public function __construct(PsrContainerInterface $inner, array $aliases)
4949

5050
/**
5151
* @inheritdoc
52-
*
53-
* @since [*next-version*]
5452
*/
55-
public function get($key)
53+
public function get(string $key)
5654
{
5755
return $this->inner->get($this->getInnerKey($key));
5856
}
5957

6058
/**
6159
* @inheritdoc
62-
*
63-
* @since [*next-version*]
6460
*/
65-
public function has($key)
61+
public function has(string $key): bool
6662
{
67-
$key = (string) $key;
68-
6963
return $this->inner->has($this->getInnerKey($key));
7064
}
7165

src/CachingContainer.php

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,8 @@ public function __construct(PsrContainerInterface $container)
3939
/**
4040
* {@inheritDoc}
4141
*/
42-
public function get($key)
42+
public function get(string $key)
4343
{
44-
/** @psalm-suppress RedundantCastGivenDocblockType
45-
* @psalm-suppress RedundantCast
46-
* Will remove when switching to PHP 7.2 and new PSR-11 interfaces
47-
*/
48-
$key = (string) $key;
49-
5044
/**
5145
* @psalm-suppress InvalidCatch
5246
* The base interface does not extend Throwable, but in fact everything that is possible
@@ -76,13 +70,8 @@ public function get($key)
7670
/**
7771
* {@inheritDoc}
7872
*/
79-
public function has($key)
73+
public function has(string $key): bool
8074
{
81-
/** @psalm-suppress RedundantCastGivenDocblockType
82-
* Will remove when switching to PHP 7.2 and new PSR-11 interfaces
83-
*/
84-
$key = (string) $key;
85-
8675
/**
8776
* @psalm-suppress InvalidCatch
8877
* The base interface does not extend Throwable, but in fact everything that is possible

src/CompositeContainer.php

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@
1111
use Exception;
1212
use Psr\Container\ContainerInterface as PsrContainerInterface;
1313
use Psr\Container\NotFoundExceptionInterface;
14-
use Traversable;
15-
use UnexpectedValueException;
1614

1715
class CompositeContainer implements ContainerInterface
1816
{
@@ -34,14 +32,8 @@ public function __construct(iterable $containers)
3432
/**
3533
* {@inheritDoc}
3634
*/
37-
public function get($key)
35+
public function get(string $key)
3836
{
39-
/** @psalm-suppress RedundantCastGivenDocblockType
40-
* @psalm-suppress RedundantCast
41-
* Will remove when switching to PHP 7.2 and new PSR-11 interfaces
42-
*/
43-
$key = (string) $key;
44-
4537
foreach ($this->containers as $index => $container) {
4638
/**
4739
* @psalm-suppress InvalidCatch
@@ -77,13 +69,8 @@ public function get($key)
7769
/**
7870
* {@inheritDoc}
7971
*/
80-
public function has($key)
72+
public function has(string $key): bool
8173
{
82-
/** @psalm-suppress RedundantCastGivenDocblockType
83-
* Will remove when switching to PHP 7.2 and new PSR-11 interfaces
84-
*/
85-
$key = (string) $key;
86-
8774
foreach ($this->containers as $index => $container) {
8875
try {
8976
if ($container->has($key)) {

src/DataStructureBasedFactory.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
namespace Dhii\Container;
66

77
use Dhii\Collection\WritableMapFactoryInterface;
8-
use Psr\Container\ContainerInterface;
8+
use Dhii\Collection\WritableMapInterface;
99

1010
/**
1111
* @inheritDoc
@@ -24,7 +24,7 @@ public function __construct(WritableMapFactoryInterface $containerFactory)
2424
/**
2525
* @inheritDoc
2626
*/
27-
public function createContainerFromArray(array $structure): ContainerInterface
27+
public function createContainerFromArray(array $structure): WritableMapInterface
2828
{
2929
$map = [];
3030
foreach ($structure as $key => $value) {

src/DataStructureBasedFactoryInterface.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
use Dhii\Collection\WritableMapFactoryInterface;
88
use Dhii\Collection\WritableMapInterface;
99
use Exception;
10-
use Psr\Container\ContainerInterface as BaseContainerInterface;
1110

1211
/**
1312
* Creates a container hierarchy based on a traditional data structure.
@@ -23,5 +22,5 @@ interface DataStructureBasedFactoryInterface extends WritableMapFactoryInterface
2322
*
2423
* @throws Exception If problem creating.
2524
*/
26-
public function createContainerFromArray(array $structure): BaseContainerInterface;
25+
public function createContainerFromArray(array $structure): WritableMapInterface;
2726
}

src/DelegatingContainer.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public function __construct(ServiceProviderInterface $provider, PsrContainerInte
4343
/**
4444
* {@inheritDoc}
4545
*/
46-
public function get($id)
46+
public function get(string $id)
4747
{
4848
if (array_key_exists($id, $this->stack)) {
4949
$trace = implode(' -> ', array_keys($this->stack)) . ' -> ' . $id;
@@ -67,10 +67,9 @@ public function get($id)
6767
/**
6868
* {@inheritDoc}
6969
*/
70-
public function has($id)
70+
public function has(string $id): bool
7171
{
7272
$services = $this->provider->getFactories();
73-
$id = (string) $id;
7473

7574
return array_key_exists($id, $services);
7675
}

src/DeprefixingContainer.php

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,8 @@ public function __construct(PsrContainerInterface $container, string $prefix, bo
5656

5757
/**
5858
* @inheritdoc
59-
*
60-
* @since [*next-version*]
6159
*/
62-
public function get($key)
60+
public function get(string $key)
6361
{
6462
/**
6563
* @psalm-suppress InvalidCatch
@@ -79,12 +77,9 @@ public function get($key)
7977

8078
/**
8179
* @inheritdoc
82-
*
83-
* @since [*next-version*]
8480
*/
85-
public function has($key)
81+
public function has(string $key): bool
8682
{
87-
$key = (string) $key;
8883
$realKey = $this->getInnerKey($key);
8984

9085
return $this->inner->has($realKey) || (!$this->strict && $this->inner->has($key));
@@ -93,8 +88,6 @@ public function has($key)
9388
/**
9489
* Retrieves the key to use for the inner container.
9590
*
96-
* @since [*next-version*]
97-
*
9891
* @param string $key The outer key.
9992
*
10093
* @return string The inner key.

src/Dictionary.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public function __construct(array $data)
3636
/**
3737
* {@inheritDoc}
3838
*/
39-
public function get($key)
39+
public function get(string $key)
4040
{
4141
if (!array_key_exists($key, $this->data)) {
4242
throw new NotFoundException(
@@ -52,10 +52,8 @@ public function get($key)
5252
/**
5353
* {@inheritDoc}
5454
*/
55-
public function has($key)
55+
public function has(string $key): bool
5656
{
57-
$key = (string) $key;
58-
5957
$isHas = array_key_exists($key, $this->data);
6058

6159
return $isHas;

src/DictionaryFactory.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
namespace Dhii\Container;
66

77
use Dhii\Collection\WritableMapFactoryInterface;
8-
use Psr\Container\ContainerInterface;
8+
use Dhii\Collection\WritableMapInterface;
99

1010
/**
1111
* @inheritDoc
@@ -15,7 +15,7 @@ class DictionaryFactory implements WritableMapFactoryInterface
1515
/**
1616
* @inheritDoc
1717
*/
18-
public function createContainerFromArray(array $data): ContainerInterface
18+
public function createContainerFromArray(array $data): WritableMapInterface
1919
{
2020
return new Dictionary($data);
2121
}

src/FlashContainer.php

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
use Dhii\Collection\ClearableContainerInterface;
88
use Dhii\Collection\MutableContainerInterface;
99
use Dhii\Container\Exception\NotFoundException;
10-
use Psr\Container\ContainerExceptionInterface;
1110

1211
/**
1312
* A container for data that is accessible once per init.
@@ -59,10 +58,8 @@ public function init(): void
5958
/**
6059
* @inheritDoc
6160
*/
62-
public function has($key)
61+
public function has(string $key): bool
6362
{
64-
$key = (string) $key;
65-
6663
return array_key_exists($key, $this->flashData);
6764
}
6865

@@ -71,7 +68,7 @@ public function has($key)
7168
*
7269
* Retrieves the value for the specified key from memory.
7370
*/
74-
public function get($key)
71+
public function get(string $key)
7572
{
7673
if (!array_key_exists($key, $this->flashData)) {
7774
throw new NotFoundException(sprintf('Flash data not found for key "%1$s"', $key));

0 commit comments

Comments
 (0)