From 44524632737ab083b5e44fd7081e5fd9e02ce254 Mon Sep 17 00:00:00 2001 From: jorgecc Date: Tue, 8 Oct 2024 11:50:46 -0300 Subject: [PATCH] 4.15.1 --- lib/BladeOne.php | 25 +++++++++++-------------- tests/SwitchTest.php | 3 ++- 2 files changed, 13 insertions(+), 15 deletions(-) diff --git a/lib/BladeOne.php b/lib/BladeOne.php index 6add299..aa393b0 100644 --- a/lib/BladeOne.php +++ b/lib/BladeOne.php @@ -32,16 +32,16 @@ * * @package BladeOne * @author Jorge Patricio Castro Castillo - * @copyright Copyright (c) 2016-2023 Jorge Patricio Castro Castillo MIT License. + * @copyright Copyright (c) 2016-2024 Jorge Patricio Castro Castillo MIT License. * Don't delete this comment, its part of the license. * Part of this code is based in the work of Laravel PHP Components. - * @version 4.14 + * @version 4.15.1 * @link https://github.com/EFTEC/BladeOne */ class BladeOne { // - public const VERSION = '4.14'; + public const VERSION = '4.15.1'; /** @var int BladeOne reads if the compiled file has changed. If it has changed,then the file is replaced. */ public const MODE_AUTO = 0; /** @var int Then compiled file is always replaced. It's slow and it's useful for development. */ @@ -81,8 +81,8 @@ class BladeOne protected array $hierarcy = []; /** * @var callable[] associative array with the callable methods. The key must be the name of the method
- * example:
- * ```php + * **example:**
+ * ``` * $this->methods['compileAlert']=static function(?string $expression=null) { return }; * $this->methods['runtimeAlert']=function(?array $arguments=null) { return }; * ``` @@ -112,7 +112,7 @@ class BladeOne * @var callable[] It allows to parse the compiled output using a function. * This function doesn't require to return a value
* **Example:** this converts all compiled result in uppercase (note, content is a ref) - * ```php + * ``` * $this->compileCallbacks[]= static function (&$content, $templatename=null) { * $content=strtoupper($content); * }; @@ -876,11 +876,7 @@ public function relative($relativeWeb): string public function addAssetDict($name, $url = ''): void { if (\is_array($name)) { - if ($this->assetDict === null) { - $this->assetDict = $name; - } else { - $this->assetDict = \array_merge($this->assetDict, $name); - } + $this->assetDict = \array_merge($this->assetDict, $name); } else { $this->assetDict[$name] = $url; } @@ -2895,7 +2891,7 @@ protected function compileComments($value): string case 1: return \preg_replace($pattern, '', $value); default: - return ""; + return \preg_replace($pattern, '', $value); } } @@ -2968,7 +2964,7 @@ protected function compileComponents($value) * [3]=... * [4]=content * - * @return mixed|string + * @return string */ $callback = function($match) { @@ -2985,7 +2981,8 @@ protected function compileComponents($value) } - protected function parseParams($params) { + protected function parseParams($params): string + { preg_match_all('/([a-z-0-9:]*?)\s*?=\s*?(.+?)(\s|$)/ms', $params, $matches); $paramsCompiled = []; foreach ($matches[1] as $i => $key) { diff --git a/tests/SwitchTest.php b/tests/SwitchTest.php index 7a49f92..150e0dc 100644 --- a/tests/SwitchTest.php +++ b/tests/SwitchTest.php @@ -49,9 +49,10 @@ public function testSwitch2(): void @endswitch BLADE; $this->blade->setCommentMode(2); - //$this->assertEqualsIgnoringWhitespace("First case...", $this->blade->compileString($bladeSource)); + //$this->assertEquals("First case...", $this->blade->compileString($bladeSource)); $this->assertEqualsIgnoringWhitespace("First case...", $this->blade->runString($bladeSource, ['i' => 1])); $this->assertEqualsIgnoringWhitespace("Second case...", $this->blade->runString($bladeSource, ['i' => 2])); $this->assertEqualsIgnoringWhitespace("Default case...", $this->blade->runString($bladeSource, ['i' => 3])); + $this->blade->setCommentMode(0); } }