File tree Expand file tree Collapse file tree 4 files changed +83
-0
lines changed
Expand file tree Collapse file tree 4 files changed +83
-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 \Array_ ;
19+ use phpDocumentor \Reflection \Types \Integer ;
20+ use phpDocumentor \Reflection \Types \Mixed_ ;
21+
22+ /**
23+ * Value Object representing the type 'callable-array'.
24+ *
25+ * @psalm-immutable
26+ */
27+ final class CallableArray extends Array_ implements PseudoType
28+ {
29+ public function __construct ()
30+ {
31+ parent ::__construct (new Mixed_ (), new Integer ());
32+ }
33+
34+ public function underlyingType (): Type
35+ {
36+ return new Array_ (new Mixed_ (), new Integer ());
37+ }
38+
39+ public function __toString (): string
40+ {
41+ return 'callable-array ' ;
42+ }
43+ }
Original file line number Diff line number Diff line change 1818use phpDocumentor \Reflection \PseudoTypes \ArrayKey ;
1919use phpDocumentor \Reflection \PseudoTypes \ArrayShape ;
2020use phpDocumentor \Reflection \PseudoTypes \ArrayShapeItem ;
21+ use phpDocumentor \Reflection \PseudoTypes \CallableArray ;
2122use phpDocumentor \Reflection \PseudoTypes \CallableString ;
2223use phpDocumentor \Reflection \PseudoTypes \ClassString ;
2324use phpDocumentor \Reflection \PseudoTypes \ClosedResource ;
@@ -169,6 +170,7 @@ final class TypeResolver
169170 'object ' => Object_::class,
170171 'mixed ' => Mixed_::class,
171172 'array ' => Array_::class,
173+ 'callable-array ' => CallableArray::class,
172174 'array-key ' => ArrayKey::class,
173175 'non-empty-array ' => NonEmptyArray::class,
174176 'resource ' => Resource_::class,
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 \Array_ ;
17+ use phpDocumentor \Reflection \Types \Integer ;
18+ use phpDocumentor \Reflection \Types \Mixed_ ;
19+ use PHPUnit \Framework \TestCase ;
20+
21+ final class CallableArrayTest extends TestCase
22+ {
23+ public function testCreate (): void
24+ {
25+ $ type = new CallableArray ();
26+
27+ $ this ->assertEquals (new Array_ (new Mixed_ (), new Integer ()), $ type ->underlyingType ());
28+ $ this ->assertEquals (new Mixed_ (), $ type ->getValueType ());
29+ $ this ->assertEquals (new Integer (), $ type ->getKeyType ());
30+ }
31+
32+ public function testToString (): void
33+ {
34+ $ this ->assertSame ('callable-array ' , (string ) (new CallableArray ()));
35+ }
36+ }
Original file line number Diff line number Diff line change 1818use phpDocumentor \Reflection \PseudoTypes \ArrayKey ;
1919use phpDocumentor \Reflection \PseudoTypes \ArrayShape ;
2020use phpDocumentor \Reflection \PseudoTypes \ArrayShapeItem ;
21+ use phpDocumentor \Reflection \PseudoTypes \CallableArray ;
2122use phpDocumentor \Reflection \PseudoTypes \CallableString ;
2223use phpDocumentor \Reflection \PseudoTypes \ClassString ;
2324use phpDocumentor \Reflection \PseudoTypes \ClosedResource ;
@@ -672,6 +673,7 @@ public function provideKeywords(): array
672673 ['callable-string ' , CallableString::class],
673674 ['callback ' , Callable_::class],
674675 ['array ' , Array_::class],
676+ ['callable-array ' , CallableArray::class],
675677 ['array-key ' , ArrayKey::class],
676678 ['scalar ' , Scalar::class],
677679 ['object ' , Object_::class],
You can’t perform that action at this time.
0 commit comments