Passed
Push — master ( 6063b2...1b381e )
by Fran
03:05
created
src/base/types/helpers/InjectorHelper.php 2 patches
Doc Comments   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -74,8 +74,8 @@  discard block
 block discarded – undo
74 74
 
75 75
     /**
76 76
      * Method extract if a variable is required
77
-     * @param $doc
78
-     * @return null|string
77
+     * @param string $doc
78
+     * @return boolean
79 79
      */
80 80
     public static function checkIsRequired($doc)
81 81
     {
@@ -88,8 +88,8 @@  discard block
 block discarded – undo
88 88
 
89 89
     /**
90 90
      * Method extract if a class or variable is visible
91
-     * @param $doc
92
-     * @return null|string
91
+     * @param string $doc
92
+     * @return boolean
93 93
      */
94 94
     public static function checkIsVisible($doc)
95 95
     {
@@ -101,7 +101,7 @@  discard block
 block discarded – undo
101 101
     }
102 102
 
103 103
     /**
104
-     * @param $doc
104
+     * @param string $doc
105 105
      * @return null|string
106 106
      */
107 107
     public static function getLabel($doc) {
@@ -115,8 +115,8 @@  discard block
 block discarded – undo
115 115
     }
116 116
 
117 117
     /**
118
-     * @param $doc
119
-     * @return null
118
+     * @param string $doc
119
+     * @return string|null
120 120
      */
121 121
     public static function getDefaultValue($doc) {
122 122
         $default = null;
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -108,7 +108,7 @@  discard block
 block discarded – undo
108 108
         // Extract description
109 109
         $label = null;
110 110
         preg_match('/@label\ (.*)\n/i', $doc, $matches);
111
-        if(count($matches)) {
111
+        if (count($matches)) {
112 112
             $label = _($matches[1]);
113 113
         }
114 114
         return $label;
@@ -121,7 +121,7 @@  discard block
 block discarded – undo
121 121
     public static function getDefaultValue($doc) {
122 122
         $default = null;
123 123
         preg_match('/@default\ (.*)\n/i', $doc, $matches);
124
-        if(count($matches)) {
124
+        if (count($matches)) {
125 125
             $default = $matches[1];
126 126
         }
127 127
         return $default;
@@ -137,13 +137,13 @@  discard block
 block discarded – undo
137 137
      */
138 138
     public static function constructInyectableInstance($variable, $singleton, $classNameSpace, $calledClass)
139 139
     {
140
-        Logger::log('Create inyectable instance for ' . $classNameSpace);
140
+        Logger::log('Create inyectable instance for '.$classNameSpace);
141 141
         $reflector = new \ReflectionClass($calledClass);
142 142
         $property = $reflector->getProperty($variable);
143 143
         $varInstanceType = (null === $classNameSpace) ? InjectorHelper::extractVarType($property->getDocComment()) : $classNameSpace;
144 144
         if (true === $singleton && method_exists($varInstanceType, "getInstance")) {
145 145
             $instance = $varInstanceType::getInstance();
146
-        } else {
146
+        }else {
147 147
             $instance = new $varInstanceType();
148 148
         }
149 149
         return $instance;
@@ -157,7 +157,7 @@  discard block
 block discarded – undo
157 157
     public static function getClassProperties($class)
158 158
     {
159 159
         $properties = [];
160
-        Logger::log('Extracting annotations properties from class ' . $class);
160
+        Logger::log('Extracting annotations properties from class '.$class);
161 161
         $selfReflector = new \ReflectionClass($class);
162 162
         if (false !== $selfReflector->getParentClass()) {
163 163
             $properties = self::getClassProperties($selfReflector->getParentClass()->getName());
Please login to merge, or discard this patch.
src/services/DocumentorService.php 1 patch
Spacing   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -57,10 +57,10 @@  discard block
 block discarded – undo
57 57
                     if (!preg_match('/^ROOT/i', $module) && $module == $requestModule) {
58 58
                         $modules = [
59 59
                             'name' => $module,
60
-                            'path' => realpath($info['template'] . DIRECTORY_SEPARATOR . '..'),
60
+                            'path' => realpath($info['template'].DIRECTORY_SEPARATOR.'..'),
61 61
                         ];
62 62
                     }
63
-                } catch (\Exception $e) {
63
+                }catch (\Exception $e) {
64 64
                     $modules[] = $e->getMessage();
65 65
                 }
66 66
             }
@@ -78,7 +78,7 @@  discard block
 block discarded – undo
78 78
      */
79 79
     public function extractApiEndpoints(array $module)
80 80
     {
81
-        $module_path = $module['path'] . DIRECTORY_SEPARATOR . 'Api';
81
+        $module_path = $module['path'].DIRECTORY_SEPARATOR.'Api';
82 82
         $module_name = $module['name'];
83 83
         $endpoints = [];
84 84
         if (file_exists($module_path)) {
@@ -87,7 +87,7 @@  discard block
 block discarded – undo
87 87
             if (count($finder)) {
88 88
                 /** @var \SplFileInfo $file */
89 89
                 foreach ($finder as $file) {
90
-                    $namespace = "\\{$module_name}\\Api\\" . str_replace('.php', '', $file->getFilename());
90
+                    $namespace = "\\{$module_name}\\Api\\".str_replace('.php', '', $file->getFilename());
91 91
                     $info = $this->extractApiInfo($namespace, $module_name);
92 92
                     if (!empty($info)) {
93 93
                         $endpoints[$namespace] = $info;
@@ -111,14 +111,14 @@  discard block
 block discarded – undo
111 111
         if (Router::exists($namespace) && !I18nHelper::checkI18Class($namespace)) {
112 112
             $reflection = new \ReflectionClass($namespace);
113 113
             $visible = InjectorHelper::checkIsVisible($reflection->getDocComment());
114
-            if($visible) {
114
+            if ($visible) {
115 115
                 foreach ($reflection->getMethods(\ReflectionMethod::IS_PUBLIC) as $method) {
116 116
                     try {
117 117
                         $mInfo = $this->extractMethodInfo($namespace, $method, $reflection, $module);
118 118
                         if (NULL !== $mInfo) {
119 119
                             $info[] = $mInfo;
120 120
                         }
121
-                    } catch (\Exception $e) {
121
+                    }catch (\Exception $e) {
122 122
                         Logger::getInstance()->errorLog($e->getMessage());
123 123
                     }
124 124
                 }
@@ -251,7 +251,7 @@  discard block
 block discarded – undo
251 251
             $payload = $this->extractModelFields($namespace);
252 252
             $reflector = new \ReflectionClass($namespace);
253 253
             $namespace = $reflector->getShortName();
254
-        } else {
254
+        }else {
255 255
             $namespace = $model;
256 256
         }
257 257
 
@@ -338,10 +338,10 @@  discard block
 block discarded – undo
338 338
                         "required" => $field->isNotNull(),
339 339
                         'format' => $format,
340 340
                     ];
341
-                    if(count($field->getValueSet())) {
341
+                    if (count($field->getValueSet())) {
342 342
                         $info['enum'] = array_values($field->getValueSet());
343 343
                     }
344
-                    if(null !== $field->getDefaultValue()) {
344
+                    if (null !== $field->getDefaultValue()) {
345 345
                         $info['default'] = $field->getDefaultValue();
346 346
                     }
347 347
                     $payload[$field->getPhpName()] = $info;
@@ -349,7 +349,7 @@  discard block
 block discarded – undo
349 349
             } elseif (null !== $reflector && $reflector->isSubclassOf(self::DTO_INTERFACE)) {
350 350
                 $payload = $this->extractDtoProperties($namespace);
351 351
             }
352
-        } catch (\Exception $e) {
352
+        }catch (\Exception $e) {
353 353
             Logger::getInstance()->errorLog($e->getMessage());
354 354
         }
355 355
 
@@ -380,7 +380,7 @@  discard block
 block discarded – undo
380 380
                     $return = $this->extractReturn($modelNamespace, $docComments);
381 381
                     $url = array_pop($route);
382 382
                     $methodInfo = [
383
-                        'url' => str_replace("/" . $module . "/api", '', $url),
383
+                        'url' => str_replace("/".$module."/api", '', $url),
384 384
                         'method' => $info['http'],
385 385
                         'description' => $info['label'],
386 386
                         'return' => $return,
@@ -391,7 +391,7 @@  discard block
 block discarded – undo
391 391
                     $this->setRequestParams($method, $methodInfo, $modelNamespace, $docComments);
392 392
                     $this->setQueryParams($method, $methodInfo);
393 393
                     $this->setRequestHeaders($reflection, $methodInfo);
394
-                } catch (\Exception $e) {
394
+                }catch (\Exception $e) {
395 395
                     Logger::getInstance()->errorLog($e->getMessage());
396 396
                 }
397 397
             }
@@ -460,10 +460,10 @@  discard block
 block discarded – undo
460 460
         $formatted = [
461 461
             "swagger" => "2.0",
462 462
             "host" => preg_replace('/^(http|https)\:\/\/(.*)\/$/i', '$2', Router::getInstance()->getRoute('', true)),
463
-            "basePath" => '/' . $module['name'] . '/api',
463
+            "basePath" => '/'.$module['name'].'/api',
464 464
             "schemes" => [Request::getInstance()->getServer('HTTPS') == 'on' ? "https" : "http"],
465 465
             "info" => [
466
-                "title" => _('Documentación API módulo ') . $module['name'],
466
+                "title" => _('Documentación API módulo ').$module['name'],
467 467
                 "version" => Config::getParam('api.version', '1.0.0'),
468 468
                 "contact" => [
469 469
                     "name" => Config::getParam("author", "Fran López"),
@@ -476,7 +476,7 @@  discard block
 block discarded – undo
476 476
         foreach ($endpoints as $model) {
477 477
             foreach ($model as $endpoint) {
478 478
                 if (!preg_match('/^\/(admin|api)\//i', $endpoint['url']) && strlen($endpoint['url'])) {
479
-                    $url = preg_replace('/\/' . $module['name'] . '\/api/i', '', $endpoint['url']);
479
+                    $url = preg_replace('/\/'.$module['name'].'\/api/i', '', $endpoint['url']);
480 480
                     $description = $endpoint['description'];
481 481
                     $method = strtolower($endpoint['method']);
482 482
                     $paths[$url][$method] = [
@@ -535,7 +535,7 @@  discard block
 block discarded – undo
535 535
     protected function extractDtoName($dto, $isArray = false)
536 536
     {
537 537
         $dto = explode('\\', $dto);
538
-        $modelDto = array_pop($dto) . "Dto";
538
+        $modelDto = array_pop($dto)."Dto";
539 539
         if ($isArray) {
540 540
             $modelDto .= "List";
541 541
         }
@@ -585,10 +585,10 @@  discard block
 block discarded – undo
585 585
     {
586 586
 
587 587
         $methodInfo['headers'] = [];
588
-        foreach($reflection->getProperties() as $property) {
588
+        foreach ($reflection->getProperties() as $property) {
589 589
             $doc = $property->getDocComment();
590 590
             preg_match('/@header\ (.*)\n/i', $doc, $headers);
591
-            if(count($headers)) {
591
+            if (count($headers)) {
592 592
                 $header = [
593 593
                     "name" => $headers[1],
594 594
                     "in" => "header",
@@ -632,7 +632,7 @@  discard block
 block discarded – undo
632 632
             foreach ($method->getParameters() as $parameter) {
633 633
                 $parameterName = $parameter->getName();
634 634
                 $types = [];
635
-                preg_match_all('/\@param\ (.*)\ \$' . $parameterName . '$/im', $docComments, $types);
635
+                preg_match_all('/\@param\ (.*)\ \$'.$parameterName.'$/im', $docComments, $types);
636 636
                 if (count($types) > 1) {
637 637
                     $methodInfo['parameters'][$parameterName] = $types[1][0];
638 638
                 }
Please login to merge, or discard this patch.
src/base/types/helpers/DocumentorHelper.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -27,10 +27,10 @@  discard block
 block discarded – undo
27 27
         ];
28 28
         if ($endpoint['payload']['is_array']) {
29 29
             $schema['items'] = [
30
-                '$ref' => '#/definitions/' . $endpoint['payload']['type'],
30
+                '$ref' => '#/definitions/'.$endpoint['payload']['type'],
31 31
             ];
32
-        } else {
33
-            $schema['$ref'] = '#/definitions/' . $endpoint['payload']['type'];
32
+        }else {
33
+            $schema['$ref'] = '#/definitions/'.$endpoint['payload']['type'];
34 34
         }
35 35
         $paths[$url][$method]['parameters'][] = [
36 36
             'in' => 'body',
@@ -58,13 +58,13 @@  discard block
 block discarded – undo
58 58
             if (array_key_exists('data', $endpoint['return']) && count(array_keys($object)) === count(array_keys($endpoint['return']['data']))) {
59 59
                 $classDefinition = [
60 60
                     'type' => 'object',
61
-                    '$ref' => '#/definitions/' . $class,
61
+                    '$ref' => '#/definitions/'.$class,
62 62
                 ];
63
-            } else {
63
+            }else {
64 64
                 $classDefinition = [
65 65
                     'type' => 'array',
66 66
                     'items' => [
67
-                        '$ref' => '#/definitions/' . $class,
67
+                        '$ref' => '#/definitions/'.$class,
68 68
                     ],
69 69
                 ];
70 70
             }
@@ -150,10 +150,10 @@  discard block
 block discarded – undo
150 150
                 "type" => $type,
151 151
                 "required" => $info['required'],
152 152
             ];
153
-            if(array_key_exists('description', $info)) {
153
+            if (array_key_exists('description', $info)) {
154 154
                 $fieldData['description'] = $info['description'];
155 155
             }
156
-            if(array_key_exists('format', $info)) {
156
+            if (array_key_exists('format', $info)) {
157 157
                 $fieldData['format'] = $info['format'];
158 158
             }
159 159
             $dto['properties'][$field] = $fieldData;
Please login to merge, or discard this patch.