From 3668e3821a0d268184b06189ca9d0be2aed891d1 Mon Sep 17 00:00:00 2001 From: Matthew Hailwood Date: Fri, 30 Aug 2019 17:32:01 +1200 Subject: [PATCH] Add support for custom cast classes (#816) * Add support for custom cast classes * Fix unrelated code style warning. --- src/Console/ModelsCommand.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Console/ModelsCommand.php b/src/Console/ModelsCommand.php index 051105f..3ed2b63 100644 --- a/src/Console/ModelsCommand.php +++ b/src/Console/ModelsCommand.php @@ -290,7 +290,7 @@ class ModelsCommand extends Command $realType = '\Illuminate\Support\Collection'; break; default: - $realType = 'mixed'; + $realType = class_exists($type) ? ('\\' . $type) : 'mixed'; break; } @@ -456,7 +456,7 @@ class ModelsCommand extends Command //Use reflection to inspect the code, based on Illuminate/Support/SerializableClosure.php $reflection = new \ReflectionMethod($model, $method); // php 7.x type or fallback to docblock - $type = (string) $reflection->getReturnType() ?: (string)$this->getReturnTypeFromDocBlock($reflection); + $type = (string)($reflection->getReturnType() ?: $this->getReturnTypeFromDocBlock($reflection)); $file = new \SplFileObject($reflection->getFileName()); $file->seek($reflection->getStartLine() - 1);