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:
parent
e33492398b
commit
90d6239d74
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
'
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user