Completed
Pull Request — master (#690)
by
unknown
01:42
created
src/Extracting/Strategies/Responses/UseTransformerTags.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -65,7 +65,7 @@  discard block
 block discarded – undo
65 65
 
66 66
             $fractal = new Manager();
67 67
 
68
-            if (! is_null(config('apidoc.fractal.serializer'))) {
68
+            if (!is_null(config('apidoc.fractal.serializer'))) {
69 69
                 $fractal->setSerializer(app(config('apidoc.fractal.serializer')));
70 70
             }
71 71
 
@@ -84,7 +84,7 @@  discard block
 block discarded – undo
84 84
                 ],
85 85
             ];
86 86
         } catch (Exception $e) {
87
-            echo 'Exception thrown when fetching transformer response for ['.implode(',', $route->methods)."] {$route->uri}.\n";
87
+            echo 'Exception thrown when fetching transformer response for [' . implode(',', $route->methods) . "] {$route->uri}.\n";
88 88
             if (Flags::$shouldBeVerbose) {
89 89
                 Utils::dumpException($e);
90 90
             } else {
@@ -120,7 +120,7 @@  discard block
 block discarded – undo
120 120
      */
121 121
     private function getClassToBeTransformed(array $tags, ReflectionFunctionAbstract $transformerMethod): string
122 122
     {
123
-        $modelTag = Arr::first(array_filter($tags, function ($tag) {
123
+        $modelTag = Arr::first(array_filter($tags, function($tag) {
124 124
             return ($tag instanceof Tag) && strtolower($tag->getName()) == 'transformermodel';
125 125
         }));
126 126
 
@@ -129,7 +129,7 @@  discard block
 block discarded – undo
129 129
             $type = $modelTag->getContent();
130 130
         } else {
131 131
             $parameter = Arr::first($transformerMethod->getParameters());
132
-            if ($parameter->hasType() && ! $parameter->getType()->isBuiltin() && class_exists($parameter->getType()->getName())) {
132
+            if ($parameter->hasType() && !$parameter->getType()->isBuiltin() && class_exists($parameter->getType()->getName())) {
133 133
                 // Ladies and gentlemen, we have a type!
134 134
                 $type = $parameter->getType()->getName();
135 135
             }
@@ -190,7 +190,7 @@  discard block
 block discarded – undo
190 190
     private function getTransformerTag(array $tags)
191 191
     {
192 192
         $transformerTags = array_values(
193
-            array_filter($tags, function ($tag) {
193
+            array_filter($tags, function($tag) {
194 194
                 return ($tag instanceof Tag) && in_array(strtolower($tag->getName()), ['transformer', 'transformercollection']);
195 195
             })
196 196
         );
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, \ReflectionFunctionAbstract $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 {
@@ -194,14 +194,14 @@  discard block
 block discarded – undo
194 194
         // set URL and query parameters
195 195
         $uri = $request->getRequestUri();
196 196
         $query = $request->getQueryString();
197
-        if (! empty($query)) {
197
+        if (!empty($query)) {
198 198
             $uri .= "?$query";
199 199
         }
200 200
         $response = call_user_func_array([$dispatcher, strtolower($request->method())], [$uri]);
201 201
 
202 202
         // the response from the Dingo dispatcher is the 'raw' response from the controller,
203 203
         // so we have to ensure it's JSON first
204
-        if (! $response instanceof Response) {
204
+        if (!$response instanceof Response) {
205 205
             $response = response()->json($response);
206 206
         }
207 207
 
@@ -329,7 +329,7 @@  discard block
 block discarded – undo
329 329
         }
330 330
 
331 331
         // Don't attempt a response call if there are already successful responses
332
-        $successResponses = collect($context['responses'])->filter(function ($response) {
332
+        $successResponses = collect($context['responses'])->filter(function($response) {
333 333
             return ((string) $response['status'])[0] == '2';
334 334
         })->count();
335 335
         if ($successResponses) {
@@ -365,8 +365,8 @@  discard block
 block discarded – undo
365 365
         $prefix = 'HTTP_';
366 366
         foreach ($headers as $name => $value) {
367 367
             $name = strtr(strtoupper($name), '-', '_');
368
-            if (! Str::startsWith($name, $prefix) && $name !== 'CONTENT_TYPE') {
369
-                $name = $prefix.$name;
368
+            if (!Str::startsWith($name, $prefix) && $name !== 'CONTENT_TYPE') {
369
+                $name = $prefix . $name;
370 370
             }
371 371
             $server[$name] = $value;
372 372
         }
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
@@ -61,7 +61,7 @@  discard block
 block discarded – undo
61 61
             : $controller->getMethod($methodName);
62 62
 
63 63
         $parsedRoute = [
64
-            'id' => md5($this->getUri($route).':'.implode($this->getMethods($route))),
64
+            'id' => md5($this->getUri($route) . ':' . implode($this->getMethods($route))),
65 65
             'methods' => $this->getMethods($route),
66 66
             'uri' => $this->getUri($route),
67 67
         ];
@@ -86,7 +86,7 @@  discard block
 block discarded – undo
86 86
 
87 87
         $responses = $this->fetchResponses($controller, $method, $route, $routeRules, $parsedRoute);
88 88
         $parsedRoute['responses'] = $responses;
89
-        $parsedRoute['showresponse'] = ! empty($responses);
89
+        $parsedRoute['showresponse'] = !empty($responses);
90 90
 
91 91
         return $parsedRoute;
92 92
     }
@@ -123,7 +123,7 @@  discard block
 block discarded – undo
123 123
     {
124 124
         $responses = $this->iterateThroughStrategies('responses', $context, [$route, $controller, $method, $rulesToApply]);
125 125
         if (count($responses)) {
126
-            return array_filter($responses, function ($response) {
126
+            return array_filter($responses, function($response) {
127 127
                 return $response['content'] != null;
128 128
             });
129 129
         }
@@ -173,7 +173,7 @@  discard block
 block discarded – undo
173 173
             $strategyArgs = $arguments;
174 174
             $strategyArgs[] = $context;
175 175
             $results = $strategy(...$strategyArgs);
176
-            if (! is_null($results)) {
176
+            if (!is_null($results)) {
177 177
                 foreach ($results as $index => $item) {
178 178
                     if ($stage == 'responses') {
179 179
                         // Responses are additive
@@ -185,7 +185,7 @@  discard block
 block discarded – undo
185 185
                     // and also allows values to be overwritten
186 186
 
187 187
                     // Don't allow overwriting if an empty value is trying to replace a set one
188
-                    if (! in_array($context[$stage], [null, ''], true) && in_array($item, [null, ''], true)) {
188
+                    if (!in_array($context[$stage], [null, ''], true) && in_array($item, [null, ''], true)) {
189 189
                         continue;
190 190
                     } else {
191 191
                         $context[$stage][$index] = $item;
@@ -210,8 +210,8 @@  discard block
 block discarded – undo
210 210
         $values = [];
211 211
 
212 212
         // Remove params which have no examples.
213
-        $params = array_filter($params, function ($details) {
214
-            return ! is_null($details['value']);
213
+        $params = array_filter($params, function($details) {
214
+            return !is_null($details['value']);
215 215
         });
216 216
 
217 217
         foreach ($params as $paramName => $details) {
Please login to merge, or discard this patch.
src/Commands/GenerateDocumentation.php 1 patch
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -71,7 +71,7 @@  discard block
 block discarded – undo
71 71
 
72 72
         $groupedRoutes = collect($parsedRoutes)
73 73
             ->groupBy('metadata.groupName')
74
-            ->sortBy(static function ($group) {
74
+            ->sortBy(static function($group) {
75 75
                 /* @var $group Collection */
76 76
                 return $group->first()['metadata']['groupName'];
77 77
             }, SORT_NATURAL);
@@ -102,18 +102,18 @@  discard block
 block discarded – undo
102 102
             $routePath = $generator->getUri($route);
103 103
 
104 104
             $routeControllerAndMethod = Utils::getRouteClassAndMethodNames($route->getAction());
105
-            if (! $this->isValidRoute($routeControllerAndMethod)) {
105
+            if (!$this->isValidRoute($routeControllerAndMethod)) {
106 106
                 $this->warn(sprintf($messageFormat, 'Skipping invalid', $routeMethods, $routePath));
107 107
                 continue;
108 108
             }
109 109
 
110
-            if (! $this->doesControllerMethodExist($routeControllerAndMethod)) {
111
-                $this->warn(sprintf($messageFormat, 'Skipping', $routeMethods, $routePath).': Controller method does not exist.');
110
+            if (!$this->doesControllerMethodExist($routeControllerAndMethod)) {
111
+                $this->warn(sprintf($messageFormat, 'Skipping', $routeMethods, $routePath) . ': Controller method does not exist.');
112 112
                 continue;
113 113
             }
114 114
 
115
-            if (! $this->isRouteVisibleForDocumentation($routeControllerAndMethod)) {
116
-                $this->warn(sprintf($messageFormat, 'Skipping', $routeMethods, $routePath).': @hideFromAPIDocumentation was specified.');
115
+            if (!$this->isRouteVisibleForDocumentation($routeControllerAndMethod)) {
116
+                $this->warn(sprintf($messageFormat, 'Skipping', $routeMethods, $routePath) . ': @hideFromAPIDocumentation was specified.');
117 117
                 continue;
118 118
             }
119 119
 
@@ -121,7 +121,7 @@  discard block
 block discarded – undo
121 121
                 $parsedRoutes[] = $generator->processRoute($route, $routeItem->getRules());
122 122
                 $this->info(sprintf($messageFormat, 'Processed', $routeMethods, $routePath));
123 123
             } catch (\Exception $exception) {
124
-                $this->warn(sprintf($messageFormat, 'Skipping', $routeMethods, $routePath).'- Exception '.get_class($exception).' encountered : '.$exception->getMessage());
124
+                $this->warn(sprintf($messageFormat, 'Skipping', $routeMethods, $routePath) . '- Exception ' . get_class($exception) . ' encountered : ' . $exception->getMessage());
125 125
             }
126 126
         }
127 127
 
@@ -140,10 +140,10 @@  discard block
 block discarded – undo
140 140
             if (Utils::isInvokableObject($classOrObject)) {
141 141
                 return true;
142 142
             }
143
-            $routeControllerAndMethod = $classOrObject.'@'.$method;
143
+            $routeControllerAndMethod = $classOrObject . '@' . $method;
144 144
         }
145
-        return ! is_callable($routeControllerAndMethod)
146
-            && ! is_null($routeControllerAndMethod);
145
+        return !is_callable($routeControllerAndMethod)
146
+            && !is_null($routeControllerAndMethod);
147 147
     }
148 148
 
149 149
     /**
@@ -181,7 +181,7 @@  discard block
 block discarded – undo
181 181
             $phpdoc = new DocBlock($comment);
182 182
 
183 183
             return collect($phpdoc->getTags())
184
-                ->filter(function ($tag) {
184
+                ->filter(function($tag) {
185 185
                     return $tag->getName() === 'hideFromAPIDocumentation';
186 186
                 })
187 187
                 ->isEmpty();
Please login to merge, or discard this patch.
src/Extracting/RouteDocBlocker.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
 
38 38
         $class = new ReflectionClass($className);
39 39
 
40
-        if (! $class->hasMethod($methodName)) {
40
+        if (!$class->hasMethod($methodName)) {
41 41
             throw new \Exception("Error while fetching docblock for route: Class $className does not contain method $methodName");
42 42
         }
43 43
 
@@ -64,7 +64,7 @@  discard block
 block discarded – undo
64 64
         if (is_object($classNameOrInstance)) {
65 65
             // route handlers are not destroyed until the script
66 66
             // ends so this should be perfectly safe.
67
-            $classNameOrInstance = get_class($classNameOrInstance).'::'.spl_object_id($classNameOrInstance);
67
+            $classNameOrInstance = get_class($classNameOrInstance) . '::' . spl_object_id($classNameOrInstance);
68 68
         }
69 69
 
70 70
         return $classNameOrInstance;
Please login to merge, or discard this patch.