From dc014c0881229694d0b6710e663fc9af500bea1d Mon Sep 17 00:00:00 2001 From: Jakub-Fajkus Date: Tue, 15 Mar 2022 17:21:05 +0100 Subject: [PATCH 1/2] Fix NetteGenerator BC break First argument of \Nette\PhpGenerator\Method::setBody() cannot be null --- src/Events/DI/EventsExtension.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Events/DI/EventsExtension.php b/src/Events/DI/EventsExtension.php index cc39012..f849332 100644 --- a/src/Events/DI/EventsExtension.php +++ b/src/Events/DI/EventsExtension.php @@ -182,7 +182,7 @@ public function afterCompile(ClassTypeGenerator $class) /** @hack This tries to add the event invokation right after the code, generated by NetteExtension. */ $foundNetteInitStart = $foundNetteInitEnd = FALSE; $lines = explode(";\n", trim($init->getBody() ?: '')); - $init->setBody(NULL); + $init->setBody(''); while (($line = array_shift($lines)) !== NULL) { if ($foundNetteInitStart && !$foundNetteInitEnd && stripos($line, 'Nette\\') === FALSE && stripos($line, 'set_include_path') === FALSE && stripos($line, 'date_default_timezone_set') === FALSE From 7d3e3869ca0c3e71eb4881c9259e5408c07b2234 Mon Sep 17 00:00:00 2001 From: Jakub-Fajkus Date: Tue, 15 Mar 2022 17:23:49 +0100 Subject: [PATCH 2/2] fix Nette\PhpGenerator\Helpers::format() is deprecated E_USER_DEPRECATED: Nette\PhpGenerator\Helpers::format() is deprecated, use (new Nette\PhpGenerator\Dumper)->format(). --- src/Events/DI/EventsExtension.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Events/DI/EventsExtension.php b/src/Events/DI/EventsExtension.php index f849332..858999a 100644 --- a/src/Events/DI/EventsExtension.php +++ b/src/Events/DI/EventsExtension.php @@ -187,7 +187,7 @@ public function afterCompile(ClassTypeGenerator $class) if ($foundNetteInitStart && !$foundNetteInitEnd && stripos($line, 'Nette\\') === FALSE && stripos($line, 'set_include_path') === FALSE && stripos($line, 'date_default_timezone_set') === FALSE ) { - $init->addBody(GeneratorHelpers::format( + $init->addBody( (new \Nette\PhpGenerator\Dumper)->format( '$this->getService(?)->createEvent(?)->dispatch($this);', $this->prefix('manager'), [DIContainer::class, 'onInitialize'] @@ -206,7 +206,7 @@ public function afterCompile(ClassTypeGenerator $class) } if (!$foundNetteInitEnd) { - $init->addBody(GeneratorHelpers::format( + $init->addBody( (new \Nette\PhpGenerator\Dumper)->format( '$this->getService(?)->createEvent(?)->dispatch($this);', $this->prefix('manager'), [DIContainer::class, 'onInitialize']