mirror of
https://github.com/danog/psalm-plugin.git
synced 2024-11-26 12:25:05 +01:00
Fixup
This commit is contained in:
parent
b36ca5eed0
commit
678f519620
@ -11,7 +11,7 @@
|
||||
],
|
||||
"require": {
|
||||
"php": "^8.1",
|
||||
"vimeo/psalm": "^5.0"
|
||||
"vimeo/psalm": ">=5.16"
|
||||
},
|
||||
"conflict": {
|
||||
"azjezz/psl": "<2.0"
|
||||
|
@ -28,80 +28,28 @@ final class FunctionReturnTypeProvider implements FunctionReturnTypeProviderInte
|
||||
if (null === $argument_type) {
|
||||
// [unknown] -> list<string>
|
||||
$value = new Type\Union([new Type\Atomic\TString()], ['possibly_undefined' => true]);
|
||||
return new Type\Union([new Type\Atomic\TKeyedArray(
|
||||
[
|
||||
0 => $value
|
||||
],
|
||||
null,
|
||||
[
|
||||
Type::getListKey(),
|
||||
$value
|
||||
],
|
||||
true
|
||||
)]);
|
||||
return Type::getList($value);
|
||||
}
|
||||
|
||||
$string_argument_type = $argument_type->getAtomicTypes()['string'] ?? null;
|
||||
if (null === $string_argument_type) {
|
||||
// [unknown] -> list<string>
|
||||
$value = new Type\Union([new Type\Atomic\TString()], ['possibly_undefined' => true]);
|
||||
return new Type\Union([new Type\Atomic\TKeyedArray(
|
||||
[
|
||||
0 => $value
|
||||
],
|
||||
null,
|
||||
[
|
||||
Type::getListKey(),
|
||||
$value
|
||||
],
|
||||
true
|
||||
)]);
|
||||
return Type::getList($value);
|
||||
}
|
||||
|
||||
if ($string_argument_type instanceof Type\Atomic\TNonEmptyString) {
|
||||
// non-empty-lowercase-string => non-empty-list<non-empty-lowercase-string>
|
||||
if ($string_argument_type instanceof Type\Atomic\TNonEmptyLowercaseString) {
|
||||
$value = new Type\Union([new Type\Atomic\TNonEmptyLowercaseString()]);
|
||||
return new Type\Union([new Type\Atomic\TKeyedArray(
|
||||
[
|
||||
0 => $value
|
||||
],
|
||||
null,
|
||||
[
|
||||
Type::getListKey(),
|
||||
$value
|
||||
],
|
||||
true
|
||||
)]);
|
||||
return Type::getNonEmptyList(Type::getNonEmptyLowercaseString());
|
||||
}
|
||||
|
||||
// non-empty-string => non-empty-list<non-empty-string>
|
||||
$value = new Type\Union([new Type\Atomic\TNonEmptyString()]);
|
||||
return new Type\Union([new Type\Atomic\TKeyedArray(
|
||||
[
|
||||
0 => $value
|
||||
],
|
||||
null,
|
||||
[
|
||||
Type::getListKey(),
|
||||
$value
|
||||
],
|
||||
true
|
||||
)]);
|
||||
return Type::getNonEmptyList(Type::getNonEmptyString());
|
||||
}
|
||||
|
||||
// string -> list<string>
|
||||
$value = new Type\Union([new Type\Atomic\TString()], ['possibly_undefined' => true]);
|
||||
return new Type\Union([new Type\Atomic\TKeyedArray(
|
||||
[
|
||||
0 => $value
|
||||
],
|
||||
null,
|
||||
[
|
||||
Type::getListKey(),
|
||||
$value
|
||||
],
|
||||
true
|
||||
)]);
|
||||
return Type::getList($value);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user