mirror of
https://github.com/danog/psalm.git
synced 2024-11-30 04:39:00 +01:00
Fix merge errors
This commit is contained in:
parent
0747b48d06
commit
2358b96f54
@ -237,12 +237,12 @@ class ReturnTypeAnalyzer
|
||||
}
|
||||
|
||||
$number_of_types = count($inferred_return_type_parts);
|
||||
// we filter TNever and TEmpty that have no bearing on the return type
|
||||
// we filter TNever that have no bearing on the return type
|
||||
if ($number_of_types > 1) {
|
||||
$inferred_return_type_parts = array_filter(
|
||||
$inferred_return_type_parts,
|
||||
static function (Union $union_type): bool {
|
||||
return !($union_type->isNever() || $union_type->isEmpty());
|
||||
return !$union_type->isNever();
|
||||
}
|
||||
);
|
||||
}
|
||||
|
@ -45,7 +45,6 @@ use Psalm\Type\Atomic\TString;
|
||||
use Psalm\Type\Atomic\TTemplateParam;
|
||||
use Psalm\Type\Union;
|
||||
|
||||
use Psalm\Type\Union;
|
||||
use function array_diff_key;
|
||||
use function array_values;
|
||||
use function count;
|
||||
|
@ -27,12 +27,12 @@ use Psalm\StatementsSource;
|
||||
use Psalm\Storage\ClassLikeStorage;
|
||||
use Psalm\Type;
|
||||
use Psalm\Type\Atomic;
|
||||
use Psalm\Type\Atomic\TEmpty;
|
||||
use Psalm\Type\Atomic\TEmptyMixed;
|
||||
use Psalm\Type\Atomic\TFalse;
|
||||
use Psalm\Type\Atomic\TGenericObject;
|
||||
use Psalm\Type\Atomic\TMixed;
|
||||
use Psalm\Type\Atomic\TNamedObject;
|
||||
use Psalm\Type\Atomic\TNever;
|
||||
use Psalm\Type\Atomic\TNonEmptyMixed;
|
||||
use Psalm\Type\Atomic\TNull;
|
||||
use Psalm\Type\Atomic\TObject;
|
||||
|
@ -25,7 +25,6 @@ use Psalm\Internal\Scanner\UnresolvedConstantComponent;
|
||||
use Psalm\Type;
|
||||
use Psalm\Type\Atomic;
|
||||
use Psalm\Type\Atomic\TArray;
|
||||
use Psalm\Type\Atomic\TEmpty;
|
||||
use Psalm\Type\Atomic\TFalse;
|
||||
use Psalm\Type\Atomic\TKeyedArray;
|
||||
use Psalm\Type\Atomic\TLiteralClassString;
|
||||
@ -33,6 +32,7 @@ use Psalm\Type\Atomic\TLiteralFloat;
|
||||
use Psalm\Type\Atomic\TLiteralInt;
|
||||
use Psalm\Type\Atomic\TLiteralString;
|
||||
use Psalm\Type\Atomic\TMixed;
|
||||
use Psalm\Type\Atomic\TNever;
|
||||
use Psalm\Type\Atomic\TNull;
|
||||
use Psalm\Type\Atomic\TString;
|
||||
use Psalm\Type\Atomic\TTrue;
|
||||
|
@ -27,7 +27,6 @@ use Psalm\Type\Atomic\TDependentGetClass;
|
||||
use Psalm\Type\Atomic\TDependentGetDebugType;
|
||||
use Psalm\Type\Atomic\TDependentGetType;
|
||||
use Psalm\Type\Atomic\TDependentListKey;
|
||||
use Psalm\Type\Atomic\TEmpty;
|
||||
use Psalm\Type\Atomic\TEmptyMixed;
|
||||
use Psalm\Type\Atomic\TEmptyNumeric;
|
||||
use Psalm\Type\Atomic\TEmptyScalar;
|
||||
|
@ -7,7 +7,6 @@ use Psalm\Type;
|
||||
use Psalm\Type\Atomic;
|
||||
use Psalm\Type\Atomic\TArray;
|
||||
use Psalm\Type\Atomic\TClassStringMap;
|
||||
use Psalm\Type\Atomic\TEmpty;
|
||||
use Psalm\Type\Atomic\TKeyedArray;
|
||||
use Psalm\Type\Atomic\TList;
|
||||
use Psalm\Type\Atomic\TLiteralInt;
|
||||
|
@ -15,7 +15,6 @@ use Psalm\Type\Atomic\TCallableString;
|
||||
use Psalm\Type\Atomic\TClassStringMap;
|
||||
use Psalm\Type\Atomic\TClosure;
|
||||
use Psalm\Type\Atomic\TConditional;
|
||||
use Psalm\Type\Atomic\TEmpty;
|
||||
use Psalm\Type\Atomic\TEmptyMixed;
|
||||
use Psalm\Type\Atomic\TEnumCase;
|
||||
use Psalm\Type\Atomic\TGenericObject;
|
||||
|
@ -2272,7 +2272,7 @@ class SimpleAssertionReconciler extends Reconciler
|
||||
|
||||
$failed_reconciliation = 2;
|
||||
|
||||
return Type::getEmpty();
|
||||
return Type::getNever();
|
||||
}
|
||||
|
||||
if (!$did_remove_type) {
|
||||
@ -2304,8 +2304,8 @@ class SimpleAssertionReconciler extends Reconciler
|
||||
$existing_var_type->removeType('array');
|
||||
$existing_var_type->addType(new TArray(
|
||||
[
|
||||
new Union([new TEmpty()]),
|
||||
new Union([new TEmpty()]),
|
||||
new Union([new TNever()]),
|
||||
new Union([new TNever()]),
|
||||
]
|
||||
));
|
||||
}
|
||||
|
@ -30,6 +30,7 @@ use Psalm\Type\Atomic\TLiteralString;
|
||||
use Psalm\Type\Atomic\TLowercaseString;
|
||||
use Psalm\Type\Atomic\TMixed;
|
||||
use Psalm\Type\Atomic\TNamedObject;
|
||||
use Psalm\Type\Atomic\TNever;
|
||||
use Psalm\Type\Atomic\TNonEmptyArray;
|
||||
use Psalm\Type\Atomic\TNonEmptyList;
|
||||
use Psalm\Type\Atomic\TNonEmptyLowercaseString;
|
||||
@ -39,7 +40,6 @@ use Psalm\Type\Atomic\TNonEmptyScalar;
|
||||
use Psalm\Type\Atomic\TNonEmptyString;
|
||||
use Psalm\Type\Atomic\TNonFalsyString;
|
||||
use Psalm\Type\Atomic\TNonspecificLiteralString;
|
||||
use Psalm\Type\Atomic\TNever;
|
||||
use Psalm\Type\Atomic\TNumeric;
|
||||
use Psalm\Type\Atomic\TPositiveInt;
|
||||
use Psalm\Type\Atomic\TScalar;
|
||||
@ -714,7 +714,7 @@ class SimpleNegatedAssertionReconciler extends Reconciler
|
||||
|
||||
$failed_reconciliation = 2;
|
||||
|
||||
return Type::getEmpty();
|
||||
return Type::getNever();
|
||||
}
|
||||
|
||||
if (!$did_remove_type) {
|
||||
|
@ -14,7 +14,6 @@ use Psalm\Type\Atomic\TClassConstant;
|
||||
use Psalm\Type\Atomic\TClassString;
|
||||
use Psalm\Type\Atomic\TClosure;
|
||||
use Psalm\Type\Atomic\TConditional;
|
||||
use Psalm\Type\Atomic\TEmpty;
|
||||
use Psalm\Type\Atomic\TGenericObject;
|
||||
use Psalm\Type\Atomic\TInt;
|
||||
use Psalm\Type\Atomic\TIntMask;
|
||||
@ -827,13 +826,12 @@ class TypeExpander
|
||||
);
|
||||
|
||||
$number_of_types = count($all_conditional_return_types);
|
||||
// we filter TNever and TEmpty that have no bearing on the return type
|
||||
// we filter TNever that have no bearing on the return type
|
||||
if ($number_of_types > 1) {
|
||||
$all_conditional_return_types = array_filter(
|
||||
$all_conditional_return_types,
|
||||
static function (Atomic $atomic_type): bool {
|
||||
return !($atomic_type instanceof TEmpty
|
||||
|| $atomic_type instanceof TNever);
|
||||
return !$atomic_type instanceof TNever;
|
||||
}
|
||||
);
|
||||
}
|
||||
|
@ -305,16 +305,6 @@ abstract class Type
|
||||
return new Union([$type]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated will be removed in Psalm 5. See getNever to retrieve a TNever that replaces TEmpty
|
||||
*/
|
||||
public static function getEmpty(): Union
|
||||
{
|
||||
$type = new TNever();
|
||||
|
||||
return new Union([$type]);
|
||||
}
|
||||
|
||||
public static function getNever(): Union
|
||||
{
|
||||
$type = new TNever();
|
||||
|
@ -1,10 +1,12 @@
|
||||
<?php
|
||||
namespace Psalm\Type\Atomic;
|
||||
|
||||
use Psalm\Type\Atomic;
|
||||
|
||||
/**
|
||||
* Represents any value that returns true to empty(). This is used for assertions
|
||||
*/
|
||||
class TAssertionEmpty extends \Psalm\Type\Atomic
|
||||
class TAssertionEmpty extends Atomic
|
||||
{
|
||||
public function __toString(): string
|
||||
{
|
||||
|
@ -1,33 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Psalm\Type\Atomic;
|
||||
|
||||
/**
|
||||
* Denotes the `empty` type, used to describe a type corresponding to no value whatsoever.
|
||||
* Empty arrays `[]` have the type `array<empty, empty>`.
|
||||
* @deprecated Will be replaced by TNever when in type context and TAssertionEmpty for assertion context in Psalm 5
|
||||
*/
|
||||
class TEmpty extends Scalar
|
||||
{
|
||||
public function __toString(): string
|
||||
{
|
||||
return 'empty';
|
||||
}
|
||||
|
||||
public function getKey(bool $include_extra = true): string
|
||||
{
|
||||
return 'empty';
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<lowercase-string, string> $aliased_classes
|
||||
*/
|
||||
public function toPhpString(
|
||||
?string $namespace,
|
||||
array $aliased_classes,
|
||||
?string $this_class,
|
||||
int $analysis_php_version_id
|
||||
): ?string {
|
||||
return null;
|
||||
}
|
||||
}
|
@ -274,7 +274,7 @@ class EnumTest extends TestCase
|
||||
$_z = Status::cases();
|
||||
',
|
||||
'assertions' => [
|
||||
'$_z===' => 'array<empty, empty>',
|
||||
'$_z===' => 'array<never, never>',
|
||||
],
|
||||
[],
|
||||
'8.1',
|
||||
|
@ -104,7 +104,7 @@ class ReconcilerTest extends TestCase
|
||||
'nullWithSomeClassPipeNull' => ['null', 'null', 'SomeClass|null'],
|
||||
'nullWithMixed' => ['null', 'null', 'mixed'],
|
||||
|
||||
'falsyWithSomeClass' => ['empty', 'falsy', 'SomeClass'],
|
||||
'falsyWithSomeClass' => ['never', 'falsy', 'SomeClass'],
|
||||
'falsyWithSomeClassPipeFalse' => ['false', 'falsy', 'SomeClass|false'],
|
||||
'falsyWithSomeClassPipeBool' => ['false', 'falsy', 'SomeClass|bool'],
|
||||
'falsyWithMixed' => ['empty-mixed', 'falsy', 'mixed'],
|
||||
|
Loading…
Reference in New Issue
Block a user