Skip to content

Commit 02b8281

Browse files
phpstan-botclaude
authored andcommitted
Add regression test for #5521
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
1 parent 799e98d commit 02b8281

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

‎tests/PHPStan/Analyser/nsrt/implode.php‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,17 @@ public function atLeastTwoElements(array $arr, array $arr3) {
110110
assertType('string', implode('', $arr));
111111
}
112112

113+
public function bug5521() {
114+
// https://github.com/phpstan/phpstan/issues/5521
115+
// A single-element array drops the separator entirely, so the result
116+
// is just the (empty) single value, not a non-empty-string.
117+
$foo = [null];
118+
assertType("''", implode(',', $foo));
119+
120+
$bar = [''];
121+
assertType("''", implode(',', $bar));
122+
}
123+
113124
/** @param array{'a', 'b', ...<int, string>} $unsealed */
114125
public function unsealedConstArrEmptySeparator($unsealed) {
115126
// Empty separator + a possibly-empty unsealed value type leaves no

0 commit comments

Comments
 (0)