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
36 changes: 36 additions & 0 deletions src/PseudoTypes/NeverReturn.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\Never_;

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

public function __toString(): string
{
return 'never-return';
}
}
36 changes: 36 additions & 0 deletions src/PseudoTypes/NeverReturns.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\Never_;

/**
* Value Object representing the type 'never-returns'.
*
* @psalm-immutable
*/
final class NeverReturns extends Never_ implements PseudoType
{
public function underlyingType(): Type
{
return new Never_();
}

public function __toString(): string
{
return 'never-returns';
}
}
36 changes: 36 additions & 0 deletions src/PseudoTypes/NoReturn.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\Never_;

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

public function __toString(): string
{
return 'no-return';
}
}
6 changes: 6 additions & 0 deletions src/TypeResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@
use phpDocumentor\Reflection\PseudoTypes\LiteralString;
use phpDocumentor\Reflection\PseudoTypes\LowercaseString;
use phpDocumentor\Reflection\PseudoTypes\NegativeInteger;
use phpDocumentor\Reflection\PseudoTypes\NeverReturn;
use phpDocumentor\Reflection\PseudoTypes\NeverReturns;
use phpDocumentor\Reflection\PseudoTypes\NonEmptyArray;
use phpDocumentor\Reflection\PseudoTypes\NonEmptyList;
use phpDocumentor\Reflection\PseudoTypes\NonEmptyLowercaseString;
Expand All @@ -48,6 +50,7 @@
use phpDocumentor\Reflection\PseudoTypes\NonNegativeInteger;
use phpDocumentor\Reflection\PseudoTypes\NonPositiveInteger;
use phpDocumentor\Reflection\PseudoTypes\NonZeroInteger;
use phpDocumentor\Reflection\PseudoTypes\NoReturn;
use phpDocumentor\Reflection\PseudoTypes\Numeric_;
use phpDocumentor\Reflection\PseudoTypes\NumericString;
use phpDocumentor\Reflection\PseudoTypes\ObjectShape;
Expand Down Expand Up @@ -182,6 +185,9 @@ final class TypeResolver
'parent' => Parent_::class,
'iterable' => Iterable_::class,
'never' => Never_::class,
'never-return' => NeverReturn::class,
'never-returns' => NeverReturns::class,
'no-return' => NoReturn::class,
'list' => List_::class,
'non-empty-list' => NonEmptyList::class,
'non-falsy-string' => NonFalsyString::class,
Expand Down
2 changes: 1 addition & 1 deletion src/Types/Never_.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
*
* @psalm-immutable
*/
final class Never_ implements Type
class Never_ implements Type
{
/**
* Returns a rendered output of the Type as it would be used in a DocBlock.
Expand Down
32 changes: 32 additions & 0 deletions tests/unit/PseudoTypes/NeverReturnTest.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\Never_;
use PHPUnit\Framework\TestCase;

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

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

public function testToString(): void
{
$this->assertSame('never-return', (string) (new NeverReturn()));
}
}
32 changes: 32 additions & 0 deletions tests/unit/PseudoTypes/NeverReturnsTest.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\Never_;
use PHPUnit\Framework\TestCase;

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

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

public function testToString(): void
{
$this->assertSame('never-returns', (string) (new NeverReturns()));
}
}
32 changes: 32 additions & 0 deletions tests/unit/PseudoTypes/NoReturnTest.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\Never_;
use PHPUnit\Framework\TestCase;

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

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

public function testToString(): void
{
$this->assertSame('no-return', (string) (new NoReturn()));
}
}
6 changes: 6 additions & 0 deletions tests/unit/TypeResolverTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@
use phpDocumentor\Reflection\PseudoTypes\LiteralString;
use phpDocumentor\Reflection\PseudoTypes\LowercaseString;
use phpDocumentor\Reflection\PseudoTypes\NegativeInteger;
use phpDocumentor\Reflection\PseudoTypes\NeverReturn;
use phpDocumentor\Reflection\PseudoTypes\NeverReturns;
use phpDocumentor\Reflection\PseudoTypes\NonEmptyArray;
use phpDocumentor\Reflection\PseudoTypes\NonEmptyList;
use phpDocumentor\Reflection\PseudoTypes\NonEmptyLowercaseString;
Expand All @@ -48,6 +50,7 @@
use phpDocumentor\Reflection\PseudoTypes\NonNegativeInteger;
use phpDocumentor\Reflection\PseudoTypes\NonPositiveInteger;
use phpDocumentor\Reflection\PseudoTypes\NonZeroInteger;
use phpDocumentor\Reflection\PseudoTypes\NoReturn;
use phpDocumentor\Reflection\PseudoTypes\Numeric_;
use phpDocumentor\Reflection\PseudoTypes\NumericString;
use phpDocumentor\Reflection\PseudoTypes\ObjectShape;
Expand Down Expand Up @@ -676,6 +679,9 @@ public function provideKeywords(): array
['parent', Parent_::class],
['iterable', Iterable_::class],
['never', Never_::class],
['never-return', NeverReturn::class],
['never-returns', NeverReturns::class],
['no-return', NoReturn::class],
['literal-string', LiteralString::class],
['list', List_::class],
['non-empty-list', NonEmptyList::class],
Expand Down