Skip to content

Commit aef1bd4

Browse files
authored
Merge pull request #478 from defuse/fix-php8-tests
Skip a test of substr for PHP 8 and above because the behavior changed
2 parents 2a693cb + 54f79a1 commit aef1bd4

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

test/unit/CoreTest.php

+8-4
Original file line numberDiff line numberDiff line change
@@ -79,10 +79,14 @@ public function testOurSubstrOutOfBorders()
7979
// See: https://secure.php.net/manual/en/function.mb-substr.php#50275
8080

8181
// We want to be like substr, so confirm that behavior.
82-
$this->assertSame(
83-
false,
84-
substr('abc', 5, 2)
85-
);
82+
if (PHP_VERSION_ID < 80000) {
83+
// In PHP 8.0, substr starts returning '' instead of the empty string.
84+
// Core::ourSubstr should behave the OLD way.
85+
$this->assertSame(
86+
false,
87+
substr('abc', 5, 2)
88+
);
89+
}
8690

8791
// Confirm that mb_substr does not have that behavior.
8892
if (function_exists('mb_substr')) {

0 commit comments

Comments
 (0)