Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/ViewHelpers/ReplaceViewHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public function render(): string
$value = $this->arguments['value'] ?? $this->renderChildren();
$search = $this->arguments['search'];
$replace = $this->arguments['replace'];
if ($value === null || (!is_scalar($value) && !$value instanceof \Stringable)) {
if ($value !== null && !is_scalar($value) && !$value instanceof \Stringable) {
throw new \InvalidArgumentException('A stringable value must be provided.', 1710441987);
}
if ($search === null) {
Expand Down
11 changes: 5 additions & 6 deletions tests/Functional/ViewHelpers/ReplaceViewHelperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,6 @@ final class ReplaceViewHelperTest extends AbstractFunctionalTestCase
{
public static function throwsExceptionForInvalidArgumentDataProvider(): iterable
{
yield 'without value' => [
'<f:replace search="foo" replace="bar" />',
[],
1710441987,
'A stringable value must be provided.',
];
yield 'array as value' => [
'{value -> f:replace(search: \'foo\', replace: \'bar\')}',
['value' => [1, 2, 3]],
Expand Down Expand Up @@ -132,6 +126,11 @@ public static function renderDataProvider(): iterable
['value' => ''],
'',
];
yield 'with null as value' => [
'<f:replace search="foo" replace="bar" value="{null}" />',
[],
'',
];
}

#[DataProvider('renderDataProvider')]
Expand Down