Skip to content

Commit

Permalink
Merge pull request #130 from phpDocumentor/feature/never_type
Browse files Browse the repository at this point in the history
Add support for never keyword
  • Loading branch information
jaapio authored Sep 17, 2021
2 parents 5c67adb + 4d427fa commit 30f38bf
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/TypeResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ final class TypeResolver
'static' => Types\Static_::class,
'parent' => Types\Parent_::class,
'iterable' => Types\Iterable_::class,
'never' => Types\Never_::class,
];

/**
Expand Down
35 changes: 35 additions & 0 deletions src/Types/Never_.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?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\Types;

use phpDocumentor\Reflection\Type;

/**
* Value Object representing the return-type 'never'.
*
* Never is generally only used when working with return types as it signifies that the method that only
* ever throw or exit.
*
* @psalm-immutable
*/
final class Never_ implements Type
{
/**
* Returns a rendered output of the Type as it would be used in a DocBlock.
*/
public function __toString(): string
{
return 'never';
}
}
2 changes: 1 addition & 1 deletion src/Types/Void_.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
use phpDocumentor\Reflection\Type;

/**
* Value Object representing the pseudo-type 'void'.
* Value Object representing the return-type 'void'.
*
* Void is generally only used when working with return types as it signifies that the method intentionally does not
* return any value.
Expand Down
1 change: 1 addition & 0 deletions tests/unit/TypeResolverTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -757,6 +757,7 @@ public function provideKeywords(): array
['self', Types\Self_::class],
['parent', Types\Parent_::class],
['iterable', Types\Iterable_::class],
['never', Types\Never_::class],
];
}

Expand Down

0 comments on commit 30f38bf

Please sign in to comment.