File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree 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 \String_ ;
19+
20+ /**
21+ * Value Object representing the type 'truthy-string'.
22+ *
23+ * @psalm-immutable
24+ */
25+ final class TruthyString extends String_ implements PseudoType
26+ {
27+ public function underlyingType (): Type
28+ {
29+ return new String_ ();
30+ }
31+
32+ public function __toString (): string
33+ {
34+ return 'truthy-string ' ;
35+ }
36+ }
Original file line number Diff line number Diff line change 5959use phpDocumentor \Reflection \PseudoTypes \StringValue ;
6060use phpDocumentor \Reflection \PseudoTypes \TraitString ;
6161use phpDocumentor \Reflection \PseudoTypes \True_ ;
62+ use phpDocumentor \Reflection \PseudoTypes \TruthyString ;
6263use phpDocumentor \Reflection \PseudoTypes \ValueOf ;
6364use phpDocumentor \Reflection \Types \AggregatedType ;
6465use phpDocumentor \Reflection \Types \Array_ ;
@@ -181,6 +182,7 @@ final class TypeResolver
181182 'list ' => List_::class,
182183 'non-empty-list ' => NonEmptyList::class,
183184 'non-falsy-string ' => NonFalsyString::class,
185+ 'truthy-string ' => TruthyString::class,
184186 ];
185187
186188 /**
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 \String_ ;
17+ use PHPUnit \Framework \TestCase ;
18+
19+ final class TruthyStringTest extends TestCase
20+ {
21+ public function testCreate (): void
22+ {
23+ $ type = new TruthyString ();
24+
25+ $ this ->assertEquals (new String_ (), $ type ->underlyingType ());
26+ }
27+
28+ public function testToString (): void
29+ {
30+ $ this ->assertSame ('truthy-string ' , (string ) (new TruthyString ()));
31+ }
32+ }
Original file line number Diff line number Diff line change 5959use phpDocumentor \Reflection \PseudoTypes \StringValue ;
6060use phpDocumentor \Reflection \PseudoTypes \TraitString ;
6161use phpDocumentor \Reflection \PseudoTypes \True_ ;
62+ use phpDocumentor \Reflection \PseudoTypes \TruthyString ;
6263use phpDocumentor \Reflection \PseudoTypes \ValueOf ;
6364use phpDocumentor \Reflection \Types \Array_ ;
6465use phpDocumentor \Reflection \Types \Boolean ;
@@ -677,6 +678,7 @@ public function provideKeywords(): array
677678 ['non-empty-list ' , NonEmptyList::class],
678679 ['non-empty-array ' , NonEmptyArray::class],
679680 ['non-falsy-string ' , NonFalsyString::class],
681+ ['truthy-string ' , TruthyString::class],
680682 ];
681683 }
682684
You can’t perform that action at this time.
0 commit comments