From 9b9bfb43dac31c7804b2c8900217046cc0ca3307 Mon Sep 17 00:00:00 2001 From: David Grudl Date: Tue, 10 Sep 2024 11:11:35 +0200 Subject: [PATCH] uses nette/php-generator 4.1.6 --- composer.json | 2 +- src/DI/Extensions/ParametersExtension.php | 7 ++++--- src/DI/PhpGenerator.php | 7 ++++--- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/composer.json b/composer.json index 9811dc52b..f8342787f 100644 --- a/composer.json +++ b/composer.json @@ -19,7 +19,7 @@ "ext-tokenizer": "*", "ext-ctype": "*", "nette/neon": "^3.3 || ^4.0", - "nette/php-generator": "^4.1.3", + "nette/php-generator": "^4.1.6", "nette/robot-loader": "^4.0", "nette/schema": "^1.2.5", "nette/utils": "^4.0" diff --git a/src/DI/Extensions/ParametersExtension.php b/src/DI/Extensions/ParametersExtension.php index 3de4d1c46..144554d5f 100644 --- a/src/DI/Extensions/ParametersExtension.php +++ b/src/DI/Extensions/ParametersExtension.php @@ -61,7 +61,8 @@ public function afterCompile(Nette\PhpGenerator\ClassType $class): void }); } - $class->inheritMethod('getStaticParameters') + $manipulator = new Nette\PhpGenerator\ClassManipulator($class); + $manipulator->inheritMethod('getStaticParameters') ->addBody('return ?;', [array_diff_key($builder->parameters, $dynamicParams)]); if (!$dynamicParams) { @@ -70,7 +71,7 @@ public function afterCompile(Nette\PhpGenerator\ClassType $class): void $resolver = new Nette\DI\Resolver($builder); $generator = new Nette\DI\PhpGenerator($builder); - $method = $class->inheritMethod('getDynamicParameter'); + $method = $manipulator->inheritMethod('getDynamicParameter'); $method->addBody('return match($key) {'); foreach ($dynamicParams as $key => $foo) { $value = Helpers::expand($this->config[$key] ?? null, $builder->parameters); @@ -84,7 +85,7 @@ public function afterCompile(Nette\PhpGenerator\ClassType $class): void $method->addBody("\tdefault => parent::getDynamicParameter(\$key),\n};"); if ($preload = array_keys($dynamicParams, true, true)) { - $method = $class->inheritMethod('getParameters'); + $method = $manipulator->inheritMethod('getParameters'); $method->addBody('array_map($this->getParameter(...), ?);', [$preload]); $method->addBody('return parent::getParameters();'); } diff --git a/src/DI/PhpGenerator.php b/src/DI/PhpGenerator.php index da0abf59a..bbb4b574c 100644 --- a/src/DI/PhpGenerator.php +++ b/src/DI/PhpGenerator.php @@ -38,11 +38,12 @@ public function generate(string $className): Php\ClassType $this->className = $className; $class = new Php\ClassType($this->className); $class->setExtends(Container::class); - $class->inheritMethod('__construct') + $manipulator = new Php\ClassManipulator($class); + $manipulator->inheritMethod('__construct') ->addBody('parent::__construct($params);'); foreach ($this->builder->exportMeta() as $key => $value) { - $class->inheritProperty($key) + $manipulator->inheritProperty($key) ->setComment(null) ->setValue($value); } @@ -57,7 +58,7 @@ public function generate(string $className): Php\ClassType $class->getMethod(Container::getMethodName(ContainerBuilder::ThisContainer)) ->setBody('return $this;'); - $class->inheritMethod('initialize'); + $manipulator->inheritMethod('initialize'); return $class; }