Skip to content

Commit

Permalink
Bugfix in isArrayOfPhpEchoBlocks when the parameter is an empty array…
Browse files Browse the repository at this point in the history
… (you got a warning on rendering)
  • Loading branch information
rawsrc committed May 1, 2023
1 parent 84daf5e commit 42b340a
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 3 deletions.
2 changes: 1 addition & 1 deletion PhpEcho.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -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**
Expand Down Expand Up @@ -35,6 +35,8 @@ The class will manage :
```bash
composer require rawsrc/phpecho
```
**Changelog v5.4.1:**<br>
1. Minor bugfix in method `isArrayOfPhpEchoBlocks(mixed $p)` when `$p` is an empty array

**Changelog v5.4.0:**<br>
1. Add new abstract class `ViewBuilder` that help to manipulate abstract views as objects
Expand Down
34 changes: 34 additions & 0 deletions tests/core.php
Original file line number Diff line number Diff line change
Expand Up @@ -114,3 +114,37 @@ public function __toString(): string
$pilot->assertIsString();
$pilot->assertEqual('abc &quot; &lt; &gt;');


$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);
Binary file modified tests/global_tests_result.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 3 additions & 1 deletion tests/tests.php
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down

0 comments on commit 42b340a

Please sign in to comment.