diff --git a/src/View/SSViewer_DataPresenter.php b/src/View/SSViewer_DataPresenter.php index b808773a3..9a65d01fa 100644 --- a/src/View/SSViewer_DataPresenter.php +++ b/src/View/SSViewer_DataPresenter.php @@ -377,7 +377,7 @@ class SSViewer_DataPresenter extends SSViewer_Scope // Check if the method to-be-called exists on the target object - if so, don't check any further // injection locations $on = $this->itemIterator ? $this->itemIterator->current() : $this->item; - if ($on !== null && (isset($on->$property) || method_exists($on, $property ?? ''))) { + if (is_object($on) && (isset($on->$property) || method_exists($on, $property ?? ''))) { return []; } diff --git a/tests/php/View/SSViewerTest.php b/tests/php/View/SSViewerTest.php index 457c64b98..f7314c8a1 100644 --- a/tests/php/View/SSViewerTest.php +++ b/tests/php/View/SSViewerTest.php @@ -1035,22 +1035,22 @@ after' { $this->assertEquals( $this->render('<% include SSViewerTestIncludeWithArguments %>'), - '
[out:Arg1]
[out:Arg2]
' + '[out:Arg1]
[out:Arg2]
[out:Arg2.Count]
' ); $this->assertEquals( $this->render('<% include SSViewerTestIncludeWithArguments Arg1=A %>'), - 'A
[out:Arg2]
' + 'A
[out:Arg2]
[out:Arg2.Count]
' ); $this->assertEquals( $this->render('<% include SSViewerTestIncludeWithArguments Arg1=A, Arg2=B %>'), - 'A
B
' + 'A
B
' ); $this->assertEquals( $this->render('<% include SSViewerTestIncludeWithArguments Arg1=A Bare String, Arg2=B Bare String %>'), - 'A Bare String
B Bare String
' + 'A Bare String
B Bare String
' ); $this->assertEquals( @@ -1058,7 +1058,7 @@ after' '<% include SSViewerTestIncludeWithArguments Arg1="A", Arg2=$B %>', new ArrayData(['B' => 'Bar']) ), - 'A
Bar
' + 'A
Bar
' ); $this->assertEquals( @@ -1066,7 +1066,22 @@ after' '<% include SSViewerTestIncludeWithArguments Arg1="A" %>', new ArrayData(['Arg1' => 'Foo', 'Arg2' => 'Bar']) ), - 'A
Bar
' + 'A
Bar
' + ); + + $this->assertEquals( + $this->render('<% include SSViewerTestIncludeWithArguments Arg1="A", Arg2=0 %>'), + 'A
0
' + ); + + $this->assertEquals( + $this->render('<% include SSViewerTestIncludeWithArguments Arg1="A", Arg2=false %>'), + 'A
' + ); + + $this->assertEquals( + $this->render('<% include SSViewerTestIncludeWithArguments Arg1="A", Arg2=null %>'), + 'A
' ); $this->assertEquals( diff --git a/tests/php/View/SSViewerTest/templates/Includes/SSViewerTestIncludeWithArguments.ss b/tests/php/View/SSViewerTest/templates/Includes/SSViewerTestIncludeWithArguments.ss index 385eb7abf..73004e1b7 100644 --- a/tests/php/View/SSViewerTest/templates/Includes/SSViewerTestIncludeWithArguments.ss +++ b/tests/php/View/SSViewerTest/templates/Includes/SSViewerTestIncludeWithArguments.ss @@ -1 +1 @@ -$Arg1
$Arg2
+$Arg1
$Arg2
{$Arg2.Count}