-
-
Notifications
You must be signed in to change notification settings - Fork 60
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #127 from boesing/feature/psr-container-2.0
Support for `psr/container` v2
- Loading branch information
Showing
14 changed files
with
320 additions
and
193 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,15 @@ | ||
{ | ||
"ignore_php_platform_requirements": { | ||
"8.1": true | ||
} | ||
}, | ||
"additional_checks": [ | ||
{ | ||
"name": "Psalm for psr/container v1", | ||
"job": { | ||
"php": "@lowest", | ||
"dependencies": "locked", | ||
"command": "composer require -W psr/container:^1 && vendor/bin/psalm --stats --output-format=github --no-cache" | ||
} | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Laminas\ServiceManager; | ||
|
||
use Psr\Container\ContainerExceptionInterface; | ||
use Psr\Container\ContainerInterface; | ||
use Psr\Container\NotFoundExceptionInterface; | ||
|
||
/** | ||
* This class is not meant to be used outside this component. | ||
* We only provide this class to polyfill both `psr/container` v1 & v2. | ||
* | ||
* @psalm-require-extends ServiceManager | ||
*/ | ||
abstract class AbstractTypedContainerImplementation implements ContainerInterface | ||
{ | ||
/** | ||
* Returns true if the container can return an entry for the given identifier. | ||
* Returns false otherwise. | ||
* | ||
* `has($id)` returning true does not mean that `get($id)` will not throw an exception. | ||
* It does however mean that `get($id)` will not throw a `NotFoundExceptionInterface`. | ||
* | ||
* @psalm-param string|class-string $id | ||
*/ | ||
public function has(string $id): bool | ||
{ | ||
return $this->hasService($id); | ||
} | ||
|
||
/** | ||
* Finds an entry of the container by its identifier and returns it. | ||
* | ||
* @param string $id Identifier of the entry to look for. | ||
* @psalm-param string|class-string $id | ||
* @throws NotFoundExceptionInterface No entry was found for **this** identifier. | ||
* @throws ContainerExceptionInterface Error while retrieving the entry. | ||
* @return mixed Entry. | ||
*/ | ||
public function get(string $id) | ||
{ | ||
return $this->getService($id); | ||
} | ||
|
||
/** | ||
* @internal | ||
* | ||
* @psalm-param string|class-string $name | ||
*/ | ||
abstract protected function hasService(string $name): bool; | ||
|
||
/** | ||
* @internal | ||
* | ||
* @psalm-param string|class-string $name | ||
* @throws NotFoundExceptionInterface No entry was found for **this** identifier. | ||
* @throws ContainerExceptionInterface Error while retrieving the entry. | ||
* @return mixed | ||
*/ | ||
abstract protected function getService(string $name); | ||
} |
Oops, something went wrong.