Completed
Pull Request — master (#608)
by
unknown
12:02
created
src/Matching/RouteMatcher.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -64,14 +64,14 @@  discard block
 block discarded – undo
64 64
 
65 65
     private function getAllRoutes(bool $usingDingoRouter)
66 66
     {
67
-        if (! $usingDingoRouter) {
67
+        if (!$usingDingoRouter) {
68 68
             return RouteFacade::getRoutes();
69 69
         }
70 70
 
71 71
         $allRouteCollections = app(\Dingo\Api\Routing\Router::class)->getRoutes();
72 72
 
73 73
         return collect($allRouteCollections)
74
-            ->flatMap(function (RouteCollection $collection) {
74
+            ->flatMap(function(RouteCollection $collection) {
75 75
                 return $collection->getRoutes();
76 76
             })->toArray();
77 77
     }
@@ -79,7 +79,7 @@  discard block
 block discarded – undo
79 79
     private function shouldIncludeRoute(Route $route, array $routeRule, array $mustIncludes, bool $usingDingoRouter)
80 80
     {
81 81
         $matchesVersion = $usingDingoRouter
82
-            ? ! empty(array_intersect($route->versions(), $routeRule['match']['versions'] ?? []))
82
+            ? !empty(array_intersect($route->versions(), $routeRule['match']['versions'] ?? []))
83 83
             : true;
84 84
 
85 85
         return Str::is($mustIncludes, $route->getName())
Please login to merge, or discard this patch.
src/Extracting/Generator.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -56,7 +56,7 @@  discard block
 block discarded – undo
56 56
         $method = $controller->getMethod($methodName);
57 57
 
58 58
         $parsedRoute = [
59
-            'id' => md5($this->getUri($route).':'.implode($this->getMethods($route))),
59
+            'id' => md5($this->getUri($route) . ':' . implode($this->getMethods($route))),
60 60
             'methods' => $this->getMethods($route),
61 61
             'uri' => $this->getUri($route),
62 62
         ];
@@ -78,7 +78,7 @@  discard block
 block discarded – undo
78 78
 
79 79
         $responses = $this->fetchResponses($controller, $method, $route, $routeRules, $parsedRoute);
80 80
         $parsedRoute['responses'] = $responses;
81
-        $parsedRoute['showresponse'] = ! empty($responses);
81
+        $parsedRoute['showresponse'] = !empty($responses);
82 82
 
83 83
         $parsedRoute['headers'] = $routeRules['headers'] ?? [];
84 84
 
@@ -117,7 +117,7 @@  discard block
 block discarded – undo
117 117
     {
118 118
         $responses = $this->iterateThroughStrategies('responses', $context, [$route, $controller, $method, $rulesToApply]);
119 119
         if (count($responses)) {
120
-            return array_filter($responses, function ($response) {
120
+            return array_filter($responses, function($response) {
121 121
                 return $response['content'] != null;
122 122
             });
123 123
         }
@@ -157,7 +157,7 @@  discard block
 block discarded – undo
157 157
             $strategyArgs = $arguments;
158 158
             $strategyArgs[] = $context;
159 159
             $results = $strategy(...$strategyArgs);
160
-            if (! is_null($results)) {
160
+            if (!is_null($results)) {
161 161
                 foreach ($results as $index => $item) {
162 162
                     if ($stage == 'responses') {
163 163
                         // Responses are additive
@@ -169,7 +169,7 @@  discard block
 block discarded – undo
169 169
                     // and also allows values to be overwritten
170 170
 
171 171
                     // Don't allow overwriting if an empty value is trying to replace a set one
172
-                    if (! in_array($context[$stage], [null, ''], true) && in_array($item, [null, ''], true)) {
172
+                    if (!in_array($context[$stage], [null, ''], true) && in_array($item, [null, ''], true)) {
173 173
                         continue;
174 174
                     } else {
175 175
                         $context[$stage][$index] = $item;
@@ -194,8 +194,8 @@  discard block
 block discarded – undo
194 194
         $values = [];
195 195
 
196 196
         // Remove params which have no examples.
197
-        $params = array_filter($params, function ($details) {
198
-            return ! is_null($details['value']);
197
+        $params = array_filter($params, function($details) {
198
+            return !is_null($details['value']);
199 199
         });
200 200
 
201 201
         foreach ($params as $paramName => $details) {
Please login to merge, or discard this patch.
src/Extracting/RouteDocBlocker.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -20,7 +20,7 @@
 block discarded – undo
20 20
 
21 21
         $class = new ReflectionClass($className);
22 22
 
23
-        if (! $class->hasMethod($methodName)) {
23
+        if (!$class->hasMethod($methodName)) {
24 24
             throw new \Exception("Error while fetching docblock for route: Class $className does not contain method $methodName");
25 25
         }
26 26
 
Please login to merge, or discard this patch.
src/Extracting/Strategies/Responses/UseResponseFileTag.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -44,7 +44,7 @@  discard block
 block discarded – undo
44 44
     {
45 45
         // Avoid "holes" in the keys of the filtered array, by using array_values on the filtered array
46 46
         $responseFileTags = array_values(
47
-            array_filter($tags, function ($tag) {
47
+            array_filter($tags, function($tag) {
48 48
                 return $tag instanceof Tag && strtolower($tag->getName()) === 'responsefile';
49 49
             })
50 50
         );
@@ -53,11 +53,11 @@  discard block
 block discarded – undo
53 53
             return null;
54 54
         }
55 55
 
56
-        $responses = array_map(function (Tag $responseFileTag) {
56
+        $responses = array_map(function(Tag $responseFileTag) {
57 57
             preg_match('/^(\d{3})?\s?([\S]*[\s]*?)(\{.*\})?$/', $responseFileTag->getContent(), $result);
58 58
             $status = $result[1] ?: 200;
59 59
             $content = $result[2] ? file_get_contents(storage_path(trim($result[2])), true) : '{}';
60
-            $json = ! empty($result[3]) ? str_replace("'", '"', $result[3]) : '{}';
60
+            $json = !empty($result[3]) ? str_replace("'", '"', $result[3]) : '{}';
61 61
             $merged = array_merge(json_decode($content, true), json_decode($json, true));
62 62
 
63 63
             return ['content' => json_encode($merged), 'status' => (int) $status];
Please login to merge, or discard this patch.
src/Extracting/Strategies/Responses/UseResponseTag.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -43,7 +43,7 @@  discard block
 block discarded – undo
43 43
     protected function getDocBlockResponses(array $tags)
44 44
     {
45 45
         $responseTags = array_values(
46
-            array_filter($tags, function ($tag) {
46
+            array_filter($tags, function($tag) {
47 47
                 return $tag instanceof Tag && strtolower($tag->getName()) === 'response';
48 48
             })
49 49
         );
@@ -52,7 +52,7 @@  discard block
 block discarded – undo
52 52
             return null;
53 53
         }
54 54
 
55
-        $responses = array_map(function (Tag $responseTag) {
55
+        $responses = array_map(function(Tag $responseTag) {
56 56
             preg_match('/^(\d{3})?\s?([\s\S]*)$/', $responseTag->getContent(), $result);
57 57
 
58 58
             $status = $result[1] ?: 200;
Please login to merge, or discard this patch.
src/Extracting/Strategies/Responses/ResponseCalls.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -31,7 +31,7 @@  discard block
 block discarded – undo
31 31
     public function __invoke(Route $route, \ReflectionClass $controller, \ReflectionMethod $method, array $routeRules, array $context = [])
32 32
     {
33 33
         $rulesToApply = $routeRules['response_calls'] ?? [];
34
-        if (! $this->shouldMakeApiCall($route, $rulesToApply, $context)) {
34
+        if (!$this->shouldMakeApiCall($route, $rulesToApply, $context)) {
35 35
             return null;
36 36
         }
37 37
 
@@ -52,7 +52,7 @@  discard block
 block discarded – undo
52 52
                 ],
53 53
             ];
54 54
         } catch (\Exception $e) {
55
-            echo 'Exception thrown during response call for ['.implode(',', $route->methods)."] {$route->uri}.\n";
55
+            echo 'Exception thrown during response call for [' . implode(',', $route->methods) . "] {$route->uri}.\n";
56 56
             if (Flags::$shouldBeVerbose) {
57 57
                 Utils::dumpException($e);
58 58
             } else {
@@ -186,14 +186,14 @@  discard block
 block discarded – undo
186 186
         // set URL and query parameters
187 187
         $uri = $request->getRequestUri();
188 188
         $query = $request->getQueryString();
189
-        if (! empty($query)) {
189
+        if (!empty($query)) {
190 190
             $uri .= "?$query";
191 191
         }
192 192
         $response = call_user_func_array([$dispatcher, strtolower($request->method())], [$uri]);
193 193
 
194 194
         // the response from the Dingo dispatcher is the 'raw' response from the controller,
195 195
         // so we have to ensure it's JSON first
196
-        if (! $response instanceof Response) {
196
+        if (!$response instanceof Response) {
197 197
             $response = response()->json($response);
198 198
         }
199 199
 
@@ -321,7 +321,7 @@  discard block
 block discarded – undo
321 321
         }
322 322
 
323 323
         // Don't attempt a response call if there are already successful responses
324
-        $successResponses = collect($context['responses'])->filter(function ($response) {
324
+        $successResponses = collect($context['responses'])->filter(function($response) {
325 325
             return ((string) $response['status'])[0] == '2';
326 326
         })->count();
327 327
         if ($successResponses) {
@@ -357,8 +357,8 @@  discard block
 block discarded – undo
357 357
         $prefix = 'HTTP_';
358 358
         foreach ($headers as $name => $value) {
359 359
             $name = strtr(strtoupper($name), '-', '_');
360
-            if (! Str::startsWith($name, $prefix) && $name !== 'CONTENT_TYPE') {
361
-                $name = $prefix.$name;
360
+            if (!Str::startsWith($name, $prefix) && $name !== 'CONTENT_TYPE') {
361
+                $name = $prefix . $name;
362 362
             }
363 363
             $server[$name] = $value;
364 364
         }
Please login to merge, or discard this patch.
src/Extracting/Strategies/Metadata/GetFromDocBlocks.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -37,7 +37,7 @@  discard block
 block discarded – undo
37 37
     protected function getAuthStatusFromDocBlock(array $tags)
38 38
     {
39 39
         $authTag = collect($tags)
40
-            ->first(function ($tag) {
40
+            ->first(function($tag) {
41 41
                 return $tag instanceof Tag && strtolower($tag->getName()) === 'authenticated';
42 42
             });
43 43
 
@@ -53,7 +53,7 @@  discard block
 block discarded – undo
53 53
     protected function getRouteGroupDescriptionAndTitle(DocBlock $methodDocBlock, DocBlock $controllerDocBlock)
54 54
     {
55 55
         // @group tag on the method overrides that on the controller
56
-        if (! empty($methodDocBlock->getTags())) {
56
+        if (!empty($methodDocBlock->getTags())) {
57 57
             foreach ($methodDocBlock->getTags() as $tag) {
58 58
                 if ($tag->getName() === 'group') {
59 59
                     $routeGroupParts = explode("\n", trim($tag->getContent()));
Please login to merge, or discard this patch.
src/ApiDoc.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -9,7 +9,7 @@
 block discarded – undo
9 9
 {
10 10
     public static function routes($path = '/doc')
11 11
     {
12
-        return Route::get("$path{format?}", function (?string $format = null) {
12
+        return Route::get("$path{format?}", function(?string $format = null) {
13 13
             if ($format == '.json') {
14 14
                 return response(
15 15
                     Storage::disk('local')->get('apidoc/collection.json'),
Please login to merge, or discard this patch.
src/Tools/Utils.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -53,7 +53,7 @@  discard block
 block discarded – undo
53 53
     public static function replaceUrlParameterPlaceholdersWithValues(string $uri, array $urlParameters)
54 54
     {
55 55
         $matches = preg_match_all('/{.+?}/i', $uri, $parameterPaths);
56
-        if (! $matches) {
56
+        if (!$matches) {
57 57
             return $uri;
58 58
         }
59 59
 
@@ -88,7 +88,7 @@  discard block
 block discarded – undo
88 88
 
89 89
     public static function deleteDirectoryAndContents($dir)
90 90
     {
91
-        $adapter = new Local(realpath(__DIR__.'/../../'));
91
+        $adapter = new Local(realpath(__DIR__ . '/../../'));
92 92
         $fs = new Filesystem($adapter);
93 93
         $fs->deleteDir($dir);
94 94
     }
@@ -101,7 +101,7 @@  discard block
 block discarded – undo
101 101
         $result = '';
102 102
         $padWith = str_repeat(' ', $indentationLevel);
103 103
         foreach ($split as $index => $line) {
104
-            $result .= ($index == 0 ? '' : "\n$padWith").$line;
104
+            $result .= ($index == 0 ? '' : "\n$padWith") . $line;
105 105
         }
106 106
 
107 107
         return $result;
Please login to merge, or discard this patch.