@@ -59,10 +59,16 @@ class Type
5959 /**
6060 * @throws \InvalidArgumentException
6161 */
62- public function __construct (string $ builtinType , bool $ nullable = false , string $ class = null , bool $ collection = false , self $ collectionKeyType = null , self $ collectionValueType = null )
62+ public function __construct (/* string|array */ $ builtinType , bool $ nullable = false , string $ class = null , bool $ collection = false , self $ collectionKeyType = null , self $ collectionValueType = null )
6363 {
64- if (!\in_array ($ builtinType , self ::$ builtinTypes )) {
65- throw new \InvalidArgumentException (sprintf ('"%s" is not a valid PHP type. ' , $ builtinType ));
64+ if (!\is_string ($ builtinType ) && !\is_array ($ builtinType )) {
65+ throw new \TypeError ('"$builtinType" should be a string or an array. ' );
66+ }
67+
68+ foreach ((array ) $ builtinType as $ type ) {
69+ if (!\in_array ($ type , self ::$ builtinTypes )) {
70+ throw new \InvalidArgumentException (sprintf ('"%s" is not a valid PHP type. ' , $ type ));
71+ }
6672 }
6773
6874 $ this ->builtinType = $ builtinType ;
@@ -77,8 +83,10 @@ public function __construct(string $builtinType, bool $nullable = false, string
7783 * Gets built-in type.
7884 *
7985 * Can be bool, int, float, string, array, object, resource, null, callback or iterable.
86+ *
87+ * @return string|array
8088 */
81- public function getBuiltinType (): string
89+ public function getBuiltinType ()
8290 {
8391 return $ this ->builtinType ;
8492 }
0 commit comments