File tree Expand file tree Collapse file tree 4 files changed +75
-0
lines changed
Expand file tree Collapse file tree 4 files changed +75
-0
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 \Integer ;
19+
20+ /**
21+ * Value Object representing the type 'non-negative-int'.
22+ *
23+ * @psalm-immutable
24+ */
25+ final class NonNegativeInteger extends Integer implements PseudoType
26+ {
27+ public function underlyingType (): Type
28+ {
29+ return new Integer ();
30+ }
31+
32+ /**
33+ * Returns a rendered output of the Type as it would be used in a DocBlock.
34+ */
35+ public function __toString (): string
36+ {
37+ return 'non-negative-int ' ;
38+ }
39+ }
Original file line number Diff line number Diff line change 4545use phpDocumentor \Reflection \PseudoTypes \NonEmptyLowercaseString ;
4646use phpDocumentor \Reflection \PseudoTypes \NonEmptyString ;
4747use phpDocumentor \Reflection \PseudoTypes \NonFalsyString ;
48+ use phpDocumentor \Reflection \PseudoTypes \NonNegativeInteger ;
4849use phpDocumentor \Reflection \PseudoTypes \NonPositiveInteger ;
4950use phpDocumentor \Reflection \PseudoTypes \Numeric_ ;
5051use phpDocumentor \Reflection \PseudoTypes \NumericString ;
@@ -185,6 +186,7 @@ final class TypeResolver
185186 'non-falsy-string ' => NonFalsyString::class,
186187 'truthy-string ' => TruthyString::class,
187188 'non-positive-int ' => NonPositiveInteger::class,
189+ 'non-negative-int ' => NonNegativeInteger::class,
188190 ];
189191
190192 /**
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 \Integer ;
17+ use PHPUnit \Framework \TestCase ;
18+
19+ final class NonNegativeIntegerTest extends TestCase
20+ {
21+ public function testCreate (): void
22+ {
23+ $ type = new NonNegativeInteger ();
24+
25+ $ this ->assertEquals (new Integer (), $ type ->underlyingType ());
26+ }
27+
28+ public function testToString (): void
29+ {
30+ $ this ->assertSame ('non-negative-int ' , (string ) (new NonNegativeInteger ()));
31+ }
32+ }
Original file line number Diff line number Diff line change 4545use phpDocumentor \Reflection \PseudoTypes \NonEmptyLowercaseString ;
4646use phpDocumentor \Reflection \PseudoTypes \NonEmptyString ;
4747use phpDocumentor \Reflection \PseudoTypes \NonFalsyString ;
48+ use phpDocumentor \Reflection \PseudoTypes \NonNegativeInteger ;
4849use phpDocumentor \Reflection \PseudoTypes \NonPositiveInteger ;
4950use phpDocumentor \Reflection \PseudoTypes \Numeric_ ;
5051use phpDocumentor \Reflection \PseudoTypes \NumericString ;
@@ -681,6 +682,7 @@ public function provideKeywords(): array
681682 ['non-falsy-string ' , NonFalsyString::class],
682683 ['truthy-string ' , TruthyString::class],
683684 ['non-positive-int ' , NonPositiveInteger::class],
685+ ['non-negative-int ' , NonNegativeInteger::class],
684686 ];
685687 }
686688
You can’t perform that action at this time.
0 commit comments