File tree Expand file tree Collapse file tree 5 files changed +73
-1
lines changed
Expand file tree Collapse file tree 5 files changed +73
-1
lines changed Original file line number Diff line number Diff line change 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 \PseudoTypes ;
15+
16+ use phpDocumentor \Reflection \PseudoType ;
17+ use phpDocumentor \Reflection \Type ;
18+ use phpDocumentor \Reflection \Types \Never_ ;
19+
20+ /**
21+ * Value Object representing the type 'never-return'.
22+ *
23+ * @psalm-immutable
24+ */
25+ final class NeverReturn extends Never_ implements PseudoType
26+ {
27+ public function underlyingType (): Type
28+ {
29+ return new Never_ ();
30+ }
31+
32+ public function __toString (): string
33+ {
34+ return 'never-return ' ;
35+ }
36+ }
Original file line number Diff line number Diff line change 4040use phpDocumentor \Reflection \PseudoTypes \LiteralString ;
4141use phpDocumentor \Reflection \PseudoTypes \LowercaseString ;
4242use phpDocumentor \Reflection \PseudoTypes \NegativeInteger ;
43+ use phpDocumentor \Reflection \PseudoTypes \NeverReturn ;
4344use phpDocumentor \Reflection \PseudoTypes \NonEmptyArray ;
4445use phpDocumentor \Reflection \PseudoTypes \NonEmptyList ;
4546use phpDocumentor \Reflection \PseudoTypes \NonEmptyLowercaseString ;
@@ -182,6 +183,7 @@ final class TypeResolver
182183 'parent ' => Parent_::class,
183184 'iterable ' => Iterable_::class,
184185 'never ' => Never_::class,
186+ 'never-return ' => NeverReturn::class,
185187 'list ' => List_::class,
186188 'non-empty-list ' => NonEmptyList::class,
187189 'non-falsy-string ' => NonFalsyString::class,
Original file line number Diff line number Diff line change 2323 *
2424 * @psalm-immutable
2525 */
26- final class Never_ implements Type
26+ class Never_ implements Type
2727{
2828 /**
2929 * Returns a rendered output of the Type as it would be used in a DocBlock.
Original file line number Diff line number Diff line change 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 \PseudoTypes ;
15+
16+ use phpDocumentor \Reflection \Types \Never_ ;
17+ use PHPUnit \Framework \TestCase ;
18+
19+ final class NeverReturnTest extends TestCase
20+ {
21+ public function testCreate (): void
22+ {
23+ $ type = new NeverReturn ();
24+
25+ $ this ->assertEquals (new Never_ (), $ type ->underlyingType ());
26+ }
27+
28+ public function testToString (): void
29+ {
30+ $ this ->assertSame ('never-return ' , (string ) (new NeverReturn ()));
31+ }
32+ }
Original file line number Diff line number Diff line change 4040use phpDocumentor \Reflection \PseudoTypes \LiteralString ;
4141use phpDocumentor \Reflection \PseudoTypes \LowercaseString ;
4242use phpDocumentor \Reflection \PseudoTypes \NegativeInteger ;
43+ use phpDocumentor \Reflection \PseudoTypes \NeverReturn ;
4344use phpDocumentor \Reflection \PseudoTypes \NonEmptyArray ;
4445use phpDocumentor \Reflection \PseudoTypes \NonEmptyList ;
4546use phpDocumentor \Reflection \PseudoTypes \NonEmptyLowercaseString ;
@@ -676,6 +677,7 @@ public function provideKeywords(): array
676677 ['parent ' , Parent_::class],
677678 ['iterable ' , Iterable_::class],
678679 ['never ' , Never_::class],
680+ ['never-return ' , NeverReturn::class],
679681 ['literal-string ' , LiteralString::class],
680682 ['list ' , List_::class],
681683 ['non-empty-list ' , NonEmptyList::class],
You can’t perform that action at this time.
0 commit comments