1
0
mirror of https://github.com/danog/psalm.git synced 2024-11-27 04:45:20 +01:00

Remove irrelevant types, use keep aliases

This commit is contained in:
William Owen O. Ponce 2022-10-05 09:09:56 +08:00
parent 04c9fe89c1
commit ae426a00ce
4 changed files with 3 additions and 141 deletions

View File

@ -45,7 +45,6 @@ use Psalm\Type\Atomic\TLiteralString;
use Psalm\Type\Atomic\TLowercaseString;
use Psalm\Type\Atomic\TMixed;
use Psalm\Type\Atomic\TNamedObject;
use Psalm\Type\Atomic\TNegativeInt;
use Psalm\Type\Atomic\TNever;
use Psalm\Type\Atomic\TNonEmptyArray;
use Psalm\Type\Atomic\TNonEmptyList;
@ -55,8 +54,6 @@ use Psalm\Type\Atomic\TNonEmptyNonspecificLiteralString;
use Psalm\Type\Atomic\TNonEmptyScalar;
use Psalm\Type\Atomic\TNonEmptyString;
use Psalm\Type\Atomic\TNonFalsyString;
use Psalm\Type\Atomic\TNonNegativeInt;
use Psalm\Type\Atomic\TNonPositiveInt;
use Psalm\Type\Atomic\TNonspecificLiteralInt;
use Psalm\Type\Atomic\TNonspecificLiteralString;
use Psalm\Type\Atomic\TNull;
@ -234,13 +231,13 @@ abstract class Atomic implements TypeNode
return new TPositiveInt();
case 'non-positive-int':
return new TNonPositiveInt();
return new TIntRange(null, -1);
case 'negative-int':
return new TNegativeInt();
return new TIntRange(null, -1);
case 'non-negative-int':
return new TNonNegativeInt();
return new TPositiveInt();
case 'numeric':
return $php_version !== null ? new TNamedObject($value) : new TNumeric();
@ -732,18 +729,6 @@ abstract class Atomic implements TypeNode
return true;
}
if ($this instanceof TNonPositiveInt) {
return true;
}
if ($this instanceof TNegativeInt) {
return true;
}
if ($this instanceof TNonNegativeInt) {
return true;
}
if ($this instanceof TLiteralClassString) {
return true;
}

View File

@ -1,41 +0,0 @@
<?php
namespace Psalm\Type\Atomic;
/**
* Denotes an int that is also negative (strictly < 0)
* @deprecated will be removed in Psalm 5
*/
class TNegativeInt extends TInt
{
public function getId(bool $nested = false): string
{
return 'negative-int';
}
public function __toString(): string
{
return 'negative-int';
}
/**
* @return false
*/
public function canBeFullyExpressedInPhp(int $php_major_version, int $php_minor_version): bool
{
return false;
}
/**
* @param array<lowercase-string, string> $aliased_classes
*
*/
public function toNamespacedString(
?string $namespace,
array $aliased_classes,
?string $this_class,
bool $use_phpdoc_format
): string {
return $use_phpdoc_format ? 'int' : 'negative-int';
}
}

View File

@ -1,41 +0,0 @@
<?php
namespace Psalm\Type\Atomic;
/**
* Denotes an int that is also non-negative (strictly > 0)
* @deprecated will be removed in Psalm 5
*/
class TNonNegativeInt extends TInt
{
public function getId(bool $nested = false): string
{
return 'non-negative-int';
}
public function __toString(): string
{
return 'non-negative-int';
}
/**
* @return false
*/
public function canBeFullyExpressedInPhp(int $php_major_version, int $php_minor_version): bool
{
return false;
}
/**
* @param array<lowercase-string, string> $aliased_classes
*
*/
public function toNamespacedString(
?string $namespace,
array $aliased_classes,
?string $this_class,
bool $use_phpdoc_format
): string {
return $use_phpdoc_format ? 'int' : 'non-negative-int';
}
}

View File

@ -1,41 +0,0 @@
<?php
namespace Psalm\Type\Atomic;
/**
* Denotes an int that is also non non-positive (strictly < 0)
* @deprecated will be removed in Psalm 5
*/
class TNonPositiveInt extends TInt
{
public function getId(bool $nested = false): string
{
return 'non-positive-int';
}
public function __toString(): string
{
return 'non-positive-int';
}
/**
* @return false
*/
public function canBeFullyExpressedInPhp(int $php_major_version, int $php_minor_version): bool
{
return false;
}
/**
* @param array<lowercase-string, string> $aliased_classes
*
*/
public function toNamespacedString(
?string $namespace,
array $aliased_classes,
?string $this_class,
bool $use_phpdoc_format
): string {
return $use_phpdoc_format ? 'int' : 'non-positive-int';
}
}