Quellcode durchsuchen

PHP 8 compatibility

shalvah vor 4 Jahren
Ursprung
Commit
10f61296e2

+ 2 - 2
src/Commands/GenerateDocumentation.php

@@ -8,7 +8,7 @@ use Illuminate\Support\Collection;
 use Illuminate\Support\Facades\URL;
 use Illuminate\Support\Str;
 use Knuckles\Scribe\Extracting\Generator;
-use Knuckles\Scribe\Matching\Match;
+use Knuckles\Scribe\Matching\MatchedRoute;
 use Knuckles\Scribe\Matching\RouteMatcherInterface;
 use Knuckles\Scribe\Tools\ConsoleOutputUtils as c;
 use Knuckles\Scribe\Tools\DocumentationConfig;
@@ -84,7 +84,7 @@ class GenerateDocumentation extends Command
     }
 
     /**
-     * @param Match[] $matches
+     * @param MatchedRoute[] $matches
      *
      * @return array
      * @throws \ReflectionException

+ 6 - 0
src/Extracting/Strategies/BodyParameters/GetFromBodyParamTag.php

@@ -13,6 +13,7 @@ use Mpociot\Reflection\DocBlock\Tag;
 use ReflectionClass;
 use ReflectionException;
 use ReflectionFunctionAbstract;
+use ReflectionUnionType;
 
 class GetFromBodyParamTag extends Strategy
 {
@@ -33,6 +34,11 @@ class GetFromBodyParamTag extends Strategy
                 continue;
             }
 
+            if (class_exists(ReflectionUnionType::class)
+                && $paramType instanceof ReflectionUnionType) {
+                continue;
+            }
+
             $parameterClassName = $paramType->getName();
 
             try {

+ 6 - 0
src/Extracting/Strategies/BodyParameters/GetFromFormRequest.php

@@ -20,6 +20,7 @@ use ReflectionClass;
 use ReflectionException;
 use ReflectionFunctionAbstract;
 use Illuminate\Contracts\Validation\Factory as ValidationFactory;
+use ReflectionUnionType;
 
 class GetFromFormRequest extends Strategy
 {
@@ -42,6 +43,11 @@ class GetFromFormRequest extends Strategy
                 continue;
             }
 
+            if (class_exists(ReflectionUnionType::class)
+                && $paramType instanceof ReflectionUnionType) {
+                continue;
+            }
+
             $parameterClassName = $paramType->getName();
 
             if (!class_exists($parameterClassName)) {

+ 6 - 0
src/Extracting/Strategies/Headers/GetFromHeaderTag.php

@@ -12,6 +12,7 @@ use Mpociot\Reflection\DocBlock;
 use Mpociot\Reflection\DocBlock\Tag;
 use ReflectionClass;
 use ReflectionFunctionAbstract;
+use ReflectionUnionType;
 
 class GetFromHeaderTag extends Strategy
 {
@@ -27,6 +28,11 @@ class GetFromHeaderTag extends Strategy
                 continue;
             }
 
+            if (class_exists(ReflectionUnionType::class)
+                && $paramType instanceof ReflectionUnionType) {
+                continue;
+            }
+
             $parameterClassName = $paramType->getName();
 
             try {

+ 6 - 0
src/Extracting/Strategies/QueryParameters/GetFromQueryParamTag.php

@@ -13,6 +13,7 @@ use Mpociot\Reflection\DocBlock;
 use Mpociot\Reflection\DocBlock\Tag;
 use ReflectionClass;
 use ReflectionFunctionAbstract;
+use ReflectionUnionType;
 
 class GetFromQueryParamTag extends Strategy
 {
@@ -33,6 +34,11 @@ class GetFromQueryParamTag extends Strategy
                 continue;
             }
 
+            if (class_exists(ReflectionUnionType::class)
+                && $paramType instanceof ReflectionUnionType) {
+                continue;
+            }
+
             $parameterClassName = $paramType->getName();
 
             try {

+ 6 - 0
src/Extracting/Strategies/UrlParameters/GetFromUrlParamTag.php

@@ -13,6 +13,7 @@ use Mpociot\Reflection\DocBlock;
 use Mpociot\Reflection\DocBlock\Tag;
 use ReflectionClass;
 use ReflectionFunctionAbstract;
+use ReflectionUnionType;
 
 class GetFromUrlParamTag extends Strategy
 {
@@ -28,6 +29,11 @@ class GetFromUrlParamTag extends Strategy
                 continue;
             }
 
+            if (class_exists(ReflectionUnionType::class)
+                && $paramType instanceof ReflectionUnionType) {
+                continue;
+            }
+
             $parameterClassName = $paramType->getName();
 
             try {

+ 1 - 1
src/Matching/Match.php → src/Matching/MatchedRoute.php

@@ -4,7 +4,7 @@ namespace Knuckles\Scribe\Matching;
 
 use Illuminate\Routing\Route;
 
-class Match implements \ArrayAccess
+class MatchedRoute implements \ArrayAccess
 {
     /**
      * @var Route

+ 1 - 1
src/Matching/RouteMatcher.php

@@ -35,7 +35,7 @@ class RouteMatcher implements RouteMatcherInterface
                 }
 
                 if ($this->shouldIncludeRoute($route, $routeRule, $includes, $usingDingoRouter)) {
-                    $matchedRoutes[] = new Match($route, $routeRule['apply'] ?? []);
+                    $matchedRoutes[] = new MatchedRoute($route, $routeRule['apply'] ?? []);
                 }
             }
         }

+ 1 - 1
src/Matching/RouteMatcherInterface.php

@@ -10,7 +10,7 @@ interface RouteMatcherInterface
      * @param array $routeRules Route rules defined under the "routes" section in config
      * @param string $router
      *
-     * @return Match[]
+     * @return MatchedRoute[]
      */
     public function getRoutes(array $routeRules = [], string $router = 'laravel');
 }