mirror of
https://github.com/danog/psalm.git
synced 2024-11-27 04:45:20 +01:00
Fix non-empty-literal-string to behave as subtype of non-empty-string (fixes #7095).
This commit is contained in:
parent
8bd525a55f
commit
a89e8ec28c
@ -38,6 +38,7 @@ use Psalm\Type\Atomic\TNonEmptyArray;
|
|||||||
use Psalm\Type\Atomic\TNonEmptyList;
|
use Psalm\Type\Atomic\TNonEmptyList;
|
||||||
use Psalm\Type\Atomic\TNonEmptyLowercaseString;
|
use Psalm\Type\Atomic\TNonEmptyLowercaseString;
|
||||||
use Psalm\Type\Atomic\TNonEmptyMixed;
|
use Psalm\Type\Atomic\TNonEmptyMixed;
|
||||||
|
use Psalm\Type\Atomic\TNonEmptyNonspecificLiteralString;
|
||||||
use Psalm\Type\Atomic\TNonEmptyString;
|
use Psalm\Type\Atomic\TNonEmptyString;
|
||||||
use Psalm\Type\Atomic\TNonFalsyString;
|
use Psalm\Type\Atomic\TNonFalsyString;
|
||||||
use Psalm\Type\Atomic\TNonspecificLiteralInt;
|
use Psalm\Type\Atomic\TNonspecificLiteralInt;
|
||||||
@ -1131,6 +1132,15 @@ class TypeCombiner
|
|||||||
&& get_class($type) === TNonEmptyLowercaseString::class
|
&& get_class($type) === TNonEmptyLowercaseString::class
|
||||||
) {
|
) {
|
||||||
//no-change
|
//no-change
|
||||||
|
} elseif (get_class($combination->value_types['string'])
|
||||||
|
=== TNonEmptyNonspecificLiteralString::class
|
||||||
|
&& $type instanceof TNonEmptyString
|
||||||
|
) {
|
||||||
|
$combination->value_types['string'] = new TNonEmptyString();
|
||||||
|
} elseif (get_class($type) === TNonEmptyNonspecificLiteralString::class
|
||||||
|
&& $combination->value_types['string'] instanceof TNonEmptyString
|
||||||
|
) {
|
||||||
|
// do nothing
|
||||||
} else {
|
} else {
|
||||||
$combination->value_types['string'] = new TString();
|
$combination->value_types['string'] = new TString();
|
||||||
}
|
}
|
||||||
|
@ -801,6 +801,20 @@ class TypeCombinationTest extends TestCase
|
|||||||
'positive-int',
|
'positive-int',
|
||||||
]
|
]
|
||||||
],
|
],
|
||||||
|
'combineNonEmptyStringAndNonEmptyNonSpecificLiteralString' => [
|
||||||
|
'non-empty-string',
|
||||||
|
[
|
||||||
|
'non-empty-literal-string',
|
||||||
|
'non-empty-string',
|
||||||
|
],
|
||||||
|
],
|
||||||
|
'combineNonEmptyNonSpecificLiteralStringAndNonEmptyString' => [
|
||||||
|
'non-empty-string',
|
||||||
|
[
|
||||||
|
'non-empty-string',
|
||||||
|
'non-empty-literal-string',
|
||||||
|
],
|
||||||
|
],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user