@@ -57,12 +57,20 @@ class Type
5757 private $ collectionValueType ;
5858
5959 /**
60+ * @param string|array $builtinType
61+ *
6062 * @throws \InvalidArgumentException
6163 */
62- public function __construct (string $ builtinType , bool $ nullable = false , string $ class = null , bool $ collection = false , self $ collectionKeyType = null , self $ collectionValueType = null )
64+ public function __construct ($ builtinType , bool $ nullable = false , string $ class = null , bool $ collection = false , self $ collectionKeyType = null , self $ collectionValueType = null )
6365 {
64- if (!\in_array ($ builtinType , self ::$ builtinTypes )) {
65- throw new \InvalidArgumentException (sprintf ('"%s" is not a valid PHP type. ' , $ builtinType ));
66+ if (!\is_string ($ builtinType ) && !\is_array ($ builtinType )) {
67+ throw new \TypeError (sprintf ('__construct(): Argument #1 ($builtinType) must be of type string|array, "%s" given. ' , get_debug_type ($ builtinType )));
68+ }
69+
70+ foreach ((array ) $ builtinType as $ type ) {
71+ if (!\in_array ($ type , self ::$ builtinTypes )) {
72+ throw new \InvalidArgumentException (sprintf ('"%s" is not a valid PHP type. ' , $ type ));
73+ }
6674 }
6775
6876 $ this ->builtinType = $ builtinType ;
@@ -77,8 +85,10 @@ public function __construct(string $builtinType, bool $nullable = false, string
7785 * Gets built-in type.
7886 *
7987 * Can be bool, int, float, string, array, object, resource, null, callback or iterable.
88+ *
89+ * @return string|array
8090 */
81- public function getBuiltinType (): string
91+ public function getBuiltinType ()
8292 {
8393 return $ this ->builtinType ;
8494 }
0 commit comments