Forráskód Böngészése

Fix build - remove collision package by default

shalvah 5 éve
szülő
commit
2f3a2144e1

+ 2 - 2
composer.json

@@ -23,7 +23,6 @@
         "mpociot/documentarian": "^0.2.0",
         "mpociot/reflection-docblock": "^1.0.1",
         "ramsey/uuid": "^3.8",
-        "nunomaduro/collision": "^1.1 || ^3.0",
         "league/flysystem": "^1.0"
     },
     "require-dev": {
@@ -34,7 +33,8 @@
         "league/fractal": "^0.17.0"
     },
     "suggest": {
-        "league/fractal": "Required for transformers support"
+        "league/fractal": "Required for transformers support",
+        "nunomaduro/collision": "For better reporting of errors that are thrpwn when generating docs"
     },
     "autoload": {
         "psr-4": {

+ 1 - 6
src/Tools/ResponseStrategies/ResponseCallStrategy.php

@@ -8,8 +8,6 @@ use Illuminate\Http\Response;
 use Illuminate\Routing\Route;
 use Mpociot\ApiDoc\Tools\Flags;
 use Mpociot\ApiDoc\Tools\Utils;
-use Whoops\Exception\Inspector;
-use NunoMaduro\Collision\Handler;
 use Mpociot\ApiDoc\Tools\Traits\ParamHelpers;
 
 /**
@@ -41,10 +39,7 @@ class ResponseCallStrategy
         } catch (\Exception $e) {
             echo 'Exception thrown during response call for ['.implode(',', $route->methods)."] {$route->uri}.\n";
             if (Flags::$shouldBeVerbose) {
-                $handler = new Handler;
-                $handler->setInspector(new Inspector($e));
-                $handler->setException($e);
-                $handler->handle();
+                Utils::dumpException($e);
             } else {
                 echo "Run this again with the --verbose flag to see the exception.\n";
             }

+ 13 - 0
src/Tools/Utils.php

@@ -66,6 +66,19 @@ class Utils
         return $uri;
     }
 
+    public function dumpException(\Exception $e)
+    {
+        if (class_exists(\NunoMaduro\Collision\Handler::class)) {
+            $handler = new \NunoMaduro\Collision\Handler;
+            $handler->setInspector(new \Whoops\Exception\Inspector($e));
+            $handler->setException($e);
+            $handler->handle();
+        } else {
+            dump($e);
+            echo "You can get better exception output by installing the library \nunomaduro/collision (PHP 7.1+ only).\n";
+        }
+    }
+
     public static function deleteDirectoryAndContents($dir)
     {
         $adapter = new Local(realpath(__DIR__.'/../../'));