File tree Expand file tree Collapse file tree 1 file changed +11
-0
lines changed
src/FreeElephants/JsonApi/DTO Expand file tree Collapse file tree 1 file changed +11
-0
lines changed Original file line number Diff line number Diff line change @@ -19,6 +19,17 @@ final public function __construct(array $payload)
19
19
/** @var \ReflectionUnionType $reflectionType */
20
20
$ dataClassName = $ reflectionType ->getTypes ()[0 ]->getName ();
21
21
}
22
+
23
+ /**
24
+ * In cases like:
25
+ * `public array|Example\ResourceObjectExt|Example\ResourceObject $data;`
26
+ * ReflectionUnionType::getTypes() return types in next orders:
27
+ * - Example\ResourceObjectExt
28
+ * - Example\ResourceObject
29
+ * - array
30
+ *
31
+ * This exception is [can] not covered with test. But this behavior not documented at https://www.php.net/manual/en/reflectionuniontype.gettypes.php
32
+ */
22
33
if ($ dataClassName !== 'array ' ) {
23
34
$ data = new $ dataClassName ($ payload ['data ' ]);
24
35
} else {
You can’t perform that action at this time.
0 commit comments