Skip to content

Commit 30f38bf

Browse files
authored
Merge pull request #130 from phpDocumentor/feature/never_type
Add support for never keyword
2 parents 5c67adb + 4d427fa commit 30f38bf

File tree

4 files changed

+38
-1
lines changed

4 files changed

+38
-1
lines changed

src/TypeResolver.php

+1
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ final class TypeResolver
107107
'static' => Types\Static_::class,
108108
'parent' => Types\Parent_::class,
109109
'iterable' => Types\Iterable_::class,
110+
'never' => Types\Never_::class,
110111
];
111112

112113
/**

src/Types/Never_.php

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
/**
6+
* This file is part of phpDocumentor.
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*
11+
* @link http://phpdoc.org
12+
*/
13+
14+
namespace phpDocumentor\Reflection\Types;
15+
16+
use phpDocumentor\Reflection\Type;
17+
18+
/**
19+
* Value Object representing the return-type 'never'.
20+
*
21+
* Never is generally only used when working with return types as it signifies that the method that only
22+
* ever throw or exit.
23+
*
24+
* @psalm-immutable
25+
*/
26+
final class Never_ implements Type
27+
{
28+
/**
29+
* Returns a rendered output of the Type as it would be used in a DocBlock.
30+
*/
31+
public function __toString(): string
32+
{
33+
return 'never';
34+
}
35+
}

src/Types/Void_.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
use phpDocumentor\Reflection\Type;
1717

1818
/**
19-
* Value Object representing the pseudo-type 'void'.
19+
* Value Object representing the return-type 'void'.
2020
*
2121
* Void is generally only used when working with return types as it signifies that the method intentionally does not
2222
* return any value.

tests/unit/TypeResolverTest.php

+1
Original file line numberDiff line numberDiff line change
@@ -757,6 +757,7 @@ public function provideKeywords(): array
757757
['self', Types\Self_::class],
758758
['parent', Types\Parent_::class],
759759
['iterable', Types\Iterable_::class],
760+
['never', Types\Never_::class],
760761
];
761762
}
762763

0 commit comments

Comments
 (0)