Skip to content

Commit 4452463

Browse files
4.15.1
1 parent 2890c8a commit 4452463

File tree

2 files changed

+13
-15
lines changed

2 files changed

+13
-15
lines changed

lib/BladeOne.php

+11-14
Original file line numberDiff line numberDiff line change
@@ -32,16 +32,16 @@
3232
*
3333
* @package BladeOne
3434
* @author Jorge Patricio Castro Castillo <jcastro arroba eftec dot cl>
35-
* @copyright Copyright (c) 2016-2023 Jorge Patricio Castro Castillo MIT License.
35+
* @copyright Copyright (c) 2016-2024 Jorge Patricio Castro Castillo MIT License.
3636
* Don't delete this comment, its part of the license.
3737
* Part of this code is based in the work of Laravel PHP Components.
38-
* @version 4.14
38+
* @version 4.15.1
3939
* @link https://github.com/EFTEC/BladeOne
4040
*/
4141
class BladeOne
4242
{
4343
//<editor-fold desc="fields">
44-
public const VERSION = '4.14';
44+
public const VERSION = '4.15.1';
4545
/** @var int BladeOne reads if the compiled file has changed. If it has changed,then the file is replaced. */
4646
public const MODE_AUTO = 0;
4747
/** @var int Then compiled file is always replaced. It's slow and it's useful for development. */
@@ -81,8 +81,8 @@ class BladeOne
8181
protected array $hierarcy = [];
8282
/**
8383
* @var callable[] associative array with the callable methods. The key must be the name of the method<br>
84-
* <b>example:</b><br>
85-
* ```php
84+
* **example:**<br>
85+
* ```
8686
* $this->methods['compileAlert']=static function(?string $expression=null) { return };
8787
* $this->methods['runtimeAlert']=function(?array $arguments=null) { return };
8888
* ```
@@ -112,7 +112,7 @@ class BladeOne
112112
* @var callable[] It allows to parse the compiled output using a function.
113113
* This function doesn't require to return a value<br>
114114
* **Example:** this converts all compiled result in uppercase (note, content is a ref)
115-
* ```php
115+
* ```
116116
* $this->compileCallbacks[]= static function (&$content, $templatename=null) {
117117
* $content=strtoupper($content);
118118
* };
@@ -876,11 +876,7 @@ public function relative($relativeWeb): string
876876
public function addAssetDict($name, $url = ''): void
877877
{
878878
if (\is_array($name)) {
879-
if ($this->assetDict === null) {
880-
$this->assetDict = $name;
881-
} else {
882-
$this->assetDict = \array_merge($this->assetDict, $name);
883-
}
879+
$this->assetDict = \array_merge($this->assetDict, $name);
884880
} else {
885881
$this->assetDict[$name] = $url;
886882
}
@@ -2895,7 +2891,7 @@ protected function compileComments($value): string
28952891
case 1:
28962892
return \preg_replace($pattern, '<!-- $1 -->', $value);
28972893
default:
2898-
return "";
2894+
return \preg_replace($pattern, '', $value);
28992895
}
29002896
}
29012897

@@ -2968,7 +2964,7 @@ protected function compileComponents($value)
29682964
* [3]=...
29692965
* [4]=content
29702966
*
2971-
* @return mixed|string
2967+
* @return string
29722968
*/
29732969

29742970
$callback = function($match) {
@@ -2985,7 +2981,8 @@ protected function compileComponents($value)
29852981

29862982
}
29872983

2988-
protected function parseParams($params) {
2984+
protected function parseParams($params): string
2985+
{
29892986
preg_match_all('/([a-z-0-9:]*?)\s*?=\s*?(.+?)(\s|$)/ms', $params, $matches);
29902987
$paramsCompiled = [];
29912988
foreach ($matches[1] as $i => $key) {

tests/SwitchTest.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,10 @@ public function testSwitch2(): void
4949
@endswitch
5050
BLADE;
5151
$this->blade->setCommentMode(2);
52-
//$this->assertEqualsIgnoringWhitespace("First case...", $this->blade->compileString($bladeSource));
52+
//$this->assertEquals("First case...", $this->blade->compileString($bladeSource));
5353
$this->assertEqualsIgnoringWhitespace("First case...", $this->blade->runString($bladeSource, ['i' => 1]));
5454
$this->assertEqualsIgnoringWhitespace("Second case...", $this->blade->runString($bladeSource, ['i' => 2]));
5555
$this->assertEqualsIgnoringWhitespace("Default case...", $this->blade->runString($bladeSource, ['i' => 3]));
56+
$this->blade->setCommentMode(0);
5657
}
5758
}

0 commit comments

Comments
 (0)