Skip to content

Commit

Permalink
correct PHP < 8.2 issue with empty path string
Browse files Browse the repository at this point in the history
  • Loading branch information
dakujem committed Jan 19, 2024
1 parent e685b6e commit 5e26064
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/MaterializedPath/TreeBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public static function fixed(int $levelWidth, callable $accessor): callable
{
return function (mixed $data) use ($levelWidth, $accessor): array {
$path = $accessor($data);
if (null === $path) {
if (null === $path || $path === '') {
return [];
}
if (!is_string($path)) {
Expand Down
1 change: 1 addition & 0 deletions tests/mptree.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ class Item
);
Assert::same(['000', '000'], $vectorExtractor('000000'));
Assert::same(['foo', 'bar'], $vectorExtractor('foobar'));
Assert::same(['x'], $vectorExtractor('x')); // shorter than 3
Assert::same([], $vectorExtractor(''));
Assert::same([], $vectorExtractor(null));
Assert::throws(function () use ($vectorExtractor) {
Expand Down

0 comments on commit 5e26064

Please sign in to comment.