fix:更新已知bug,优化代码

This commit is contained in:
Ying
2022-11-28 19:11:12 +08:00
parent f6aee95cfc
commit 9445b206a2
1378 changed files with 53759 additions and 20789 deletions

View File

@@ -1,5 +1,9 @@
# Change log
## 6.1.0
- [#791](https://github.com/PHP-DI/PHP-DI/issues/791) Support PHP 8.1, remove support for PHP 7.2
## 6.0.2
- Fix potential regression introduced when fixing [#582](https://github.com/PHP-DI/PHP-DI/issues/582)

View File

@@ -25,17 +25,17 @@
"phpstan": "phpstan analyse -l 5 -c phpstan.neon src"
},
"require": {
"php": ">=7.2.0",
"php": ">=7.4.0",
"psr/container": "^1.0",
"php-di/invoker": "^2.0",
"php-di/phpdoc-reader": "^2.0.1",
"opis/closure": "^3.5.5"
"laravel/serializable-closure": "^1.0"
},
"require-dev": {
"phpunit/phpunit": "^8.5|^9.0",
"phpunit/phpunit": "^9.5",
"mnapoli/phpunit-easymock": "^1.2",
"doctrine/annotations": "~1.2",
"ocramius/proxy-manager": "^2.0.2",
"doctrine/annotations": "~1.10",
"ocramius/proxy-manager": "^2.11.2",
"friendsofphp/php-cs-fixer": "^2.4",
"phpstan/phpstan": "^0.12"
},

View File

@@ -21,7 +21,7 @@ use DI\Proxy\ProxyFactory;
use function dirname;
use function file_put_contents;
use InvalidArgumentException;
use Opis\Closure\SerializableClosure;
use Laravel\SerializableClosure\Support\ReflectionClosure;
use function rename;
use function sprintf;
use function tempnam;
@@ -401,8 +401,7 @@ PHP;
*/
private function compileClosure(\Closure $closure) : string
{
$wrapper = new SerializableClosure($closure);
$reflector = $wrapper->getReflector();
$reflector = new ReflectionClosure($closure);
if ($reflector->getUseVariables()) {
throw new InvalidDefinition('Cannot compile closures which import variables using the `use` keyword');

View File

@@ -42,7 +42,7 @@ class ArrayResolver implements DefinitionResolver
$values = $definition->getValues();
// Resolve nested definitions
array_walk_recursive($values, function (&$value, $key) use ($definition) {
array_walk_recursive($values, function (& $value, $key) use ($definition) {
if ($value instanceof Definition) {
$value = $this->resolveDefinition($value, $definition, $key);
}