Skip to content

Commit 047342c

Browse files
authored
Merge pull request #31 from Dhii/feature/upgrade-container-interop
2 parents c49c78c + 9ca43cf commit 047342c

25 files changed

+92
-245
lines changed

.github/workflows/ci.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,14 @@
11
name: Continuous Integration
22

33
on:
4+
pull_request:
5+
branches:
6+
- '*.*.*'
7+
- 'master'
48
push:
9+
branches:
10+
- '*.*.*'
11+
- 'master'
512
workflow_dispatch:
613

714
jobs:

.idea/containers.iml

Lines changed: 0 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
88
### Added
99
- Recursion detection (#13).
1010

11+
### Changed
12+
- Dropped support for `psr/container` v1 in favour of v2 (#29).
13+
- Switched underlying Dhii standards (#29).
14+
1115
## [0.1.5] - 2024-04-27
1216
### Fixed
1317
- Missing return types causing warnings with PHP 8.1 and higher (#25).

composer.json

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,15 @@
1717
"prefer-stable": false,
1818
"require": {
1919
"php": "^7.4 | ^8.0",
20-
"dhii/collections-interface": "^0.3.0-alpha4",
20+
"dhii/collections-interface": "^0.4.0-alpha2",
2121
"container-interop/service-provider": "^0.4"
2222
},
2323
"require-dev": {
2424
"slevomat/coding-standard": "^6.0",
2525
"phpunit/phpunit": "^9.0",
2626
"vimeo/psalm": "^5.0",
2727
"gmazzap/andrew": "^1.1",
28-
"psr/container": "^1.0",
28+
"psr/container": "^2.0",
2929
"psr/simple-cache": "^1.0",
3030
"wildwolf/psr-memory-cache": "^1.0"
3131
},
@@ -42,11 +42,6 @@
4242
"Dhii\\Container\\TestHelpers\\": "tests/helpers"
4343
}
4444
},
45-
"extra": {
46-
"branch-alias": {
47-
"dev-develop": "0.1.x-dev"
48-
}
49-
},
5045
"config": {
5146
"allow-plugins": {
5247
"dealerdirect/phpcodesniffer-composer-installer": true

composer.lock

Lines changed: 32 additions & 53 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

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
}

0 commit comments

Comments
 (0)