diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index e5f487e0f..59649e324 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -37,6 +37,6 @@ parameters: - message: "#^Parameter \\#2 \\$callback of method League\\\\Plates\\\\Engine\\:\\:registerFunction\\(\\) expects League\\\\Plates\\\\callback, Closure given\\.$#" - count: 7 + count: 4 path: src/View.php diff --git a/src/View/GlobalSections.php b/src/View/GlobalSections.php index 4c1e6c950..c1a28de61 100644 --- a/src/View/GlobalSections.php +++ b/src/View/GlobalSections.php @@ -34,9 +34,9 @@ final class GlobalSections $initialValue = $this->sections[$section] ?? ''; $this->sections[$section] = match ($mode) { - Template::SECTION_MODE_REWRITE => $value, Template::SECTION_MODE_PREPEND => $value . $initialValue, - Template::SECTION_MODE_APPEND => $initialValue . $value + Template::SECTION_MODE_APPEND => $initialValue . $value, + default => $value }; } @@ -61,13 +61,13 @@ final class GlobalSections ob_start(); } - public function appendStart($name): void + public function appendStart(string $name): void { $this->sectionMode = Template::SECTION_MODE_APPEND; $this->start($name); } - public function prependStart($name) + public function prependStart(string $name): void { $this->sectionMode = Template::SECTION_MODE_PREPEND; $this->start($name); @@ -81,7 +81,7 @@ final class GlobalSections ); } - $this->set($this->sectionName, ob_get_clean(), $this->sectionMode); + $this->set($this->sectionName, ob_get_clean() ?: null, $this->sectionMode); $this->sectionName = null; $this->sectionMode = Template::SECTION_MODE_REWRITE;