@@ -57,12 +57,20 @@ class Type
57
57
private $ collectionValueType ;
58
58
59
59
/**
60
+ * @param string|array $builtinType
61
+ *
60
62
* @throws \InvalidArgumentException
61
63
*/
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 )
63
65
{
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 ('%s(): Argument #1 ($builtinType) must be of type string|array, "%s" given. ' , __METHOD__ , 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
+ }
66
74
}
67
75
68
76
$ this ->builtinType = $ builtinType ;
@@ -77,8 +85,10 @@ public function __construct(string $builtinType, bool $nullable = false, string
77
85
* Gets built-in type.
78
86
*
79
87
* Can be bool, int, float, string, array, object, resource, null, callback or iterable.
88
+ *
89
+ * @return string|array
80
90
*/
81
- public function getBuiltinType (): string
91
+ public function getBuiltinType ()
82
92
{
83
93
return $ this ->builtinType ;
84
94
}
0 commit comments