From 2aad22a784d57852c8c3439a1e7e016442a1048b Mon Sep 17 00:00:00 2001 From: Franck DAKIA Date: Mon, 16 Dec 2024 23:40:17 +0000 Subject: [PATCH 1/2] fix: block compilation --- src/Lexique/CompileHelpers.php | 2 +- src/StackManager.php | 3 +++ tests/CompileHelpersTest.php | 2 +- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/Lexique/CompileHelpers.php b/src/Lexique/CompileHelpers.php index 302fff3..bf060f2 100644 --- a/src/Lexique/CompileHelpers.php +++ b/src/Lexique/CompileHelpers.php @@ -131,7 +131,7 @@ protected function compileLang(string $expression): string * @param string $expression * @return string */ - protected function compileTrans(string $expression): string + protected function compileapp_trans(string $expression): string { return $this->compileHelpersStatement($expression, '%trans'); } diff --git a/src/StackManager.php b/src/StackManager.php index 6543b7f..059e1fb 100644 --- a/src/StackManager.php +++ b/src/StackManager.php @@ -146,6 +146,9 @@ public function endStack() public function getStack(string $name, ?string $default = null) { if (array_key_exists($name, $this->pushes)) { + if (is_null($this->pushes[$name])) { + $this->pushes[$name] = $default ?? ''; + } return $this->tintin->renderString( $this->pushes[$name], ['__tintin' => $this->tintin] diff --git a/tests/CompileHelpersTest.php b/tests/CompileHelpersTest.php index e31ea60..2f4a6bf 100644 --- a/tests/CompileHelpersTest.php +++ b/tests/CompileHelpersTest.php @@ -115,7 +115,7 @@ public function testCompileTransStatement() { $compileService = $this->makeReflectionFor('compileTrans'); - $render = $compileService->invoke($this->compiler, '%trans("user.service")'); + $render = $compileService->invoke($this->compiler, '%app_trans("user.service")'); $this->assertEquals($render, ''); } From 7882b983b0dde366bf8ced9f2d8220c22eed9748 Mon Sep 17 00:00:00 2001 From: Franck DAKIA Date: Mon, 16 Dec 2024 23:44:21 +0000 Subject: [PATCH 2/2] test: fix trans compilation --- src/Lexique/CompileHelpers.php | 2 +- tests/CompileHelpersTest.php | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Lexique/CompileHelpers.php b/src/Lexique/CompileHelpers.php index bf060f2..302fff3 100644 --- a/src/Lexique/CompileHelpers.php +++ b/src/Lexique/CompileHelpers.php @@ -131,7 +131,7 @@ protected function compileLang(string $expression): string * @param string $expression * @return string */ - protected function compileapp_trans(string $expression): string + protected function compileTrans(string $expression): string { return $this->compileHelpersStatement($expression, '%trans'); } diff --git a/tests/CompileHelpersTest.php b/tests/CompileHelpersTest.php index 2f4a6bf..3640ee8 100644 --- a/tests/CompileHelpersTest.php +++ b/tests/CompileHelpersTest.php @@ -115,7 +115,8 @@ public function testCompileTransStatement() { $compileService = $this->makeReflectionFor('compileTrans'); - $render = $compileService->invoke($this->compiler, '%app_trans("user.service")'); + $render = $compileService->invoke($this->compiler, '%trans("user.service")'); + $this->assertEquals($render, ''); }