From 25b61c56fed54cdec2459045bbae04ade5c8fe2c Mon Sep 17 00:00:00 2001 From: cxlblm Date: Tue, 17 Sep 2019 13:08:26 +0800 Subject: [PATCH] __toString function has been DEPRECATED (#801) * __toString function has been DEPRECATED __toString function has been DEPRECATED as of PHP 7.1.0 * remove code remove code --- src/Console/ModelsCommand.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/Console/ModelsCommand.php b/src/Console/ModelsCommand.php index 32b2937..34f38cc 100644 --- a/src/Console/ModelsCommand.php +++ b/src/Console/ModelsCommand.php @@ -455,9 +455,14 @@ 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() ?: $this->getReturnTypeFromDocBlock($reflection)); + if ($returnType = $reflection->getReturnType()) { + $type = $returnType instanceof \ReflectionNamedType ? $returnType->getName() : (string)$returnType; + } else { + // php 7.x type or fallback to docblock + $type = (string)$this->getReturnTypeFromDocBlock($reflection); + } + $file = new \SplFileObject($reflection->getFileName()); $file->seek($reflection->getStartLine() - 1);