Skip to content

Commit

Permalink
fix union type returns
Browse files Browse the repository at this point in the history
  • Loading branch information
Luukdewaaier committed Mar 5, 2024
1 parent 12d6bb8 commit 8947c6c
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/Support/Generators/AttributePropertyGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

use ReflectionClass;
use ReflectionMethod;
use ReflectionUnionType;
use Illuminate\Database\Eloquent\Model;
use Scrumble\TypeGenerator\Interfaces\IPropertyGenerator;

Expand Down Expand Up @@ -90,14 +91,13 @@ private function getPropertyType(ReflectionMethod $method): string
{
if (null !== ($returnType = $method->getReturnType())) {
if($returnType instanceof ReflectionUnionType) {
$returnTypes = collect($returnType->getTypes())
->map(function($returnType) {
// @phpstan-ignore-next-line
return $this->formatPhpReturnType($returnType->getName()) ;
})
->join(' | ') . ($returnType->allowsNull() ? ' | null' : '');
return collect($returnType->getTypes())
->map(function($returnType) {
return $this->formatPhpReturnType($returnType->getName()) ;
})
->join(' | ') . ($returnType->allowsNull() ? ' | null' : '');
}

// @phpstan-ignore-next-line
return $this->formatPhpReturnType($returnType->getName()) . ($returnType->allowsNull() ? ' | null' : '');
}
Expand Down

0 comments on commit 8947c6c

Please sign in to comment.