diff --git a/composer.json b/composer.json
index 996a777d..94d3aa46 100644
--- a/composer.json
+++ b/composer.json
@@ -23,7 +23,7 @@
"require": {
"php": "~8.1.0 || ~8.2.0 || ~8.3.0",
"laminas/laminas-stdlib": "^3.17",
- "psr/container": "^1.0"
+ "psr/container": "^1.1 || ^2.0"
},
"require-dev": {
"composer/package-versions-deprecated": "^1.11.99.5",
@@ -37,9 +37,6 @@
"psalm/plugin-phpunit": "^0.18.4",
"vimeo/psalm": "^5.8.0"
},
- "replace": {
- "container-interop/container-interop": "^1.2.0"
- },
"conflict": {
"ext-psr": "*",
"laminas/laminas-code": "<4.10.0",
@@ -47,7 +44,7 @@
"zendframework/zend-servicemanager": "*"
},
"provide": {
- "psr/container-implementation": "^1.0"
+ "psr/container-implementation": "^1.0 || ^2.0"
},
"suggest": {
"friendsofphp/proxy-manager-lts": "ProxyManager ^2.1.1 to handle lazy initialization of services"
diff --git a/composer.lock b/composer.lock
index 47e7b583..49b77430 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": "9ec9c9a8b4746d56a1f1cc10cc26afbb",
+ "content-hash": "d213b65c02168bf35fe565d019473d02",
"packages": [
{
"name": "laminas/laminas-stdlib",
@@ -67,22 +67,27 @@
},
{
"name": "psr/container",
- "version": "1.1.2",
+ "version": "2.0.2",
"source": {
"type": "git",
"url": "https://github.com/php-fig/container.git",
- "reference": "513e0666f7216c7459170d56df27dfcefe1689ea"
+ "reference": "c71ecc56dfe541dbd90c5360474fbc405f8d5963"
},
"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/c71ecc56dfe541dbd90c5360474fbc405f8d5963",
+ "reference": "c71ecc56dfe541dbd90c5360474fbc405f8d5963",
"shasum": ""
},
"require": {
"php": ">=7.4.0"
},
"type": "library",
+ "extra": {
+ "branch-alias": {
+ "dev-master": "2.0.x-dev"
+ }
+ },
"autoload": {
"psr-4": {
"Psr\\Container\\": "src/"
@@ -109,9 +114,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/tree/2.0.2"
},
- "time": "2021-11-05T16:50:12+00:00"
+ "time": "2021-11-05T16:47:00+00:00"
}
],
"packages-dev": [
@@ -4487,22 +4492,21 @@
},
{
"name": "symfony/service-contracts",
- "version": "v2.5.2",
+ "version": "v3.2.1",
"source": {
"type": "git",
"url": "https://github.com/symfony/service-contracts.git",
- "reference": "4b426aac47d6427cc1a1d0f7e2ac724627f5966c"
+ "reference": "a8c9cedf55f314f3a186041d19537303766df09a"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/symfony/service-contracts/zipball/4b426aac47d6427cc1a1d0f7e2ac724627f5966c",
- "reference": "4b426aac47d6427cc1a1d0f7e2ac724627f5966c",
+ "url": "https://api.github.com/repos/symfony/service-contracts/zipball/a8c9cedf55f314f3a186041d19537303766df09a",
+ "reference": "a8c9cedf55f314f3a186041d19537303766df09a",
"shasum": ""
},
"require": {
- "php": ">=7.2.5",
- "psr/container": "^1.1",
- "symfony/deprecation-contracts": "^2.1|^3"
+ "php": ">=8.1",
+ "psr/container": "^2.0"
},
"conflict": {
"ext-psr": "<1.1|>=2"
@@ -4513,7 +4517,7 @@
"type": "library",
"extra": {
"branch-alias": {
- "dev-main": "2.5-dev"
+ "dev-main": "3.3-dev"
},
"thanks": {
"name": "symfony/contracts",
@@ -4523,7 +4527,10 @@
"autoload": {
"psr-4": {
"Symfony\\Contracts\\Service\\": ""
- }
+ },
+ "exclude-from-classmap": [
+ "/Test/"
+ ]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
@@ -4550,7 +4557,7 @@
"standards"
],
"support": {
- "source": "https://github.com/symfony/service-contracts/tree/v2.5.2"
+ "source": "https://github.com/symfony/service-contracts/tree/v3.2.1"
},
"funding": [
{
@@ -4566,7 +4573,7 @@
"type": "tidelift"
}
],
- "time": "2022-05-30T19:17:29+00:00"
+ "time": "2023-03-01T10:32:47+00:00"
},
{
"name": "symfony/string",
diff --git a/psalm-baseline.xml b/psalm-baseline.xml
index 22164e32..1db8ba30 100644
--- a/psalm-baseline.xml
+++ b/psalm-baseline.xml
@@ -218,10 +218,6 @@
$factory
|null):object)|Factory\FactoryInterface]]>
-
- $name
- $name
-
(bool) $flag
(bool) $flag
diff --git a/src/AbstractPluginManager.php b/src/AbstractPluginManager.php
index 0a652e5e..eb50c662 100644
--- a/src/AbstractPluginManager.php
+++ b/src/AbstractPluginManager.php
@@ -143,7 +143,6 @@ public function setService($name, $service)
/**
* @param class-string|string $name Service name of plugin to retrieve.
- * @param null|array $options Options to use when creating the instance.
* @return mixed
* @psalm-return ($name is class-string ? InstanceType : mixed)
* @throws Exception\ServiceNotFoundException If the manager does not have
@@ -152,7 +151,7 @@ public function setService($name, $service)
* @throws InvalidServiceException If the plugin created is invalid for the
* plugin context.
*/
- public function get($name, ?array $options = null)
+ public function get(string $id): mixed
{
if (! $this->has($name)) {
if (! $this->autoAddInvokableClass || ! class_exists($name)) {
@@ -166,7 +165,7 @@ public function get($name, ?array $options = null)
$this->setFactory($name, Factory\InvokableFactory::class);
}
- $instance = ! $options ? parent::get($name) : $this->build($name, $options);
+ $instance = parent::get($id)
$this->validate($instance);
return $instance;
}
diff --git a/src/ServiceManager.php b/src/ServiceManager.php
index e7d3c706..48951089 100644
--- a/src/ServiceManager.php
+++ b/src/ServiceManager.php
@@ -219,34 +219,34 @@ public function getServiceLocator()
}
/** {@inheritDoc} */
- public function get($name)
+ public function get(string $id): mixed
{
// We start by checking if we have cached the requested service;
// this is the fastest method.
- if (isset($this->services[$name])) {
- return $this->services[$name];
+ if (isset($this->services[$id])) {
+ return $this->services[$id];
}
// Determine if the service should be shared.
- $sharedService = $this->shared[$name] ?? $this->sharedByDefault;
+ $sharedService = $this->shared[$id] ?? $this->sharedByDefault;
// We achieve better performance if we can let all alias
// considerations out.
if (! $this->aliases) {
- $object = $this->doCreate($name);
+ $object = $this->doCreate($id);
// Cache the object for later, if it is supposed to be shared.
if ($sharedService) {
- $this->services[$name] = $object;
+ $this->services[$id] = $object;
}
return $object;
}
// We now deal with requests which may be aliases.
- $resolvedName = $this->aliases[$name] ?? $name;
+ $resolvedName = $this->aliases[$id] ?? $id;
// Update shared service information as we checked if the alias was shared before.
- if ($resolvedName !== $name) {
+ if ($resolvedName !== $id) {
$sharedService = $this->shared[$resolvedName] ?? $sharedService;
}
@@ -255,7 +255,7 @@ public function get($name)
// If the alias is configured as a shared service, we are done.
if ($sharedAlias) {
- $this->services[$name] = $this->services[$resolvedName];
+ $this->services[$id] = $this->services[$resolvedName];
return $this->services[$resolvedName];
}
@@ -271,7 +271,7 @@ public function get($name)
// Also cache under the alias name; this allows sharing based on the
// service name used.
if ($sharedAlias) {
- $this->services[$name] = $object;
+ $this->services[$id] = $object;
}
return $object;
@@ -291,10 +291,10 @@ public function build($name, ?array $options = null)
* @param string|class-string $name
* @return bool
*/
- public function has($name)
+ public function has(string $id): bool
{
// Check static services and factories first to speedup the most common requests.
- return $this->staticServiceOrFactoryCanCreate($name) || $this->abstractFactoryCanCreate($name);
+ return $this->staticServiceOrFactoryCanCreate($id) || $this->abstractFactoryCanCreate($id);
}
/**