File tree Expand file tree Collapse file tree 4 files changed +76
-0
lines changed
Expand file tree Collapse file tree 4 files changed +76
-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 underlyingType (): Type
30+ {
31+ return new Array_ (new Mixed_ (), new Integer ());
32+ }
33+
34+ public function __toString (): string
35+ {
36+ return 'callable-array ' ;
37+ }
38+ }
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 \Conditional ;
@@ -167,6 +168,7 @@ final class TypeResolver
167168 'object ' => Object_::class,
168169 'mixed ' => Mixed_::class,
169170 'array ' => Array_::class,
171+ 'callable-array ' => CallableArray::class,
170172 'array-key ' => ArrayKey::class,
171173 'non-empty-array ' => NonEmptyArray::class,
172174 '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+ }
29+
30+ public function testToString (): void
31+ {
32+ $ this ->assertSame ('callable-array ' , (string ) (new CallableArray ()));
33+ }
34+ }
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 \Conditional ;
@@ -668,6 +669,7 @@ public function provideKeywords(): array
668669 ['callable-string ' , CallableString::class],
669670 ['callback ' , Callable_::class],
670671 ['array ' , Array_::class],
672+ ['callable-array ' , CallableArray::class],
671673 ['array-key ' , ArrayKey::class],
672674 ['scalar ' , Scalar::class],
673675 ['object ' , Object_::class],
You can’t perform that action at this time.
0 commit comments