diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c67ab2d..7b588a2 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,7 +1,14 @@ name: Continuous Integration on: + pull_request: + branches: + - '*.*.*' + - 'master' push: + branches: + - '*.*.*' + - 'master' workflow_dispatch: jobs: diff --git a/.idea/containers.iml b/.idea/containers.iml index db3a2b7..b54113e 100644 --- a/.idea/containers.iml +++ b/.idea/containers.iml @@ -2,9 +2,7 @@ - - diff --git a/CHANGELOG.md b/CHANGELOG.md index 3236806..379a50a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ### Added - Recursion detection (#13). +### Changed +- Dropped support for `psr/container` v1 in favour of v2 (#29). +- Switched underlying Dhii standards (#29). + ## [0.1.5] - 2024-04-27 ### Fixed - Missing return types causing warnings with PHP 8.1 and higher (#25). diff --git a/composer.json b/composer.json index d468f3a..2903cd0 100644 --- a/composer.json +++ b/composer.json @@ -17,7 +17,7 @@ "prefer-stable": false, "require": { "php": "^7.4 | ^8.0", - "dhii/collections-interface": "^0.3.0-alpha4", + "dhii/collections-interface": "^0.4.0-alpha2", "container-interop/service-provider": "^0.4" }, "require-dev": { @@ -25,7 +25,7 @@ "phpunit/phpunit": "^9.0", "vimeo/psalm": "^5.0", "gmazzap/andrew": "^1.1", - "psr/container": "^1.0", + "psr/container": "^2.0", "psr/simple-cache": "^1.0", "wildwolf/psr-memory-cache": "^1.0" }, @@ -42,11 +42,6 @@ "Dhii\\Container\\TestHelpers\\": "tests/helpers" } }, - "extra": { - "branch-alias": { - "dev-develop": "0.1.x-dev" - } - }, "config": { "allow-plugins": { "dealerdirect/phpcodesniffer-composer-installer": true diff --git a/composer.lock b/composer.lock index cacdc74..36c875e 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "a39fbdfee637c101d92a17cd7bdec485", + "content-hash": "4a0a03723e92b74d821d53755e41aa82", "packages": [ { "name": "container-interop/service-provider", @@ -43,34 +43,29 @@ }, { "name": "dhii/collections-interface", - "version": "dev-develop", + "version": "0.4.x-dev", "source": { "type": "git", "url": "https://github.com/Dhii/collections-interface.git", - "reference": "74464a969b340d16889eacd9eadc9817f7e7f47a" + "reference": "f860c73a3f22b952663ccae7941d36bdd3b4b504" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/Dhii/collections-interface/zipball/74464a969b340d16889eacd9eadc9817f7e7f47a", - "reference": "74464a969b340d16889eacd9eadc9817f7e7f47a", + "url": "https://api.github.com/repos/Dhii/collections-interface/zipball/f860c73a3f22b952663ccae7941d36bdd3b4b504", + "reference": "f860c73a3f22b952663ccae7941d36bdd3b4b504", "shasum": "" }, "require": { - "php": "^7.1 | ^8.0", - "psr/container": "^1.0" + "php": "^7.4 | ^8.0", + "psr/container": "^1.0 | ^2.0" }, "require-dev": { - "phpunit/phpunit": "^7.0 | ^8.0 | ^9.0", + "phpunit/phpunit": "^9.0", "slevomat/coding-standard": "^6.0", - "vimeo/psalm": "^4.0" + "vimeo/psalm": "^4.6.2 | ^5.0" }, "default-branch": true, "type": "library", - "extra": { - "branch-alias": { - "dev-develop": "0.3.x-dev" - } - }, "autoload": { "psr-4": { "Dhii\\Collection\\": "src" @@ -93,28 +88,34 @@ "description": "A highly ISP-compliant collection of interfaces that represent maps and lists.", "support": { "issues": "https://github.com/Dhii/collections-interface/issues", - "source": "https://github.com/Dhii/collections-interface/tree/v0.3.0" + "source": "https://github.com/Dhii/collections-interface/tree/0.4.x" }, - "time": "2021-10-06T10:56:09+00:00" + "time": "2024-09-21T21:40:54+00:00" }, { "name": "psr/container", - "version": "1.x-dev", + "version": "dev-master", "source": { "type": "git", "url": "https://github.com/php-fig/container.git", - "reference": "513e0666f7216c7459170d56df27dfcefe1689ea" + "reference": "707984727bd5b2b670e59559d3ed2500240cf875" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/php-fig/container/zipball/513e0666f7216c7459170d56df27dfcefe1689ea", - "reference": "513e0666f7216c7459170d56df27dfcefe1689ea", + "url": "https://api.github.com/repos/php-fig/container/zipball/707984727bd5b2b670e59559d3ed2500240cf875", + "reference": "707984727bd5b2b670e59559d3ed2500240cf875", "shasum": "" }, "require": { "php": ">=7.4.0" }, + "default-branch": true, "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.0.x-dev" + } + }, "autoload": { "psr-4": { "Psr\\Container\\": "src/" @@ -141,9 +142,9 @@ ], "support": { "issues": "https://github.com/php-fig/container/issues", - "source": "https://github.com/php-fig/container/tree/1.1.2" + "source": "https://github.com/php-fig/container" }, - "time": "2021-11-05T16:50:12+00:00" + "time": "2023-09-22T11:11:30+00:00" } ], "packages-dev": [ @@ -3897,37 +3898,29 @@ }, { "name": "symfony/service-contracts", - "version": "2.5.x-dev", + "version": "v1.1.2", "source": { "type": "git", "url": "https://github.com/symfony/service-contracts.git", - "reference": "351fb560172c6972ffa169f4ffaea6d58a9de33b" + "reference": "191afdcb5804db960d26d8566b7e9a2843cab3a0" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/service-contracts/zipball/351fb560172c6972ffa169f4ffaea6d58a9de33b", - "reference": "351fb560172c6972ffa169f4ffaea6d58a9de33b", + "url": "https://api.github.com/repos/symfony/service-contracts/zipball/191afdcb5804db960d26d8566b7e9a2843cab3a0", + "reference": "191afdcb5804db960d26d8566b7e9a2843cab3a0", "shasum": "" }, "require": { - "php": ">=7.2.5", - "psr/container": "^1.1", - "symfony/deprecation-contracts": "^2.1|^3" - }, - "conflict": { - "ext-psr": "<1.1|>=2" + "php": "^7.1.3" }, "suggest": { + "psr/container": "", "symfony/service-implementation": "" }, "type": "library", "extra": { "branch-alias": { - "dev-main": "2.5-dev" - }, - "thanks": { - "name": "symfony/contracts", - "url": "https://github.com/symfony/contracts" + "dev-master": "1.1-dev" } }, "autoload": { @@ -3960,23 +3953,9 @@ "standards" ], "support": { - "source": "https://github.com/symfony/service-contracts/tree/2.5" + "source": "https://github.com/symfony/service-contracts/tree/v1.1.2" }, - "funding": [ - { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" - } - ], - "time": "2024-04-18T08:26:06+00:00" + "time": "2019-05-28T07:50:59+00:00" }, { "name": "symfony/string", diff --git a/src/AliasingContainer.php b/src/AliasingContainer.php index 0cc59d6..eab1ce6 100644 --- a/src/AliasingContainer.php +++ b/src/AliasingContainer.php @@ -49,23 +49,17 @@ public function __construct(PsrContainerInterface $inner, array $aliases) /** * @inheritdoc - * - * @since [*next-version*] */ - public function get($key) + public function get(string $key) { return $this->inner->get($this->getInnerKey($key)); } /** * @inheritdoc - * - * @since [*next-version*] */ - public function has($key) + public function has(string $key): bool { - $key = (string) $key; - return $this->inner->has($this->getInnerKey($key)); } diff --git a/src/CachingContainer.php b/src/CachingContainer.php index f33e7b7..c4a61ee 100644 --- a/src/CachingContainer.php +++ b/src/CachingContainer.php @@ -39,14 +39,8 @@ public function __construct(PsrContainerInterface $container) /** * {@inheritDoc} */ - public function get($key) + public function get(string $key) { - /** @psalm-suppress RedundantCastGivenDocblockType - * @psalm-suppress RedundantCast - * Will remove when switching to PHP 7.2 and new PSR-11 interfaces - */ - $key = (string) $key; - /** * @psalm-suppress InvalidCatch * The base interface does not extend Throwable, but in fact everything that is possible @@ -76,13 +70,8 @@ public function get($key) /** * {@inheritDoc} */ - public function has($key) + public function has(string $key): bool { - /** @psalm-suppress RedundantCastGivenDocblockType - * Will remove when switching to PHP 7.2 and new PSR-11 interfaces - */ - $key = (string) $key; - /** * @psalm-suppress InvalidCatch * The base interface does not extend Throwable, but in fact everything that is possible diff --git a/src/CompositeContainer.php b/src/CompositeContainer.php index 5d5c1a4..89a2aa5 100644 --- a/src/CompositeContainer.php +++ b/src/CompositeContainer.php @@ -11,8 +11,6 @@ use Exception; use Psr\Container\ContainerInterface as PsrContainerInterface; use Psr\Container\NotFoundExceptionInterface; -use Traversable; -use UnexpectedValueException; class CompositeContainer implements ContainerInterface { @@ -34,14 +32,8 @@ public function __construct(iterable $containers) /** * {@inheritDoc} */ - public function get($key) + public function get(string $key) { - /** @psalm-suppress RedundantCastGivenDocblockType - * @psalm-suppress RedundantCast - * Will remove when switching to PHP 7.2 and new PSR-11 interfaces - */ - $key = (string) $key; - foreach ($this->containers as $index => $container) { /** * @psalm-suppress InvalidCatch @@ -77,13 +69,8 @@ public function get($key) /** * {@inheritDoc} */ - public function has($key) + public function has(string $key): bool { - /** @psalm-suppress RedundantCastGivenDocblockType - * Will remove when switching to PHP 7.2 and new PSR-11 interfaces - */ - $key = (string) $key; - foreach ($this->containers as $index => $container) { try { if ($container->has($key)) { diff --git a/src/DataStructureBasedFactory.php b/src/DataStructureBasedFactory.php index 5e70e58..d1b785f 100644 --- a/src/DataStructureBasedFactory.php +++ b/src/DataStructureBasedFactory.php @@ -5,7 +5,7 @@ namespace Dhii\Container; use Dhii\Collection\WritableMapFactoryInterface; -use Psr\Container\ContainerInterface; +use Dhii\Collection\WritableMapInterface; /** * @inheritDoc @@ -24,7 +24,7 @@ public function __construct(WritableMapFactoryInterface $containerFactory) /** * @inheritDoc */ - public function createContainerFromArray(array $structure): ContainerInterface + public function createContainerFromArray(array $structure): WritableMapInterface { $map = []; foreach ($structure as $key => $value) { diff --git a/src/DataStructureBasedFactoryInterface.php b/src/DataStructureBasedFactoryInterface.php index edec62a..05afa4b 100644 --- a/src/DataStructureBasedFactoryInterface.php +++ b/src/DataStructureBasedFactoryInterface.php @@ -7,7 +7,6 @@ use Dhii\Collection\WritableMapFactoryInterface; use Dhii\Collection\WritableMapInterface; use Exception; -use Psr\Container\ContainerInterface as BaseContainerInterface; /** * Creates a container hierarchy based on a traditional data structure. @@ -23,5 +22,5 @@ interface DataStructureBasedFactoryInterface extends WritableMapFactoryInterface * * @throws Exception If problem creating. */ - public function createContainerFromArray(array $structure): BaseContainerInterface; + public function createContainerFromArray(array $structure): WritableMapInterface; } diff --git a/src/DelegatingContainer.php b/src/DelegatingContainer.php index fa5da2c..0b36cd0 100644 --- a/src/DelegatingContainer.php +++ b/src/DelegatingContainer.php @@ -43,7 +43,7 @@ public function __construct(ServiceProviderInterface $provider, PsrContainerInte /** * {@inheritDoc} */ - public function get($id) + public function get(string $id) { if (array_key_exists($id, $this->stack)) { $trace = implode(' -> ', array_keys($this->stack)) . ' -> ' . $id; @@ -67,10 +67,9 @@ public function get($id) /** * {@inheritDoc} */ - public function has($id) + public function has(string $id): bool { $services = $this->provider->getFactories(); - $id = (string) $id; return array_key_exists($id, $services); } diff --git a/src/DeprefixingContainer.php b/src/DeprefixingContainer.php index 64f55e7..cd41b11 100644 --- a/src/DeprefixingContainer.php +++ b/src/DeprefixingContainer.php @@ -56,10 +56,8 @@ public function __construct(PsrContainerInterface $container, string $prefix, bo /** * @inheritdoc - * - * @since [*next-version*] */ - public function get($key) + public function get(string $key) { /** * @psalm-suppress InvalidCatch @@ -79,12 +77,9 @@ public function get($key) /** * @inheritdoc - * - * @since [*next-version*] */ - public function has($key) + public function has(string $key): bool { - $key = (string) $key; $realKey = $this->getInnerKey($key); return $this->inner->has($realKey) || (!$this->strict && $this->inner->has($key)); @@ -93,8 +88,6 @@ public function has($key) /** * Retrieves the key to use for the inner container. * - * @since [*next-version*] - * * @param string $key The outer key. * * @return string The inner key. diff --git a/src/Dictionary.php b/src/Dictionary.php index 3193c0b..ad7525e 100644 --- a/src/Dictionary.php +++ b/src/Dictionary.php @@ -36,7 +36,7 @@ public function __construct(array $data) /** * {@inheritDoc} */ - public function get($key) + public function get(string $key) { if (!array_key_exists($key, $this->data)) { throw new NotFoundException( @@ -52,10 +52,8 @@ public function get($key) /** * {@inheritDoc} */ - public function has($key) + public function has(string $key): bool { - $key = (string) $key; - $isHas = array_key_exists($key, $this->data); return $isHas; diff --git a/src/DictionaryFactory.php b/src/DictionaryFactory.php index a02ed05..211200e 100644 --- a/src/DictionaryFactory.php +++ b/src/DictionaryFactory.php @@ -5,7 +5,7 @@ namespace Dhii\Container; use Dhii\Collection\WritableMapFactoryInterface; -use Psr\Container\ContainerInterface; +use Dhii\Collection\WritableMapInterface; /** * @inheritDoc @@ -15,7 +15,7 @@ class DictionaryFactory implements WritableMapFactoryInterface /** * @inheritDoc */ - public function createContainerFromArray(array $data): ContainerInterface + public function createContainerFromArray(array $data): WritableMapInterface { return new Dictionary($data); } diff --git a/src/FlashContainer.php b/src/FlashContainer.php index 0418301..6e7bf68 100644 --- a/src/FlashContainer.php +++ b/src/FlashContainer.php @@ -7,7 +7,6 @@ use Dhii\Collection\ClearableContainerInterface; use Dhii\Collection\MutableContainerInterface; use Dhii\Container\Exception\NotFoundException; -use Psr\Container\ContainerExceptionInterface; /** * A container for data that is accessible once per init. @@ -59,10 +58,8 @@ public function init(): void /** * @inheritDoc */ - public function has($key) + public function has(string $key): bool { - $key = (string) $key; - return array_key_exists($key, $this->flashData); } @@ -71,7 +68,7 @@ public function has($key) * * Retrieves the value for the specified key from memory. */ - public function get($key) + public function get(string $key) { if (!array_key_exists($key, $this->flashData)) { throw new NotFoundException(sprintf('Flash data not found for key "%1$s"', $key)); diff --git a/src/HierarchyContainer.php b/src/HierarchyContainer.php index e6a9acb..8f59fb4 100644 --- a/src/HierarchyContainer.php +++ b/src/HierarchyContainer.php @@ -59,10 +59,8 @@ public function __construct(array $data) /** * @inheritDoc - * - * @since [*next-version*] */ - public function get($key) + public function get(string $key) { if (!array_key_exists($key, $this->data)) { throw new NotFoundException("Key '{$key}' does not exist", 0, null); @@ -83,13 +81,9 @@ public function get($key) /** * @inheritDoc - * - * @since [*next-version*] */ - public function has($key) + public function has(string $key): bool { - $key = (string) $key; - return array_key_exists($key, $this->data); } } diff --git a/src/MappingContainer.php b/src/MappingContainer.php index ce5a413..61ceada 100644 --- a/src/MappingContainer.php +++ b/src/MappingContainer.php @@ -34,28 +34,15 @@ */ class MappingContainer implements ContainerInterface { - /* @since [*next-version*] */ use StringTranslatingTrait; - /** - * @since [*next-version*] - * - * @var callable - */ + /** @var callable */ protected $callback; - /** - * @since [*next-version*] - * - * @var PsrContainerInterface - */ + /** @var PsrContainerInterface */ protected $inner; /** - * Constructor. - * - * @since [*next-version*] - * * @param PsrContainerInterface $inner The container instance to decorate. * @param callable $callback The callback to invoke on get. It will be passed 3 parameters: * * The inner container's value for the key being fetched. @@ -70,8 +57,6 @@ public function __construct(PsrContainerInterface $inner, callable $callback) /** * @inheritdoc - * - * @since [*next-version*] */ public function get($key) { @@ -80,13 +65,9 @@ public function get($key) /** * @inheritdoc - * - * @since [*next-version*] */ - public function has($key) + public function has(string $key): bool { - $key = (string) $key; - return $this->inner->has($key); } } diff --git a/src/MaskingContainer.php b/src/MaskingContainer.php index 120e76e..0995f91 100644 --- a/src/MaskingContainer.php +++ b/src/MaskingContainer.php @@ -13,12 +13,9 @@ /** * An implementation of a container that wraps around another to selectively expose or mask certain keys. - * - * @since [*next-version*] */ class MaskingContainer implements ContainerInterface { - /* @since [*next-version*] */ use StringTranslatingTrait; /** @@ -39,8 +36,6 @@ class MaskingContainer implements ContainerInterface /** * Constructor. * - * @since [*next-version*] - * * @param PsrContainerInterface $inner The container whose entries to mask. * @param bool $defaultMask The default mask. If true, all inner keys are exposed. If false, all * inner keys are hidden. Any keys specified in the $mask parameter will @@ -57,10 +52,8 @@ public function __construct(PsrContainerInterface $inner, bool $defaultMask, arr /** * @inheritdoc - * - * @since [*next-version*] */ - public function get($key) + public function get(string $key) { if (!$this->isExposed($key)) { throw new NotFoundException( @@ -75,21 +68,15 @@ public function get($key) /** * @inheritdoc - * - * @since [*next-version*] */ - public function has($key) + public function has(string $key): bool { - $key = (string) $key; - return $this->isExposed($key) && $this->inner->has($key); } /** * Checks if a key is exposed through the mask. * - * @since [*next-version*] - * * @param string $key The key to check. * * @return bool True if the key is exposed, false if the key is hidden. diff --git a/src/NoOpContainer.php b/src/NoOpContainer.php index 5a92d60..ad41c05 100644 --- a/src/NoOpContainer.php +++ b/src/NoOpContainer.php @@ -29,7 +29,7 @@ class NoOpContainer implements /** * @inheritDoc */ - public function get($id) + public function get(string $id) { throw new NotFoundException('NoOp container cannot have values'); } @@ -37,7 +37,7 @@ public function get($id) /** * @inheritDoc */ - public function has($id) + public function has(string $id): bool { return false; } diff --git a/src/PathContainer.php b/src/PathContainer.php index ec14eb4..94138d9 100644 --- a/src/PathContainer.php +++ b/src/PathContainer.php @@ -45,30 +45,17 @@ * Note that this implementation DOES NOT create containers for hierarchical _values_. Each segment in a given path * must correspond to a child {@link ContainerInterface} instance. * - * @since [*next-version*] * @see SegmentingContainer For an implementation that achieves the opposite effect. */ class PathContainer implements ContainerInterface { - /** - * @since [*next-version*] - * - * @var PsrContainerInterface - */ + /** @var PsrContainerInterface */ protected $inner; - /** - * @since [*next-version*] - * - * @var non-empty-string - */ + /** @var non-empty-string */ protected $delimiter; /** - * Constructor. - * - * @since [*next-version*] - * * @param PsrContainerInterface $inner The container instance to decorate. * @param non-empty-string $delimiter The path delimiter to use. */ @@ -80,10 +67,8 @@ public function __construct(PsrContainerInterface $inner, string $delimiter = '/ /** * @inheritDoc - * - * @since [*next-version*] */ - public function get($key) + public function get(string $key) { $tKey = (strpos($key, $this->delimiter) === 0) ? substr($key, strlen($this->delimiter)) @@ -122,13 +107,9 @@ public function get($key) /** * @inheritDoc - * - * @since [*next-version*] */ - public function has($key) + public function has(string $key): bool { - $key = (string) $key; - /** * @psalm-suppress InvalidCatch * The base interface does not extend Throwable, but in fact everything that is possible diff --git a/src/PrefixingContainer.php b/src/PrefixingContainer.php index aa5e36b..1766ec7 100644 --- a/src/PrefixingContainer.php +++ b/src/PrefixingContainer.php @@ -15,37 +15,19 @@ /** * A container implementation that wraps around an inner container and prefixes its keys, requiring consumers to * include them when fetching or looking up data. - * - * @since [*next-version*] */ class PrefixingContainer implements ContainerInterface { - /** - * @since [*next-version*] - * - * @var PsrContainerInterface - */ + /** @var PsrContainerInterface */ protected $inner; - /** - * @since [*next-version*] - * - * @var string - */ + /** @var string */ protected $prefix; - /** - * @since [*next-version*] - * - * @var bool - */ + /** @var bool */ protected $strict; /** - * Constructor. - * - * @since [*next-version*] - * * @param PsrContainerInterface $container The container whose keys to prefix. * @param string $prefix The prefix to apply to the container's keys. * @param bool $strict Whether or not to fallback to un-prefixed keys if a prefixed key does not @@ -60,10 +42,8 @@ public function __construct(PsrContainerInterface $container, string $prefix, bo /** * @inheritdoc - * - * @since [*next-version*] */ - public function get($key) + public function get(string $key) { if (!$this->isPrefixed($key) && $this->strict) { throw new NotFoundException(sprintf('Key "%s" does not exist', $key)); @@ -87,12 +67,9 @@ public function get($key) /** * @inheritdoc - * - * @since [*next-version*] */ - public function has($key) + public function has(string $key): bool { - $key = (string) $key; if (!$this->isPrefixed($key) && $this->strict) { return false; } @@ -109,8 +86,6 @@ public function has($key) /** * Retrieves the key to use for the inner container. * - * @since [*next-version*] - * * @param string $key The outer key. * * @return string The inner key. @@ -125,8 +100,6 @@ protected function unprefix(string $key): string /** * Checks if the key is prefixed. * - * @since [*next-version*] - * * @param string $key The key to check. * * @return bool True if the key is prefixed, false if not. diff --git a/src/ProxyContainer.php b/src/ProxyContainer.php index 7ed89d0..b65e5b7 100644 --- a/src/ProxyContainer.php +++ b/src/ProxyContainer.php @@ -35,7 +35,7 @@ public function __construct(BaseContainerInterface $innerContainer = null) /** * @inheritDoc */ - public function get($key) + public function get(string $key) { if (!($this->innerContainer instanceof BaseContainerInterface)) { throw new ContainerException($this->__('Inner container not set')); @@ -47,7 +47,7 @@ public function get($key) /** * @inheritDoc */ - public function has($key) + public function has(string $key): bool { if (!($this->innerContainer instanceof BaseContainerInterface)) { /** @psalm-suppress MissingThrowsDocblock The exception class implements declared thrown interface */ diff --git a/src/SegmentingContainer.php b/src/SegmentingContainer.php index 7d90215..15639e9 100644 --- a/src/SegmentingContainer.php +++ b/src/SegmentingContainer.php @@ -50,7 +50,6 @@ * $dbConfig->get("port"); // 3306 * ``` * - * @since [*next-version*] * @see PathContainer For an implementation that achieves the opposite effect. */ class SegmentingContainer implements ContainerInterface @@ -87,10 +86,8 @@ public function __construct(PsrContainerInterface $inner, string $delimiter = '/ /** * @inheritdoc - * - * @since [*next-version*] */ - public function get($key) + public function get(string $key) { $tKey = ltrim($key, $this->delimiter); $tRoot = rtrim($this->root, $this->delimiter); @@ -109,13 +106,9 @@ public function get($key) /** * @inheritdoc - * - * @since [*next-version*] */ - public function has($key) + public function has(string $key): bool { - $key = (string) $key; - return $this->inner->has($key); } } diff --git a/src/SimpleCacheContainer.php b/src/SimpleCacheContainer.php index 9b7d98b..392ad51 100644 --- a/src/SimpleCacheContainer.php +++ b/src/SimpleCacheContainer.php @@ -33,7 +33,7 @@ public function __construct(CacheInterface $storage, int $ttl) /** * @inheritDoc */ - public function get($id) + public function get(string $id) { $storage = $this->storage; @@ -53,9 +53,8 @@ public function get($id) /** * @inheritDoc */ - public function has($id) + public function has(string $id): bool { - $id = (string) $id; $storage = $this->storage; try { diff --git a/tests/helpers/ContainerMock.php b/tests/helpers/ContainerMock.php index 47fe581..20dfbca 100644 --- a/tests/helpers/ContainerMock.php +++ b/tests/helpers/ContainerMock.php @@ -36,7 +36,7 @@ public static function nameOfClassToMock() : string * * @since [*next-version*] */ - public function get($id) + public function get(string $id) { return $this->mock->get($id); } @@ -46,7 +46,7 @@ public function get($id) * * @since [*next-version*] */ - public function has($id) + public function has(string $id): bool { return $this->mock->has($id); } @@ -61,7 +61,7 @@ public function has($id) * * @return static */ - public function expectHasService($key, $value) + public function expectHasService(string $key, $value) { $this->mock->method('get') ->with($key) @@ -83,7 +83,7 @@ public function expectHasService($key, $value) * * @return static */ - public function expectNotHasService($key) + public function expectNotHasService(string $key) { $this->mock->method('get') ->with($key)