Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/PseudoTypes/NegativeInteger.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
use phpDocumentor\Reflection\Types\Integer;

/**
* Value Object representing the type 'int'.
* Value Object representing the type 'negative-int'.
*
* @psalm-immutable
*/
Expand Down
36 changes: 36 additions & 0 deletions src/PseudoTypes/NonFalsyString.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?php

declare(strict_types=1);

/**
* This file is part of phpDocumentor.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @link http://phpdoc.org
*/

namespace phpDocumentor\Reflection\PseudoTypes;

use phpDocumentor\Reflection\PseudoType;
use phpDocumentor\Reflection\Type;
use phpDocumentor\Reflection\Types\String_;

/**
* Value Object representing the type 'non-falsy-string'.
*
* @psalm-immutable
*/
final class NonFalsyString extends String_ implements PseudoType
{
public function underlyingType(): Type
{
return new String_();
}

public function __toString(): string
{
return 'non-falsy-string';
}
}
39 changes: 39 additions & 0 deletions src/PseudoTypes/NonNegativeInteger.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?php

declare(strict_types=1);

/**
* This file is part of phpDocumentor.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @link http://phpdoc.org
*/

namespace phpDocumentor\Reflection\PseudoTypes;

use phpDocumentor\Reflection\PseudoType;
use phpDocumentor\Reflection\Type;
use phpDocumentor\Reflection\Types\Integer;

/**
* Value Object representing the type 'non-negative-int'.
*
* @psalm-immutable
*/
final class NonNegativeInteger extends Integer implements PseudoType
{
public function underlyingType(): Type
{
return new Integer();
}

/**
* Returns a rendered output of the Type as it would be used in a DocBlock.
*/
public function __toString(): string
{
return 'non-negative-int';
}
}
36 changes: 36 additions & 0 deletions src/PseudoTypes/NonPositiveInteger.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?php

declare(strict_types=1);

/**
* This file is part of phpDocumentor.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @link http://phpdoc.org
*/

namespace phpDocumentor\Reflection\PseudoTypes;

use phpDocumentor\Reflection\PseudoType;
use phpDocumentor\Reflection\Type;
use phpDocumentor\Reflection\Types\Integer;

/**
* Value Object representing the type 'non-positive-int'.
*
* @psalm-immutable
*/
final class NonPositiveInteger extends Integer implements PseudoType
{
public function underlyingType(): Type
{
return new Integer();
}

public function __toString(): string
{
return 'non-positive-int';
}
}
39 changes: 39 additions & 0 deletions src/PseudoTypes/NonZeroInteger.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?php

declare(strict_types=1);

/**
* This file is part of phpDocumentor.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @link http://phpdoc.org
*/

namespace phpDocumentor\Reflection\PseudoTypes;

use phpDocumentor\Reflection\PseudoType;
use phpDocumentor\Reflection\Type;
use phpDocumentor\Reflection\Types\Integer;

/**
* Value Object representing the type 'non-zero-int'.
*
* @psalm-immutable
*/
final class NonZeroInteger extends Integer implements PseudoType
{
public function underlyingType(): Type
{
return new Integer();
}

/**
* Returns a rendered output of the Type as it would be used in a DocBlock.
*/
public function __toString(): string
{
return 'non-zero-int';
}
}
2 changes: 1 addition & 1 deletion src/PseudoTypes/PositiveInteger.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
use phpDocumentor\Reflection\Types\Integer;

/**
* Value Object representing the type 'int'.
* Value Object representing the type 'positive-int'.
*
* @psalm-immutable
*/
Expand Down
36 changes: 36 additions & 0 deletions src/PseudoTypes/TruthyString.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?php

declare(strict_types=1);

/**
* This file is part of phpDocumentor.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @link http://phpdoc.org
*/

namespace phpDocumentor\Reflection\PseudoTypes;

use phpDocumentor\Reflection\PseudoType;
use phpDocumentor\Reflection\Type;
use phpDocumentor\Reflection\Types\String_;

/**
* Value Object representing the type 'truthy-string'.
*
* @psalm-immutable
*/
final class TruthyString extends String_ implements PseudoType
{
public function underlyingType(): Type
{
return new String_();
}

public function __toString(): string
{
return 'truthy-string';
}
}
10 changes: 10 additions & 0 deletions src/TypeResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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\AggregatedType;
use phpDocumentor\Reflection\Types\Array_;
Expand Down Expand Up @@ -179,6 +184,11 @@ final class TypeResolver
'never' => 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,
];

/**
Expand Down
32 changes: 32 additions & 0 deletions tests/unit/PseudoTypes/NonFalsyStringTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php

declare(strict_types=1);

/**
* This file is part of phpDocumentor.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @link http://phpdoc.org
*/

namespace phpDocumentor\Reflection\PseudoTypes;

use phpDocumentor\Reflection\Types\String_;
use PHPUnit\Framework\TestCase;

final class NonFalsyStringTest extends TestCase
{
public function testCreate(): void
{
$type = new NonFalsyString();

$this->assertEquals(new String_(), $type->underlyingType());
}

public function testToString(): void
{
$this->assertSame('non-falsy-string', (string) (new NonFalsyString()));
}
}
32 changes: 32 additions & 0 deletions tests/unit/PseudoTypes/NonNegativeIntegerTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php

declare(strict_types=1);

/**
* This file is part of phpDocumentor.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @link http://phpdoc.org
*/

namespace phpDocumentor\Reflection\PseudoTypes;

use phpDocumentor\Reflection\Types\Integer;
use PHPUnit\Framework\TestCase;

final class NonNegativeIntegerTest extends TestCase
{
public function testCreate(): void
{
$type = new NonNegativeInteger();

$this->assertEquals(new Integer(), $type->underlyingType());
}

public function testToString(): void
{
$this->assertSame('non-negative-int', (string) (new NonNegativeInteger()));
}
}
32 changes: 32 additions & 0 deletions tests/unit/PseudoTypes/NonPositiveIntegerTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php

declare(strict_types=1);

/**
* This file is part of phpDocumentor.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @link http://phpdoc.org
*/

namespace phpDocumentor\Reflection\PseudoTypes;

use phpDocumentor\Reflection\Types\Integer;
use PHPUnit\Framework\TestCase;

final class NonPositiveIntegerTest extends TestCase
{
public function testCreate(): void
{
$type = new NonPositiveInteger();

$this->assertEquals(new Integer(), $type->underlyingType());
}

public function testToString(): void
{
$this->assertSame('non-positive-int', (string) (new NonPositiveInteger()));
}
}
32 changes: 32 additions & 0 deletions tests/unit/PseudoTypes/NonZeroIntegerTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php

declare(strict_types=1);

/**
* This file is part of phpDocumentor.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @link http://phpdoc.org
*/

namespace phpDocumentor\Reflection\PseudoTypes;

use phpDocumentor\Reflection\Types\Integer;
use PHPUnit\Framework\TestCase;

final class NonZeroIntegerTest extends TestCase
{
public function testCreate(): void
{
$type = new NonZeroInteger();

$this->assertEquals(new Integer(), $type->underlyingType());
}

public function testToString(): void
{
$this->assertSame('non-zero-int', (string) (new NonZeroInteger()));
}
}
Loading