diff --git a/src/PseudoTypes/NegativeInteger.php b/src/PseudoTypes/NegativeInteger.php index c51d3fe..ebcab6f 100644 --- a/src/PseudoTypes/NegativeInteger.php +++ b/src/PseudoTypes/NegativeInteger.php @@ -18,7 +18,7 @@ use phpDocumentor\Reflection\Types\Integer; /** - * Value Object representing the type 'int'. + * Value Object representing the type 'negative-int'. * * @psalm-immutable */ diff --git a/src/PseudoTypes/NonFalsyString.php b/src/PseudoTypes/NonFalsyString.php new file mode 100644 index 0000000..9063f74 --- /dev/null +++ b/src/PseudoTypes/NonFalsyString.php @@ -0,0 +1,36 @@ + Never_::class, 'list' => List_::class, 'non-empty-list' => NonEmptyList::class, + 'non-falsy-string' => NonFalsyString::class, + 'truthy-string' => TruthyString::class, + 'non-positive-int' => NonPositiveInteger::class, + 'non-negative-int' => NonNegativeInteger::class, + 'non-zero-int' => NonZeroInteger::class, ]; /** diff --git a/tests/unit/PseudoTypes/NonFalsyStringTest.php b/tests/unit/PseudoTypes/NonFalsyStringTest.php new file mode 100644 index 0000000..ada455e --- /dev/null +++ b/tests/unit/PseudoTypes/NonFalsyStringTest.php @@ -0,0 +1,32 @@ +assertEquals(new String_(), $type->underlyingType()); + } + + public function testToString(): void + { + $this->assertSame('non-falsy-string', (string) (new NonFalsyString())); + } +} diff --git a/tests/unit/PseudoTypes/NonNegativeIntegerTest.php b/tests/unit/PseudoTypes/NonNegativeIntegerTest.php new file mode 100644 index 0000000..5ccf66e --- /dev/null +++ b/tests/unit/PseudoTypes/NonNegativeIntegerTest.php @@ -0,0 +1,32 @@ +assertEquals(new Integer(), $type->underlyingType()); + } + + public function testToString(): void + { + $this->assertSame('non-negative-int', (string) (new NonNegativeInteger())); + } +} diff --git a/tests/unit/PseudoTypes/NonPositiveIntegerTest.php b/tests/unit/PseudoTypes/NonPositiveIntegerTest.php new file mode 100644 index 0000000..dcdf085 --- /dev/null +++ b/tests/unit/PseudoTypes/NonPositiveIntegerTest.php @@ -0,0 +1,32 @@ +assertEquals(new Integer(), $type->underlyingType()); + } + + public function testToString(): void + { + $this->assertSame('non-positive-int', (string) (new NonPositiveInteger())); + } +} diff --git a/tests/unit/PseudoTypes/NonZeroIntegerTest.php b/tests/unit/PseudoTypes/NonZeroIntegerTest.php new file mode 100644 index 0000000..4ed3bf3 --- /dev/null +++ b/tests/unit/PseudoTypes/NonZeroIntegerTest.php @@ -0,0 +1,32 @@ +assertEquals(new Integer(), $type->underlyingType()); + } + + public function testToString(): void + { + $this->assertSame('non-zero-int', (string) (new NonZeroInteger())); + } +} diff --git a/tests/unit/PseudoTypes/TruthyStringTest.php b/tests/unit/PseudoTypes/TruthyStringTest.php new file mode 100644 index 0000000..5bf781c --- /dev/null +++ b/tests/unit/PseudoTypes/TruthyStringTest.php @@ -0,0 +1,32 @@ +assertEquals(new String_(), $type->underlyingType()); + } + + public function testToString(): void + { + $this->assertSame('truthy-string', (string) (new TruthyString())); + } +} diff --git a/tests/unit/TypeResolverTest.php b/tests/unit/TypeResolverTest.php index 4919aa1..287688f 100644 --- a/tests/unit/TypeResolverTest.php +++ b/tests/unit/TypeResolverTest.php @@ -44,6 +44,10 @@ use phpDocumentor\Reflection\PseudoTypes\NonEmptyList; use phpDocumentor\Reflection\PseudoTypes\NonEmptyLowercaseString; use phpDocumentor\Reflection\PseudoTypes\NonEmptyString; +use phpDocumentor\Reflection\PseudoTypes\NonFalsyString; +use phpDocumentor\Reflection\PseudoTypes\NonNegativeInteger; +use phpDocumentor\Reflection\PseudoTypes\NonPositiveInteger; +use phpDocumentor\Reflection\PseudoTypes\NonZeroInteger; use phpDocumentor\Reflection\PseudoTypes\Numeric_; use phpDocumentor\Reflection\PseudoTypes\NumericString; use phpDocumentor\Reflection\PseudoTypes\ObjectShape; @@ -58,6 +62,7 @@ use phpDocumentor\Reflection\PseudoTypes\StringValue; use phpDocumentor\Reflection\PseudoTypes\TraitString; use phpDocumentor\Reflection\PseudoTypes\True_; +use phpDocumentor\Reflection\PseudoTypes\TruthyString; use phpDocumentor\Reflection\PseudoTypes\ValueOf; use phpDocumentor\Reflection\Types\Array_; use phpDocumentor\Reflection\Types\Boolean; @@ -675,6 +680,11 @@ public function provideKeywords(): array ['list', List_::class], ['non-empty-list', NonEmptyList::class], ['non-empty-array', NonEmptyArray::class], + ['non-falsy-string', NonFalsyString::class], + ['truthy-string', TruthyString::class], + ['non-positive-int', NonPositiveInteger::class], + ['non-negative-int', NonNegativeInteger::class], + ['non-zero-int', NonZeroInteger::class], ]; } @@ -1155,6 +1165,14 @@ public function callableProvider(): array 'callable', new Callable_(), ], + [ + 'pure-callable(int): int', + new Callable_( + 'pure-callable', + [new CallableParameter(new Integer())], + new Integer() + ), + ], [ 'callable()', new Callable_(), diff --git a/tests/unit/Types/CallableTest.php b/tests/unit/Types/CallableTest.php index 6eca238..a99e048 100644 --- a/tests/unit/Types/CallableTest.php +++ b/tests/unit/Types/CallableTest.php @@ -72,6 +72,14 @@ public static function provideToStringData(): array 'callable', new Callable_(), ], + 'pure' => [ + 'pure-callable(int): int', + new Callable_( + 'pure-callable', + [new CallableParameter(new Integer())], + new Integer() + ), + ], 'closure' => [ '\Closure', new Callable_('\Closure'),