MDL-83401 core: Upgrade PHP-DI to 7.0.7

This commit is contained in:
Andrew Nicols
2025-01-29 11:56:03 +08:00
parent bcf06a0484
commit 75dedf1d87
20 changed files with 29 additions and 27 deletions
+2 -2
View File
@@ -27,10 +27,10 @@
"php": ">=8.0",
"psr/container": "^1.1 || ^2.0",
"php-di/invoker": "^2.0",
"laravel/serializable-closure": "^1.0"
"laravel/serializable-closure": "^1.0 || ^2.0"
},
"require-dev": {
"phpunit/phpunit": "^9.5",
"phpunit/phpunit": "^9.6",
"mnapoli/phpunit-easymock": "^1.3",
"friendsofphp/proxy-manager-lts": "^1",
"friendsofphp/php-cs-fixer": "^3",
+2 -1
View File
@@ -46,7 +46,8 @@ abstract class CompiledContainer extends Container
if ($method !== null) {
// Check if we are already getting this entry -> circular dependency
if (isset($this->entriesBeingResolved[$id])) {
throw new DependencyException("Circular dependency detected while trying to resolve entry '$id'");
$idList = implode(" -> ", [...array_keys($this->entriesBeingResolved), $id]);
throw new DependencyException("Circular dependency detected while trying to resolve entry '$id': Dependencies: " . $idList);
}
$this->entriesBeingResolved[$id] = true;
+4 -3
View File
@@ -89,8 +89,8 @@ class Container implements ContainerInterface, FactoryInterface, InvokerInterfac
*/
public function __construct(
array|MutableDefinitionSource $definitions = [],
ProxyFactory $proxyFactory = null,
ContainerInterface $wrapperContainer = null
?ProxyFactory $proxyFactory = null,
?ContainerInterface $wrapperContainer = null
) {
if (is_array($definitions)) {
$this->definitionSource = $this->createDefaultDefinitionSource($definitions);
@@ -344,7 +344,8 @@ class Container implements ContainerInterface, FactoryInterface, InvokerInterfac
// Check if we are already getting this entry -> circular dependency
if (isset($this->entriesBeingResolved[$entryName])) {
throw new DependencyException("Circular dependency detected while trying to resolve entry '$entryName'");
$entryList = implode(" -> ", [...array_keys($this->entriesBeingResolved), $entryName]);
throw new DependencyException("Circular dependency detected while trying to resolve entry '$entryName': Dependencies: " . $entryList);
}
$this->entriesBeingResolved[$entryName] = true;
+1 -1
View File
@@ -238,7 +238,7 @@ class ContainerBuilder
* @return $this
* @throws InvalidArgumentException when writeToFile is set to true and the proxy directory is null
*/
public function writeProxiesToFile(bool $writeToFile, string $proxyDirectory = null) : self
public function writeProxiesToFile(bool $writeToFile, ?string $proxyDirectory = null) : self
{
$this->ensureNotLocked();
@@ -14,7 +14,7 @@ use Psr\Container\ContainerExceptionInterface;
*/
class InvalidDefinition extends \Exception implements ContainerExceptionInterface
{
public static function create(Definition $definition, string $message, \Exception $previous = null) : self
public static function create(Definition $definition, string $message, ?\Exception $previous = null) : self
{
return new self(sprintf(
'%s' . \PHP_EOL . 'Full definition:' . \PHP_EOL . '%s',
@@ -43,7 +43,7 @@ class CreateDefinitionHelper implements DefinitionHelper
* @param string|null $className Class name of the object.
* If null, the name of the entry (in the container) will be used as class name.
*/
public function __construct(string $className = null)
public function __construct(?string $className = null)
{
$this->className = $className;
}
@@ -52,7 +52,7 @@ class ObjectDefinition implements Definition
/**
* @param string $name Entry name
*/
public function __construct(string $name, string $className = null)
public function __construct(string $name, ?string $className = null)
{
$this->name = $name;
$this->setClassName($className);
@@ -159,7 +159,7 @@ class ObjectDefinition implements Definition
}
}
public function setLazy(bool $lazy = null) : void
public function setLazy(?bool $lazy = null) : void
{
$this->lazy = $lazy;
}
@@ -29,7 +29,7 @@ class PropertyInjection
* @param string $propertyName Property name
* @param mixed $value Value that should be injected in the property
*/
public function __construct(string $propertyName, mixed $value, string $className = null)
public function __construct(string $propertyName, mixed $value, ?string $className = null)
{
$this->propertyName = $propertyName;
$this->value = $value;
@@ -31,8 +31,8 @@ class ParameterResolver
* @throws InvalidDefinition A parameter has no value defined or guessable.
*/
public function resolveParameters(
MethodInjection $definition = null,
ReflectionMethod $method = null,
?MethodInjection $definition = null,
?ReflectionMethod $method = null,
array $parameters = [],
) : array {
$args = [];
@@ -31,7 +31,7 @@ class AttributeBasedAutowiring implements DefinitionSource, Autowiring
/**
* @throws InvalidAttribute
*/
public function autowire(string $name, ObjectDefinition $definition = null) : ObjectDefinition|null
public function autowire(string $name, ?ObjectDefinition $definition = null) : ObjectDefinition|null
{
$className = $definition ? $definition->getClassName() : $name;
@@ -92,7 +92,7 @@ class AttributeBasedAutowiring implements DefinitionSource, Autowiring
/**
* @throws InvalidAttribute
*/
private function readProperty(ReflectionProperty $property, ObjectDefinition $definition, string $classname = null) : void
private function readProperty(ReflectionProperty $property, ObjectDefinition $definition, ?string $classname = null) : void
{
if ($property->isStatic() || $property->isPromoted()) {
return;
@@ -19,5 +19,5 @@ interface Autowiring
*
* @throws InvalidDefinition An invalid definition was found.
*/
public function autowire(string $name, ObjectDefinition $definition = null) : ObjectDefinition|null;
public function autowire(string $name, ?ObjectDefinition $definition = null) : ObjectDefinition|null;
}
@@ -27,7 +27,7 @@ class DefinitionArray implements DefinitionSource, MutableDefinitionSource
private DefinitionNormalizer $normalizer;
public function __construct(array $definitions = [], Autowiring $autowiring = null)
public function __construct(array $definitions = [], ?Autowiring $autowiring = null)
{
if (isset($definitions[0])) {
throw new \Exception('The PHP-DI definition is not indexed by an entry name in the definition array');
@@ -20,7 +20,7 @@ class DefinitionFile extends DefinitionArray
*/
public function __construct(
private string $file,
Autowiring $autowiring = null,
?Autowiring $autowiring = null,
) {
// Lazy-loading to improve performances
parent::__construct([], $autowiring);
@@ -37,7 +37,7 @@ class DefinitionNormalizer
*
* @throws InvalidDefinition
*/
public function normalizeRootDefinition(mixed $definition, string $name, array $wildcardsReplacements = null) : Definition
public function normalizeRootDefinition(mixed $definition, string $name, ?array $wildcardsReplacements = null) : Definition
{
if ($definition instanceof DefinitionHelper) {
$definition = $definition->getDefinition($name);
@@ -14,7 +14,7 @@ use DI\Definition\ObjectDefinition;
*/
class NoAutowiring implements Autowiring
{
public function autowire(string $name, ObjectDefinition $definition = null) : ObjectDefinition|null
public function autowire(string $name, ?ObjectDefinition $definition = null) : ObjectDefinition|null
{
throw new InvalidDefinition(sprintf(
'Cannot autowire entry "%s" because autowiring is disabled',
@@ -16,7 +16,7 @@ use ReflectionNamedType;
*/
class ReflectionBasedAutowiring implements DefinitionSource, Autowiring
{
public function autowire(string $name, ObjectDefinition $definition = null) : ObjectDefinition|null
public function autowire(string $name, ?ObjectDefinition $definition = null) : ObjectDefinition|null
{
$className = $definition ? $definition->getClassName() : $name;
@@ -64,7 +64,7 @@ class SourceCache implements DefinitionSource, MutableDefinitionSource
throw new \LogicException('You cannot set a definition at runtime on a container that has caching enabled. Doing so would risk caching the definition for the next execution, where it might be different. You can either put your definitions in a file, remove the cache or ->set() a raw value directly (PHP object, string, int, ...) instead of a PHP-DI definition.');
}
private function shouldBeCached(Definition $definition = null) : bool
private function shouldBeCached(?Definition $definition = null) : bool
{
return
// Cache missing definitions
+1 -1
View File
@@ -16,7 +16,7 @@ use ProxyManager\Proxy\LazyLoadingInterface;
*
* Wraps Ocramius/ProxyManager LazyLoadingValueHolderFactory.
*
* @see \ProxyManager\Factory\LazyLoadingValueHolderFactory
* @see LazyLoadingValueHolderFactory
*
* @since 5.0
* @author Matthieu Napoli <[email protected]>
+2 -2
View File
@@ -30,7 +30,7 @@ if (! function_exists('DI\create')) {
* @param string|null $className Class name of the object.
* If null, the name of the entry (in the container) will be used as class name.
*/
function create(string $className = null) : CreateDefinitionHelper
function create(?string $className = null) : CreateDefinitionHelper
{
return new CreateDefinitionHelper($className);
}
@@ -43,7 +43,7 @@ if (! function_exists('DI\autowire')) {
* @param string|null $className Class name of the object.
* If null, the name of the entry (in the container) will be used as class name.
*/
function autowire(string $className = null) : AutowireDefinitionHelper
function autowire(?string $className = null) : AutowireDefinitionHelper
{
return new AutowireDefinitionHelper($className);
}
+1 -1
View File
@@ -782,7 +782,7 @@ All rights reserved.</copyright>
<library>
<location>php-di/php-di</location>
<name>PHP Dependency Injector</name>
<version>7.0.6</version>
<version>7.0.8</version>
<license>MIT</license>
<repository>https://github.com/PHP-DI/PHP-DI</repository>
</library>