diff --git a/src/ObjectReflection.php b/src/ObjectReflection.php index 8e71dae..b773b43 100644 --- a/src/ObjectReflection.php +++ b/src/ObjectReflection.php @@ -65,13 +65,13 @@ class ObjectReflection { if ( $traits = $this->classReflection->getTraits() ) { foreach($traits as $key => $value) { - $traitTags = array_merge_recursive($traitTags ?? [], static::fromClass($key)->gatherClass(true)); + $traitTags = static::fromClass($key)->gatherClass(true); } } if ( $interfaces = $this->classReflection->getInterfaces() ) { foreach($interfaces as $key => $value) { - $interfaceTags = array_merge_recursive($interfaceTags ?? [], static::fromClass($key)->gatherClass(true)); + $interfaceTags = static::fromClass($key)->gatherClass(true); } } @@ -81,11 +81,11 @@ class ObjectReflection { } return array_merge_recursive($class ?? [], $traitTags ?? [], $interfaceTags ?? [], [ - 'tags' => $this->annotationReader->getClass($this->classReflection) - ] + ( ! $full ? [] : [ - 'traits' => array_map($itemName, $traits), - 'interfaces' => array_map($itemName, $interfaces), - ] )); + 'tags' => $this->annotationReader->getClass($this->classReflection) + ] + ( ! $full ? [] : [ + 'traits' => array_map($itemName, $traits), + 'interfaces' => array_map($itemName, $interfaces), + ] )); } public function gatherProperties(bool $full = true, int $filter = @@ -114,10 +114,15 @@ class ObjectReflection { $current['value'] = $defaultValues[ $current['name'] ]; } + if ( $property->hasType() ) { - $current['type'] = $property->getType()->getName(); - $current['builtin'] = $property->getType()->isBuiltIn(); - $current['nullable'] = $property->getType()->allowsNull(); + $type = $property->getType(); + + if (! $type instanceof \ReflectionUnionType ) { + $current['type'] = $type->getName(); + $current['builtin'] = $type->isBuiltIn(); + $current['nullable'] = $type->allowsNull(); + } } $current['tags'] = $this->annotationReader->getProperty($property);