chore: add compatibility with psalm 5

Signed-off-by: azjezz <azjezz@protonmail.com>
This commit is contained in:
azjezz 2022-02-06 19:20:13 +01:00
parent 51f37a1c07
commit dff80efbbf
No known key found for this signature in database
GPG Key ID: B00E0A46B3F1C157
3 changed files with 12 additions and 11 deletions

View File

@ -11,7 +11,7 @@
], ],
"require": { "require": {
"php": "^8.1", "php": "^8.1",
"vimeo/psalm": "^4.6" "vimeo/psalm": "^4.20 || ^5.0"
}, },
"conflict": { "conflict": {
"azjezz/psl": "<2.0" "azjezz/psl": "<2.0"
@ -47,12 +47,15 @@
}, },
"config": { "config": {
"process-timeout": 1200, "process-timeout": 1200,
"sort-packages": true "sort-packages": true,
"allow-plugins": {
"composer/package-versions-deprecated": false
}
}, },
"extra": { "extra": {
"psalm": { "psalm": {
"pluginClass": "Psl\\Psalm\\Plugin" "pluginClass": "Psl\\Psalm\\Plugin"
} }
}, },
"minimum-stability": "dev" "minimum-stability": "alpha"
} }

View File

@ -1,5 +1,5 @@
<?xml version="1.0"?> <?xml version="1.0"?>
<psalm totallyTyped="true" resolveFromConfigFile="true" forbidEcho="true" strictBinaryOperands="true" phpVersion="8.1" allowStringToStandInForClass="true" rememberPropertyAssignmentsAfterCall="false" skipChecksOnUnresolvableIncludes="false" checkForThrowsDocblock="true" checkForThrowsInGlobalScope="true" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="https://getpsalm.org/schema/config" xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd"> <psalm totallyTyped="true" resolveFromConfigFile="true" strictBinaryOperands="true" phpVersion="8.1" allowStringToStandInForClass="true" rememberPropertyAssignmentsAfterCall="false" skipChecksOnUnresolvableIncludes="false" checkForThrowsDocblock="true" checkForThrowsInGlobalScope="true" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="https://getpsalm.org/schema/config" xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd">
<projectFiles> <projectFiles>
<directory name="src" /> <directory name="src" />
<ignoreFiles> <ignoreFiles>

View File

@ -39,7 +39,7 @@ final class FunctionReturnTypeProvider implements FunctionReturnTypeProviderInte
if ($array_argument_type instanceof Type\Atomic\TNonEmptyList) { if ($array_argument_type instanceof Type\Atomic\TNonEmptyList) {
$count = $array_argument_type->count; $count = $array_argument_type->count;
if (null === $count) { if (null === $count) {
return Type::getPositiveInt(); return new Type\Union([new Type\Atomic\TIntRange(1, null)]);
} }
return Type::getInt(false, $count); return Type::getInt(false, $count);
@ -48,7 +48,7 @@ final class FunctionReturnTypeProvider implements FunctionReturnTypeProviderInte
if ($array_argument_type instanceof Type\Atomic\TNonEmptyArray) { if ($array_argument_type instanceof Type\Atomic\TNonEmptyArray) {
$count = $array_argument_type->count; $count = $array_argument_type->count;
if (null === $count) { if (null === $count) {
return Type::getPositiveInt(); return new Type\Union([new Type\Atomic\TIntRange(1, null)]);
} }
return Type::getInt(false, $count); return Type::getInt(false, $count);
@ -62,17 +62,15 @@ final class FunctionReturnTypeProvider implements FunctionReturnTypeProviderInte
// return Type::getInt(false, count($array_argument_type->properties)); // return Type::getInt(false, count($array_argument_type->properties));
if (count($array_argument_type->properties) >= 1) { if (count($array_argument_type->properties) >= 1) {
return Type::getPositiveInt(); return new Type\Union([new Type\Atomic\TIntRange(1, null)]);
} }
return Type::getInt(); return Type::getInt();
} }
if ($array_argument_type instanceof Type\Atomic\TArray) { if (($array_argument_type instanceof Type\Atomic\TArray) && $array_argument_type->type_params[0]->isNever() && $array_argument_type->type_params[1]->isNever()) {
if ($array_argument_type->type_params[0]->isEmpty() && $array_argument_type->type_params[1]->isEmpty()) {
return Type::getInt(false, 0); return Type::getInt(false, 0);
} }
}
return Type::getInt(); return Type::getInt();
} }