From b1e1324bfa0da77b4f5d2f447e2376b95ea5cf31 Mon Sep 17 00:00:00 2001 From: Dave Mc Nicoll Date: Thu, 13 Apr 2023 15:49:45 -0400 Subject: [PATCH 1/2] - Fixed some PHP 8.x bugs (missing vars within compiler's context) and removed Picea's error handler - needs some work before putting online --- src/Compiler/Context.php | 4 +++- src/Picea.php | 10 +++++----- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/Compiler/Context.php b/src/Compiler/Context.php index 718d5ec..51c6170 100644 --- a/src/Compiler/Context.php +++ b/src/Compiler/Context.php @@ -24,10 +24,12 @@ abstract class Context { public array $switchStack = []; - public array $iterateStack = []; + public array $iterationStack = []; public array $useStack = []; + public array $sections = []; + public int $functions = 0; public array $functionStack = []; diff --git a/src/Picea.php b/src/Picea.php index 5879360..3035e50 100644 --- a/src/Picea.php +++ b/src/Picea.php @@ -71,12 +71,12 @@ class Picea implements LanguageRegistration return call_user_func($object); } catch(\Throwable $ex) { - if (! $ex instanceof Exception\RenderHtmlException ) { - throw new Exception\RenderHtmlException($object, $this, "An error occurred trying to render HTML view `$viewPath` : " . $ex->getMessage(), 911, $ex); - } - else { + # if (! $ex instanceof Exception\RenderHtmlException ) { + # throw new Exception\RenderHtmlException($object, $this, "An error occurred trying to render HTML view `$viewPath` : " . $ex->getMessage(), 911, $ex); + # } + #else { throw $ex; - } + # } } exit(); From 5182ba19bc1f000460ff0a5b96540e4a2204b3d1 Mon Sep 17 00:00:00 2001 From: Dave Mc Nicoll Date: Wed, 19 Apr 2023 13:23:29 -0400 Subject: [PATCH 2/2] - Fixed optional arguments in buildUrl() --- src/Extension/UrlExtension.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Extension/UrlExtension.php b/src/Extension/UrlExtension.php index 691d5dc..598c782 100644 --- a/src/Extension/UrlExtension.php +++ b/src/Extension/UrlExtension.php @@ -249,12 +249,13 @@ PATTERN; if ($default ?? false) { $value = $default; } - elseif ($this->enforceExistingArguments) { + elseif ($this->enforceExistingArguments && ! strpos($route, sprintf('[/{%s:', $variable)) ) { throw new \RuntimeException(sprintf("Error while preparing route %s : could not match variable '%s' into given arguments ( %s )", $route, $variable, json_encode($arguments))); } } - $search[ $item[0] ] = $value; + $search[$item[0]] = $value ?? ""; + } $route = str_replace(array_keys($search), array_values($search), $route);