Skip to content

Commit d161a53

Browse files
Add test
1 parent e3690a7 commit d161a53

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

tests/Template/ConditionalReturnTypeTest.php

+26
Original file line numberDiff line numberDiff line change
@@ -1039,6 +1039,32 @@ function getSomething(string $string)
10391039
],
10401040
'ignored_issues' => [],
10411041
],
1042+
'lowercaseStringIsNotNonEmptyWithUnion' => [
1043+
'code' => '<?php
1044+
/**
1045+
* @param string|int $stringOrInt
1046+
* @psalm-return ($string is non-empty-string|int ? string : int)
1047+
*/
1048+
function getSomething($stringOrInt)
1049+
{
1050+
if (!$stringOrInt) {
1051+
return 1;
1052+
}
1053+
return "";
1054+
}
1055+
/** @var string $string */
1056+
$string;
1057+
$something = getSomething($string);
1058+
/** @var non-empty-string $nonEmptyString */
1059+
$nonEmptyString;
1060+
$something2 = getSomething($nonEmptyString);
1061+
',
1062+
'assertions' => [
1063+
'$something' => 'int|string',
1064+
'$something2' => 'string',
1065+
],
1066+
'ignored_issues' => [],
1067+
],
10421068
];
10431069
}
10441070
}

0 commit comments

Comments
 (0)