diff --git a/PhpEcho.php b/PhpEcho.php index f367012..1a953a2 100644 --- a/PhpEcho.php +++ b/PhpEcho.php @@ -830,7 +830,7 @@ private function bindHelpersTo(object $p): void */ private function isArrayOfPhpEchoBlocks(mixed $p): bool { - if (is_array($p)) { + if (is_array($p) && ($p !== [])) { foreach ($p as $v) { if ( ! ($v instanceof self)) { return false; diff --git a/README.md b/README.md index 579e4d5..1aa601e 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # **PhpEcho** -`2023-04-17` `PHP 8.0+` `v.5.4.0` +`2023-05-01` `PHP 8.0+` `v.5.4.1` ## **A native PHP template engine : One class to rule them all** ## **VERSION 5.X IS ONLY FOR PHP 8 AND ABOVE** @@ -35,6 +35,8 @@ The class will manage : ```bash composer require rawsrc/phpecho ``` +**Changelog v5.4.1:**
+1. Minor bugfix in method `isArrayOfPhpEchoBlocks(mixed $p)` when `$p` is an empty array **Changelog v5.4.0:**
1. Add new abstract class `ViewBuilder` that help to manipulate abstract views as objects diff --git a/tests/core.php b/tests/core.php index cbb386c..032c068 100644 --- a/tests/core.php +++ b/tests/core.php @@ -114,3 +114,37 @@ public function __toString(): string $pilot->assertIsString(); $pilot->assertEqual('abc " < >'); + +$data = [new PhpEcho(), new PhpEcho()]; +$pilot->runClassMethod( + id: 'core_012', + class: $block, + description: 'check isArrayOfPhpEchoBlocks with a full array of PhpEcho blocks', + method: 'isArrayOfPhpEchoBlocks', + params: [$data] +); +$pilot->assertIsBool(); +$pilot->assertEqual(true); + +$data = [new PhpEcho(), new PhpEcho(), 25]; +$pilot->runClassMethod( + id: 'core_013', + class: $block, + description: 'check isArrayOfPhpEchoBlocks with an mixed array', + method: 'isArrayOfPhpEchoBlocks', + params: [$data] +); +$pilot->assertIsBool(); +$pilot->assertEqual(false); + + +$data = []; +$pilot->runClassMethod( + id: 'core_014', + class: $block, + description: 'check isArrayOfPhpEchoBlocks with an empty array', + method: 'isArrayOfPhpEchoBlocks', + params: [$data] +); +$pilot->assertIsBool(); +$pilot->assertEqual(false); diff --git a/tests/global_tests_result.jpg b/tests/global_tests_result.jpg index 69fe8bf..7dfd142 100644 Binary files a/tests/global_tests_result.jpg and b/tests/global_tests_result.jpg differ diff --git a/tests/tests.php b/tests/tests.php index 345d0f9..cd321f8 100644 --- a/tests/tests.php +++ b/tests/tests.php @@ -11,12 +11,14 @@ //region setup test environment include_once '../vendor/exacodis/Pilot.php'; +include_once '../vendor/exacodis/Report.php'; +include_once '../vendor/exacodis/Runner.php'; include_once '../PhpEcho.php'; include_once '../ViewBuilder.php'; use Exacodis\Pilot; -$pilot = new Pilot('PhpEcho - A native PHP template engine - v.5.4.0'); +$pilot = new Pilot('PhpEcho - A native PHP template engine - v.5.4.1'); $pilot->injectStandardHelpers(); include 'filepath.php';