Completed
Pull Request — master (#212)
by Salah
01:44
created
src/Mpociot/ApiDoc/Generators/AbstractGenerator.php 2 patches
Doc Comments   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -35,9 +35,9 @@  discard block
 block discarded – undo
35 35
     /**
36 36
      * Get the response from the docblock if available.
37 37
      *
38
-     * @param array $tags
38
+     * @param Tag[] $tags
39 39
      *
40
-     * @return mixed
40
+     * @return null|\Symfony\Component\HttpFoundation\Response
41 41
      */
42 42
     protected function getDocblockResponse($tags)
43 43
     {
@@ -339,7 +339,7 @@  discard block
 block discarded – undo
339 339
      * @param  string $rule
340 340
      * @param  string $parameter
341 341
      *
342
-     * @return array
342
+     * @return string
343 343
      */
344 344
     protected function parseParameters($rule, $parameter)
345 345
     {
@@ -403,7 +403,7 @@  discard block
 block discarded – undo
403 403
     }
404 404
 
405 405
     /**
406
-     * @param  $route
406
+     * @param  \Illuminate\Routing\Route $route
407 407
      * @param  $bindings
408 408
      * @param  $headers
409 409
      *
Please login to merge, or discard this patch.
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -92,7 +92,7 @@  discard block
 block discarded – undo
92 92
 
93 93
         foreach ($reflectionMethod->getParameters() as $parameter) {
94 94
             $parameterType = $parameter->getClass();
95
-            if (! is_null($parameterType) && class_exists($parameterType->name)) {
95
+            if (!is_null($parameterType) && class_exists($parameterType->name)) {
96 96
                 $className = $parameterType->name;
97 97
 
98 98
                 if (is_subclass_of($className, FormRequest::class)) {
@@ -175,7 +175,7 @@  discard block
 block discarded – undo
175 175
                 }
176 176
                 break;
177 177
             case 'between':
178
-                if (! isset($attributeData['type'])) {
178
+                if (!isset($attributeData['type'])) {
179 179
                     $attributeData['type'] = 'numeric';
180 180
                 }
181 181
                 $attributeData['description'][] = Description::parse($rule)->with($parameters)->getDescription();
@@ -378,8 +378,8 @@  discard block
 block discarded – undo
378 378
      */
379 379
     protected function fancyImplode($arr, $first, $last)
380 380
     {
381
-        $arr = array_map(function ($value) {
382
-            return '`'.$value.'`';
381
+        $arr = array_map(function($value) {
382
+            return '`' . $value . '`';
383 383
         }, $arr);
384 384
         array_push($arr, implode($last, array_splice($arr, -2)));
385 385
 
@@ -389,8 +389,8 @@  discard block
 block discarded – undo
389 389
     protected function splitValuePairs($parameters, $first = 'is ', $last = 'or ')
390 390
     {
391 391
         $attribute = '';
392
-        collect($parameters)->map(function ($item, $key) use (&$attribute, $first, $last) {
393
-            $attribute .= '`'.$item.'` ';
392
+        collect($parameters)->map(function($item, $key) use (&$attribute, $first, $last) {
393
+            $attribute .= '`' . $item . '` ';
394 394
             if (($key + 1) % 2 === 0) {
395 395
                 $attribute .= $last;
396 396
             } else {
@@ -416,7 +416,7 @@  discard block
 block discarded – undo
416 416
         $methods = $this->getMethods($route);
417 417
 
418 418
         // Split headers into key - value pairs
419
-        $headers = collect($headers)->map(function ($value) {
419
+        $headers = collect($headers)->map(function($value) {
420 420
             $split = explode(':', $value);
421 421
 
422 422
             return [trim($split[0]) => trim($split[1])];
@@ -438,7 +438,7 @@  discard block
 block discarded – undo
438 438
     {
439 439
         $uri = $this->getUri($route);
440 440
         foreach ($bindings as $model => $id) {
441
-            $uri = str_replace('{'.$model.'}', $id, $uri);
441
+            $uri = str_replace('{' . $model . '}', $id, $uri);
442 442
         }
443 443
 
444 444
         return $uri;
@@ -539,8 +539,8 @@  discard block
 block discarded – undo
539 539
         foreach ($headers as $name => $value) {
540 540
             $name = strtr(strtoupper($name), '-', '_');
541 541
 
542
-            if (! Str::startsWith($name, $prefix) && $name !== 'CONTENT_TYPE') {
543
-                $name = $prefix.$name;
542
+            if (!Str::startsWith($name, $prefix) && $name !== 'CONTENT_TYPE') {
543
+                $name = $prefix . $name;
544 544
             }
545 545
 
546 546
             $server[$name] = $value;
@@ -574,8 +574,8 @@  discard block
 block discarded – undo
574 574
     {
575 575
         $names = \array_wrap($names);
576 576
 
577
-        return \array_filter($tags, function ($tag) use ($names) {
578
-            if (! ($tag instanceof Tag)) {
577
+        return \array_filter($tags, function($tag) use ($names) {
578
+            if (!($tag instanceof Tag)) {
579 579
                 return false;
580 580
             }
581 581
 
Please login to merge, or discard this patch.
src/Mpociot/ApiDoc/Commands/ResponseMakeCommand.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -35,7 +35,7 @@  discard block
 block discarded – undo
35 35
      */
36 36
     protected function getDefaultNamespace($rootNamespace)
37 37
     {
38
-        return $rootNamespace.'\Api\Responses';
38
+        return $rootNamespace . '\Api\Responses';
39 39
     }
40 40
 
41 41
     /**
@@ -45,6 +45,6 @@  discard block
 block discarded – undo
45 45
      */
46 46
     protected function getStub()
47 47
     {
48
-        return __DIR__.'/stubs/response.stub';
48
+        return __DIR__ . '/stubs/response.stub';
49 49
     }
50 50
 }
Please login to merge, or discard this patch.
src/Mpociot/ApiDoc/Generators/LaravelGenerator.php 2 patches
Doc Comments   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -88,7 +88,7 @@  discard block
 block discarded – undo
88 88
     /**
89 89
      * Get a response from the transformer tags.
90 90
      *
91
-     * @param array $tags
91
+     * @param \Mpociot\Reflection\DocBlock\Tag[] $tags
92 92
      *
93 93
      * @return mixed
94 94
      */
@@ -182,7 +182,7 @@  discard block
 block discarded – undo
182 182
     /**
183 183
      * Get response content use responseclass tag.
184 184
      *
185
-     * @param $tags
185
+     * @param \Mpociot\Reflection\DocBlock\Tag[] $tags
186 186
      *
187 187
      * @return bool|void
188 188
      */
@@ -227,7 +227,7 @@  discard block
 block discarded – undo
227 227
     /**
228 228
      * @param Route $route
229 229
      *
230
-     * @return mixed
230
+     * @return string
231 231
      */
232 232
     public function getMethods($route)
233 233
     {
@@ -325,7 +325,7 @@  discard block
 block discarded – undo
325 325
      * Get Custom Data from data tag.
326 326
      *
327 327
      * @param $tags
328
-     * @param array $default
328
+     * @param null|false $default
329 329
      *
330 330
      * @return array|null
331 331
      */
@@ -350,7 +350,7 @@  discard block
 block discarded – undo
350 350
     /**
351 351
      * Get Response use @data tag.
352 352
      *
353
-     * @param $tags
353
+     * @param \Mpociot\Reflection\DocBlock\Tag[] $tags
354 354
      *
355 355
      * @return bool|\Illuminate\Contracts\Routing\ResponseFactory|\Symfony\Component\HttpFoundation\Response
356 356
      */
Please login to merge, or discard this patch.
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -38,7 +38,7 @@  discard block
 block discarded – undo
38 38
                 $response = $docblockResponse;
39 39
                 $showresponse = true;
40 40
             }
41
-            if (! $response) {
41
+            if (!$response) {
42 42
                 $transformerResponse = $this->getTransformerResponse($routeDescription['tags']);
43 43
                 if ($transformerResponse) {
44 44
                     // we have a transformer response from the docblock ( @transformer || @transformercollection )
@@ -46,7 +46,7 @@  discard block
 block discarded – undo
46 46
                     $showresponse = true;
47 47
                 }
48 48
             }
49
-            if (! $response) {
49
+            if (!$response) {
50 50
                 $responseClassResponse = $this->getResponseClassResponse($routeDescription['tags']);
51 51
                 if ($responseClassResponse) {
52 52
                     // we have a class response from the docblock ( @responseClass )
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
                     $showresponse = true;
55 55
                 }
56 56
             }
57
-            if (! $response) {
57
+            if (!$response) {
58 58
                 $dataResponse = $this->getDataResponse($routeDescription['tags']);
59 59
                 if ($dataResponse) {
60 60
                     // we have a data response from the docblock ( @data )
@@ -62,7 +62,7 @@  discard block
 block discarded – undo
62 62
                     $showresponse = true;
63 63
                 }
64 64
             }
65
-            if (! $response) {
65
+            if (!$response) {
66 66
                 $response = $this->getRouteResponse($route, $bindings, $headers);
67 67
             }
68 68
             if ($response->headers->get('Content-Type') === 'application/json') {
@@ -73,7 +73,7 @@  discard block
 block discarded – undo
73 73
         }
74 74
 
75 75
         return $this->getParameters([
76
-            'id' => md5($this->getUri($route).':'.implode($this->getMethods($route))),
76
+            'id' => md5($this->getUri($route) . ':' . implode($this->getMethods($route))),
77 77
             'resource' => $routeGroup,
78 78
             'title' => $routeDescription['short'],
79 79
             'description' => $routeDescription['long'],
@@ -104,7 +104,7 @@  discard block
 block discarded – undo
104 104
 
105 105
             $modelTag = $this->getFirstTagFromDocblock($tags, ['transformermodel']);
106 106
             $transformer = $transFormerTag->getContent();
107
-            if (! \class_exists($transformer)) {
107
+            if (!\class_exists($transformer)) {
108 108
                 // if we can't find the transformer we can't generate a response
109 109
                 return;
110 110
             }
@@ -119,7 +119,7 @@  discard block
 block discarded – undo
119 119
             }
120 120
             if (version_compare(PHP_VERSION, '7.0.0') >= 0 && \is_null($type)) {
121 121
                 // we can only get the type with reflection for PHP 7
122
-                if ($parameter->hasType() && ! $parameter->getType()->isBuiltin() && \class_exists((string) $parameter->getType())) {
122
+                if ($parameter->hasType() && !$parameter->getType()->isBuiltin() && \class_exists((string) $parameter->getType())) {
123 123
                     //we have a type
124 124
                     $type = (string) $parameter->getType();
125 125
                 }
@@ -160,7 +160,7 @@  discard block
 block discarded – undo
160 160
             $fractal = new Manager();
161 161
             $resource = [];
162 162
             // allow use custom serializer
163
-            if (! empty($serializer) && class_exists($serializer)) {
163
+            if (!empty($serializer) && class_exists($serializer)) {
164 164
                 $fractal->setSerializer(new $serializer());
165 165
             }
166 166
             if ($transFormerTag->getName() == 'transformer') {
@@ -197,7 +197,7 @@  discard block
 block discarded – undo
197 197
             }
198 198
 
199 199
             $responseClass = $responseClassTag->getContent();
200
-            if (! \class_exists($responseClass)) {
200
+            if (!\class_exists($responseClass)) {
201 201
                 // if we can't find the response class we can't generate a response
202 202
                 return;
203 203
             }
@@ -277,7 +277,7 @@  discard block
 block discarded – undo
277 277
 
278 278
         $kernel->terminate($request, $response);
279 279
 
280
-        if (file_exists($file = App::bootstrapPath().'/app.php')) {
280
+        if (file_exists($file = App::bootstrapPath() . '/app.php')) {
281 281
             $app = require $file;
282 282
             $app->make('Illuminate\Contracts\Console\Kernel')->bootstrap();
283 283
         }
@@ -299,7 +299,7 @@  discard block
 block discarded – undo
299 299
 
300 300
         foreach ($reflectionMethod->getParameters() as $parameter) {
301 301
             $parameterType = $parameter->getClass();
302
-            if (! is_null($parameterType) && class_exists($parameterType->name)) {
302
+            if (!is_null($parameterType) && class_exists($parameterType->name)) {
303 303
                 $className = $parameterType->name;
304 304
 
305 305
                 if (is_subclass_of($className, FormRequest::class)) {
@@ -340,7 +340,7 @@  discard block
 block discarded – undo
340 340
 
341 341
         $additionData = explode(',', $additionData->getContent());
342 342
 
343
-        $additionData = array_column(array_map(function ($v) {
343
+        $additionData = array_column(array_map(function($v) {
344 344
             return explode('|', $v);
345 345
         }, $additionData), 1, 0);
346 346
 
Please login to merge, or discard this patch.
src/Mpociot/ApiDoc/Transformers/ResponseApiDataAbstract.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -144,7 +144,7 @@  discard block
 block discarded – undo
144 144
      */
145 145
     public function toArray()
146 146
     {
147
-        return array_map(function ($value) {
147
+        return array_map(function($value) {
148 148
             return $value instanceof Arrayable ? $value->toArray() : $value;
149 149
         }, $this->response());
150 150
     }
@@ -178,7 +178,7 @@  discard block
 block discarded – undo
178 178
      */
179 179
     public function jsonSerialize()
180 180
     {
181
-        return array_map(function ($value) {
181
+        return array_map(function($value) {
182 182
             if ($value instanceof JsonSerializable) {
183 183
                 return $value->jsonSerialize();
184 184
             } elseif ($value instanceof Jsonable) {
@@ -208,13 +208,13 @@  discard block
 block discarded – undo
208 208
         $response->setData($this->toArray());
209 209
 
210 210
         if (is_int($statusCode)) {
211
-            $statusCode = function (JsonResponse $response) use ($statusCode) {
211
+            $statusCode = function(JsonResponse $response) use ($statusCode) {
212 212
                 return $response->setStatusCode($statusCode);
213 213
             };
214 214
         }
215 215
 
216 216
         if (is_array($headers)) {
217
-            $headers = function (JsonResponse $response) use ($headers) {
217
+            $headers = function(JsonResponse $response) use ($headers) {
218 218
                 return $response->withHeaders($headers);
219 219
             };
220 220
         }
@@ -240,7 +240,7 @@  discard block
 block discarded – undo
240 240
      */
241 241
     public function __call($name, $arguments)
242 242
     {
243
-        if (! method_exists($this, $name)) {
243
+        if (!method_exists($this, $name)) {
244 244
             return $this->getData()->$name(...$arguments);
245 245
         }
246 246
 
Please login to merge, or discard this patch.