1
0
mirror of https://github.com/danog/psalm.git synced 2024-11-27 04:45:20 +01:00

strlen of strtolower of string is not always true

This commit is contained in:
orklah 2021-10-24 18:31:42 +02:00
parent e33492398b
commit 90d6239d74
2 changed files with 23 additions and 0 deletions

View File

@ -585,6 +585,11 @@ class ScalarTypeComparator
return true;
}
if ($input_type_part instanceof TLowercaseString
&& get_class($container_type_part) === TNonEmptyString::class) {
return false;
}
if ($input_type_part->getKey() === $container_type_part->getKey()) {
return true;
}

View File

@ -841,6 +841,24 @@ class ConditionalReturnTypeTest extends TestCase
}
'
],
'strlenReturnsIntForLowercaseString' => [
'<?php
/**
* @psalm-return (
* $string is non-empty-string
* ? positive-int
* : int
* )
*/
function strlen2(string $string) : int { return 1;}
function test(string $s): void {
if (strlen2(strtolower($s))) {
echo 1;
}
}
'
],
];
}
}