Skip to content

Commit 1d03873

Browse files
committed
uses nette/php-generator 4.1.6
1 parent 15c1711 commit 1d03873

File tree

3 files changed

+9
-7
lines changed

3 files changed

+9
-7
lines changed

composer.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
"ext-tokenizer": "*",
2020
"ext-ctype": "*",
2121
"nette/neon": "^3.3 || ^4.0",
22-
"nette/php-generator": "^4.1.3",
22+
"nette/php-generator": "^4.1.6",
2323
"nette/robot-loader": "^4.0",
2424
"nette/schema": "^1.2.5",
2525
"nette/utils": "^4.0"

src/DI/Extensions/ParametersExtension.php

+4-3
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,8 @@ public function afterCompile(Nette\PhpGenerator\ClassType $class): void
6161
});
6262
}
6363

64-
$class->inheritMethod('getStaticParameters')
64+
$manipulator = new Nette\PhpGenerator\ClassManipulator($class);
65+
$manipulator->inheritMethod('getStaticParameters')
6566
->addBody('return ?;', [array_diff_key($builder->parameters, $dynamicParams)]);
6667

6768
if (!$dynamicParams) {
@@ -70,7 +71,7 @@ public function afterCompile(Nette\PhpGenerator\ClassType $class): void
7071

7172
$resolver = new Nette\DI\Resolver($builder);
7273
$generator = new Nette\DI\PhpGenerator($builder);
73-
$method = $class->inheritMethod('getDynamicParameter');
74+
$method = $manipulator->inheritMethod('getDynamicParameter');
7475
$method->addBody('return match($key) {');
7576
foreach ($dynamicParams as $key => $foo) {
7677
$value = Helpers::expand($this->config[$key] ?? null, $builder->parameters);
@@ -84,7 +85,7 @@ public function afterCompile(Nette\PhpGenerator\ClassType $class): void
8485
$method->addBody("\tdefault => parent::getDynamicParameter(\$key),\n};");
8586

8687
if ($preload = array_keys($dynamicParams, true, true)) {
87-
$method = $class->inheritMethod('getParameters');
88+
$method = $manipulator->inheritMethod('getParameters');
8889
$method->addBody('array_map($this->getParameter(...), ?);', [$preload]);
8990
$method->addBody('return parent::getParameters();');
9091
}

src/DI/PhpGenerator.php

+4-3
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,12 @@ public function generate(string $className): Php\ClassType
3838
$this->className = $className;
3939
$class = new Php\ClassType($this->className);
4040
$class->setExtends(Container::class);
41-
$class->inheritMethod('__construct')
41+
$manipulator = new Php\ClassManipulator($class);
42+
$manipulator->inheritMethod('__construct')
4243
->addBody('parent::__construct($params);');
4344

4445
foreach ($this->builder->exportMeta() as $key => $value) {
45-
$class->inheritProperty($key)
46+
$manipulator->inheritProperty($key)
4647
->setComment(null)
4748
->setValue($value);
4849
}
@@ -57,7 +58,7 @@ public function generate(string $className): Php\ClassType
5758
$class->getMethod(Container::getMethodName(ContainerBuilder::ThisContainer))
5859
->setBody('return $this;');
5960

60-
$class->inheritMethod('initialize');
61+
$manipulator->inheritMethod('initialize');
6162

6263
return $class;
6364
}

0 commit comments

Comments
 (0)