Skip to content

Commit f7a84a5

Browse files
committed
Security/StaticStrreplace: add tests with optional fourth parameter
... to ensure and safeguard the sniff does not get confused over that parameter.
1 parent 497fbce commit f7a84a5

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

WordPressVIPMinimum/Tests/Security/StaticStrreplaceUnitTest.inc

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ $this->str_replace('foo', 'bar', 'foobar');
1010
$this?->str_replace('foo', 'bar', 'foobar');
1111
MyClass::str_replace('foo', 'bar', 'foobar');
1212
echo STR_REPLACE;
13-
namespace\str_replace('foo', 'bar', 'foobar');
13+
namespace\str_replace('foo', 'bar', 'foobar', $count);
1414

1515
// Looks like a function call, but is a PHP 8.0+ class instantiation via an attribute.
1616
#[Str_Replace('foo', 'bar', 'foobar')]
@@ -34,7 +34,7 @@ str_replace( $foo->getSearch(), 'bar', 'foobar' );
3434
\str_replace( 'foo', $bar, 'foobar' );
3535
str_replace( 'foo', 'bar', $foobar, );
3636
STR_REPLACE( $foo, $bar, 'foobar' );
37-
str_replace( 'foo', get_replacements(), $foobar );
37+
str_replace( 'foo', get_replacements(), $foobar, $count );
3838

3939
str_replace( array( 'foo', "$bar" ), $bar, 'foobar' );
4040

@@ -54,3 +54,4 @@ Str_replace(
5454
'foobar'
5555
); // Bad.
5656
str_replace( array( 'foo', 'bar' ), array( 'bar', 'foo' ), array( 'foobar', 'foobar' ) ); // Bad.
57+
str_replace( 'foo', 'bar', 'foobar', $count ); // Bad.

WordPressVIPMinimum/Tests/Security/StaticStrreplaceUnitTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ public function getErrorList() {
2626
50 => 1,
2727
51 => 1,
2828
56 => 1,
29+
57 => 1,
2930
];
3031
}
3132

0 commit comments

Comments
 (0)