Skip to content

Commit

Permalink
Fix merge errors
Browse files Browse the repository at this point in the history
  • Loading branch information
muglug committed Dec 15, 2021
1 parent fcafa20 commit 1f8546c
Show file tree
Hide file tree
Showing 17 changed files with 18 additions and 66 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -236,12 +236,12 @@ public static function verifyReturnType(
}

$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();
}
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@
use Psalm\Type\Atomic\Scalar;
use Psalm\Type\Atomic\TArray;
use Psalm\Type\Atomic\TDependentListKey;
use Psalm\Type\Atomic\TEmpty;
use Psalm\Type\Atomic\TFalse;
use Psalm\Type\Atomic\TGenericObject;
use Psalm\Type\Atomic\TIntRange;
Expand All @@ -49,9 +48,9 @@
use Psalm\Type\Atomic\TList;
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\TNever;
use Psalm\Type\Atomic\TNull;
use Psalm\Type\Atomic\TObject;
use Psalm\Type\Atomic\TObjectWithProperties;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@
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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@
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;
Expand Down
2 changes: 1 addition & 1 deletion src/Psalm/Internal/Codebase/ConstantTypeResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,14 @@
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;
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;
Expand Down
1 change: 0 additions & 1 deletion src/Psalm/Internal/Stubs/Generator/StubsGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
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;
Expand Down
1 change: 0 additions & 1 deletion src/Psalm/Internal/Type/Comparator/ArrayTypeComparator.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
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;
Expand Down
6 changes: 3 additions & 3 deletions src/Psalm/Internal/Type/SimpleAssertionReconciler.php
Original file line number Diff line number Diff line change
Expand Up @@ -2279,7 +2279,7 @@ private static function reconcileFalsyOrEmpty(

$failed_reconciliation = 2;

return Type::getEmpty();
return Type::getNever();
}

if (!$did_remove_type) {
Expand Down Expand Up @@ -2311,8 +2311,8 @@ private static function reconcileFalsyOrEmpty(
$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()]),
]
));
}
Expand Down
4 changes: 2 additions & 2 deletions src/Psalm/Internal/Type/SimpleNegatedAssertionReconciler.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
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;
Expand All @@ -34,7 +35,6 @@
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;
Expand Down Expand Up @@ -618,7 +618,7 @@ private static function reconcileFalsyOrEmpty(

$failed_reconciliation = 2;

return Type::getEmpty();
return Type::getNever();
}

if (!$did_remove_type) {
Expand Down
6 changes: 2 additions & 4 deletions src/Psalm/Internal/Type/TypeExpander.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
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;
Expand Down Expand Up @@ -825,13 +824,12 @@ private static function expandConditional(
);

$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;
}
);
}
Expand Down
10 changes: 0 additions & 10 deletions src/Psalm/Type.php
Original file line number Diff line number Diff line change
Expand Up @@ -304,16 +304,6 @@ public static function getScalar(): Union
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();
Expand Down
4 changes: 3 additions & 1 deletion src/Psalm/Type/Atomic/TAssertionEmpty.php
Original file line number Diff line number Diff line change
@@ -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
{
Expand Down
33 changes: 0 additions & 33 deletions src/Psalm/Type/Atomic/TEmpty.php

This file was deleted.

2 changes: 1 addition & 1 deletion src/Psalm/Type/Union.php
Original file line number Diff line number Diff line change
Expand Up @@ -1064,7 +1064,7 @@ public function isAlwaysFalsy(): bool
continue;
}

if ($atomic_type instanceof TArray && $atomic_type->getId() === 'array<empty, empty>') {
if ($atomic_type instanceof TArray && $atomic_type->getId() === 'array<never, never>') {
continue;
}

Expand Down
2 changes: 1 addition & 1 deletion tests/EnumTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ enum Status: int {}
$_z = Status::cases();
',
'assertions' => [
'$_z===' => 'array<empty, empty>',
'$_z===' => 'array<never, never>',
],
[],
'8.1',
Expand Down
2 changes: 1 addition & 1 deletion tests/TypeReconciliation/ReconcilerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ public function providerTestReconcilation(): array
'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'],
Expand Down

0 comments on commit 1f8546c

Please sign in to comment.