Passed
Push — main ( e73f01...75fb65 )
by Thierry
08:57 queued 36s
created
src/AnnotationReader.php 2 patches
Braces   +2 added lines, -4 removed lines patch added patch discarded remove patch
@@ -136,15 +136,13 @@
 block discarded – undo
136 136
                 if(isset($aMethodAttrs['protected']))
137 137
                 {
138 138
                     $aProtected[] = $sMethod; // The method is not to be exported.
139
-                }
140
-                elseif(count($aMethodAttrs) > 0)
139
+                } elseif(count($aMethodAttrs) > 0)
141 140
                 {
142 141
                     $aAttributes[$sMethod] = $aMethodAttrs;
143 142
                 }
144 143
             }
145 144
             return [false, $aAttributes, $aProtected];
146
-        }
147
-        catch(AnnotationException $e)
145
+        } catch(AnnotationException $e)
148 146
         {
149 147
             throw new SetupException($e->getMessage());
150 148
         }
Please login to merge, or discard this patch.
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -105,13 +105,13 @@  discard block
 block discarded – undo
105 105
         });
106 106
 
107 107
         $aAttributes = [];
108
-        foreach($aAnnotations as $xAnnotation)
108
+        foreach ($aAnnotations as $xAnnotation)
109 109
         {
110 110
             $xAnnotation->setReader($this);
111 111
             $sName = $xAnnotation->getName();
112 112
             $xAnnotation->setPrevValue($aAttributes[$sName] ?? null);
113 113
             $xValue = $xAnnotation->getValue();
114
-            if($sName === 'protected' && !$xValue)
114
+            if ($sName === 'protected' && !$xValue)
115 115
             {
116 116
                 // Ignore annotation @exclude with value false
117 117
                 continue;
@@ -158,7 +158,7 @@  discard block
 block discarded – undo
158 158
         // Only keep the annotations declared in this package.
159 159
         $aAnnotations = array_filter($aAnnotations, function($xAnnotation) use($sProperty) {
160 160
             // Save the property type
161
-            if(is_a($xAnnotation, VarAnnotation::class))
161
+            if (is_a($xAnnotation, VarAnnotation::class))
162 162
             {
163 163
                 $this->aPropTypes[$sProperty] = $xAnnotation->type;
164 164
             }
@@ -167,7 +167,7 @@  discard block
 block discarded – undo
167 167
         });
168 168
 
169 169
         $aAttributes = [];
170
-        foreach($aAnnotations as $xAnnotation)
170
+        foreach ($aAnnotations as $xAnnotation)
171 171
         {
172 172
             $xAnnotation->setReader($this);
173 173
             $xAnnotation->setAttr($sProperty);
@@ -198,10 +198,10 @@  discard block
 block discarded – undo
198 198
             $this->aPropTypes = [];
199 199
             $aPropAttrs = [];
200 200
             // Properties annotations
201
-            foreach($aProperties as $sProperty)
201
+            foreach ($aProperties as $sProperty)
202 202
             {
203 203
                 $aPropertyAttrs = $this->getPropertyAttrs($sClass, $sProperty);
204
-                foreach($aPropertyAttrs as $sName => $xValue)
204
+                foreach ($aPropertyAttrs as $sName => $xValue)
205 205
                 {
206 206
                     $aPropAttrs[$sName] = array_merge($aPropAttrs[$sName] ?? [], $xValue);
207 207
                 }
@@ -211,13 +211,13 @@  discard block
 block discarded – undo
211 211
             $this->sCurrMemberType = AnnotationManager::MEMBER_CLASS;
212 212
 
213 213
             $aClassAttrs = $this->getClassAttrs($sClass);
214
-            if(isset($aClassAttrs['protected']))
214
+            if (isset($aClassAttrs['protected']))
215 215
             {
216 216
                 return [true, [], []]; // The entire class is not to be exported.
217 217
             }
218 218
 
219 219
             // Merge attributes and class annotations
220
-            foreach($aPropAttrs as $sName => $xValue)
220
+            foreach ($aPropAttrs as $sName => $xValue)
221 221
             {
222 222
                 $aClassAttrs[$sName] = array_merge($aClassAttrs[$sName] ?? [], $xValue);
223 223
             }
@@ -227,21 +227,21 @@  discard block
 block discarded – undo
227 227
 
228 228
             $aAttributes = count($aClassAttrs) > 0 ? ['*' => $aClassAttrs] : [];
229 229
             $aProtected = [];
230
-            foreach($aMethods as $sMethod)
230
+            foreach ($aMethods as $sMethod)
231 231
             {
232 232
                 $aMethodAttrs = $this->getMethodAttrs($sClass, $sMethod);
233
-                if(isset($aMethodAttrs['protected']))
233
+                if (isset($aMethodAttrs['protected']))
234 234
                 {
235 235
                     $aProtected[] = $sMethod; // The method is not to be exported.
236 236
                 }
237
-                elseif(count($aMethodAttrs) > 0)
237
+                elseif (count($aMethodAttrs) > 0)
238 238
                 {
239 239
                     $aAttributes[$sMethod] = $aMethodAttrs;
240 240
                 }
241 241
             }
242 242
             return [false, $aAttributes, $aProtected];
243 243
         }
244
-        catch(AnnotationException $e)
244
+        catch (AnnotationException $e)
245 245
         {
246 246
             throw new SetupException($e->getMessage());
247 247
         }
Please login to merge, or discard this patch.
src/Annotation/DataBagAnnotation.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -61,11 +61,11 @@  discard block
 block discarded – undo
61 61
      */
62 62
     public function initAnnotation(array $properties)
63 63
     {
64
-        if(count($properties) !== 1 || !isset($properties['name']) || !is_string($properties['name']))
64
+        if (count($properties) !== 1 || !isset($properties['name']) || !is_string($properties['name']))
65 65
         {
66 66
             throw new AnnotationException('The @databag annotation requires a property "name" of type string');
67 67
         }
68
-        if(!$this->validateDataBagName($properties['name']))
68
+        if (!$this->validateDataBagName($properties['name']))
69 69
         {
70 70
             throw new AnnotationException($properties['name'] . ' is not a valid "name" value for the @databag annotation');
71 71
         }
@@ -85,7 +85,7 @@  discard block
 block discarded – undo
85 85
      */
86 86
     public function getValue()
87 87
     {
88
-        if(is_array($this->xPrevValue))
88
+        if (is_array($this->xPrevValue))
89 89
         {
90 90
             $this->xPrevValue[] = $this->sName; // Append the current value to the array
91 91
             return $this->xPrevValue;
Please login to merge, or discard this patch.
src/Annotation/ExcludeAnnotation.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -38,11 +38,11 @@  discard block
 block discarded – undo
38 38
      */
39 39
     public static function parseAnnotation($value)
40 40
     {
41
-        if($value === 'true')
41
+        if ($value === 'true')
42 42
         {
43 43
             return [true];
44 44
         }
45
-        if($value === 'false')
45
+        if ($value === 'false')
46 46
         {
47 47
             return [false];
48 48
         }
@@ -55,7 +55,7 @@  discard block
 block discarded – undo
55 55
      */
56 56
     public function initAnnotation(array $properties)
57 57
     {
58
-        if(count($properties) !== 0 &&
58
+        if (count($properties) !== 0 &&
59 59
             (count($properties) !== 1 || !isset($properties[0]) || !is_bool($properties[0])))
60 60
         {
61 61
             throw new AnnotationException('the @exclude annotation requires a single boolean or no property');
Please login to merge, or discard this patch.
src/Annotation/UploadAnnotation.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -60,11 +60,11 @@  discard block
 block discarded – undo
60 60
      */
61 61
     public function initAnnotation(array $properties)
62 62
     {
63
-        if(count($properties) != 1 || !isset($properties['field']) || !is_string($properties['field']))
63
+        if (count($properties) != 1 || !isset($properties['field']) || !is_string($properties['field']))
64 64
         {
65 65
             throw new AnnotationException('The @upload annotation requires a property "field" of type string');
66 66
         }
67
-        if(!$this->validateUploadField($properties['field']))
67
+        if (!$this->validateUploadField($properties['field']))
68 68
         {
69 69
             throw new AnnotationException($properties['field'] . ' is not a valid "field" value for the @upload annotation');
70 70
         }
@@ -84,6 +84,6 @@  discard block
 block discarded – undo
84 84
      */
85 85
     public function getValue()
86 86
     {
87
-        return "'" . $this->sField . "'" ; // The field id is surrounded with simple quotes.
87
+        return "'" . $this->sField . "'"; // The field id is surrounded with simple quotes.
88 88
     }
89 89
 }
Please login to merge, or discard this patch.
src/Annotation/ContainerAnnotation.php 2 patches
Switch Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -197,14 +197,14 @@
 block discarded – undo
197 197
         $nCount = count($this->properties);
198 198
         switch($nCount)
199 199
         {
200
-        case 0:
201
-            return true;
202
-        case 1:
203
-            return isset($this->properties['attr']) || isset($this->properties['class']);
204
-        case 2:
205
-            return isset($this->properties['attr']) && isset($this->properties['class']);
206
-        default:
207
-            return false;
200
+            case 0:
201
+                return true;
202
+            case 1:
203
+                return isset($this->properties['attr']) || isset($this->properties['class']);
204
+            case 2:
205
+                return isset($this->properties['attr']) && isset($this->properties['class']);
206
+            default:
207
+                return false;
208 208
         }
209 209
     }
210 210
 
Please login to merge, or discard this patch.
Spacing   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -134,7 +134,7 @@  discard block
 block discarded – undo
134 134
      */
135 135
     private function getFullClassName(string $sClassName): string
136 136
     {
137
-        return ltrim($this->xClassFile->resolveType($sClassName), '\\');;
137
+        return ltrim($this->xClassFile->resolveType($sClassName), '\\'); ;
138 138
     }
139 139
 
140 140
     /**
@@ -146,38 +146,38 @@  discard block
 block discarded – undo
146 146
         $value = $this->properties['__value__'];
147 147
         $aParams = preg_split('/[\s]+/', $value, 3);
148 148
         $nParamCount = count($aParams);
149
-        if($nParamCount === 1)
149
+        if ($nParamCount === 1)
150 150
         {
151 151
             // For a property, the only parameter is the class. Otherwise, it is the attribute.
152
-            if($this->xReader->annotationIsOnProperty())
152
+            if ($this->xReader->annotationIsOnProperty())
153 153
             {
154
-                if(substr($aParams[0], 0, 1) === '$')
154
+                if (substr($aParams[0], 0, 1) === '$')
155 155
                 {
156 156
                     throw new AnnotationException('The only property of the @di annotation must be a class name');
157 157
                 }
158 158
                 $this->sClass = $this->getFullClassName($aParams[0]);
159 159
                 return;
160 160
             }
161
-            if(substr($aParams[0], 0, 1) !== '$')
161
+            if (substr($aParams[0], 0, 1) !== '$')
162 162
             {
163 163
                 throw new AnnotationException('The only property of the @di annotation must be a var name');
164 164
             }
165 165
             $this->sAttr = substr($aParams[0], 1);
166 166
             return;
167 167
         }
168
-        if($nParamCount === 2)
168
+        if ($nParamCount === 2)
169 169
         {
170 170
             // For a property, having 2 parameters is not allowed.
171
-            if($this->xReader->annotationIsOnProperty())
171
+            if ($this->xReader->annotationIsOnProperty())
172 172
             {
173 173
                 throw new AnnotationException('The @di annotation accepts only one property on a class attribute');
174 174
             }
175 175
 
176
-            if(substr($aParams[0], 0, 1) !== '$')
176
+            if (substr($aParams[0], 0, 1) !== '$')
177 177
             {
178 178
                 throw new AnnotationException('The only property of the @di annotation must be a var name');
179 179
             }
180
-            if(substr($aParams[1], 0, 1) === '$')
180
+            if (substr($aParams[1], 0, 1) === '$')
181 181
             {
182 182
                 throw new AnnotationException('The first property of the @di annotation must be a class name');
183 183
             }
@@ -195,7 +195,7 @@  discard block
 block discarded – undo
195 195
     private function checkPropertiesNames(): bool
196 196
     {
197 197
         $nCount = count($this->properties);
198
-        switch($nCount)
198
+        switch ($nCount)
199 199
         {
200 200
         case 0:
201 201
             return true;
@@ -214,26 +214,26 @@  discard block
 block discarded – undo
214 214
      */
215 215
     private function parseProperties()
216 216
     {
217
-        if(!$this->checkPropertiesNames())
217
+        if (!$this->checkPropertiesNames())
218 218
         {
219 219
             throw new AnnotationException('The @di annotation accepts only "attr" or "class" as properties');
220 220
         }
221 221
 
222
-        if(isset($this->properties['attr']))
222
+        if (isset($this->properties['attr']))
223 223
         {
224
-            if($this->xReader->annotationIsOnProperty())
224
+            if ($this->xReader->annotationIsOnProperty())
225 225
             {
226 226
                 throw new AnnotationException('The @di annotation does not allow the "attr" property on class attributes');
227 227
             }
228
-            if(!is_string($this->properties['attr']))
228
+            if (!is_string($this->properties['attr']))
229 229
             {
230 230
                 throw new AnnotationException('The @di annotation requires a property "attr" of type string');
231 231
             }
232 232
             $this->sAttr = $this->properties['attr'];
233 233
         }
234
-        if(isset($this->properties['class']))
234
+        if (isset($this->properties['class']))
235 235
         {
236
-            if(!is_string($this->properties['class']))
236
+            if (!is_string($this->properties['class']))
237 237
             {
238 238
                 throw new AnnotationException('The @di annotation requires a property "class" of type string');
239 239
             }
@@ -251,25 +251,25 @@  discard block
 block discarded – undo
251 251
 
252 252
         // The type in the @di annotations can be set from the values in the @var annotations
253 253
         $aPropTypes = $this->xReader->getPropTypes();
254
-        if($this->sClass === '' && isset($aPropTypes[$this->sAttr]))
254
+        if ($this->sClass === '' && isset($aPropTypes[$this->sAttr]))
255 255
         {
256 256
             $this->sClass = ltrim($aPropTypes[$this->sAttr], '\\');
257 257
         }
258 258
 
259
-        if($this->xReader->annotationIsOnProperty() && $this->xPrevValue !== null)
259
+        if ($this->xReader->annotationIsOnProperty() && $this->xPrevValue !== null)
260 260
         {
261 261
             throw new AnnotationException('Only one @di annotation is allowed on a property');
262 262
         }
263
-        if(!$this->validateAttrName($this->sAttr))
263
+        if (!$this->validateAttrName($this->sAttr))
264 264
         {
265 265
             throw new AnnotationException($this->sAttr . ' is not a valid "attr" value for the @di annotation');
266 266
         }
267
-        if(!$this->validateClassName($this->sClass))
267
+        if (!$this->validateClassName($this->sClass))
268 268
         {
269 269
             throw new AnnotationException($this->sClass . ' is not a valid "class" value for the @di annotation');
270 270
         }
271 271
 
272
-        if(is_array($this->xPrevValue))
272
+        if (is_array($this->xPrevValue))
273 273
         {
274 274
             $this->xPrevValue[$this->sAttr] = $this->sClass; // Append the current value to the array
275 275
             return $this->xPrevValue;
Please login to merge, or discard this patch.
src/Annotation/HookAnnotation.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -57,7 +57,7 @@  discard block
 block discarded – undo
57 57
     public static function parseAnnotation($value)
58 58
     {
59 59
         $aParams = preg_split('/[\s]+/', $value, 2);
60
-        if(count($aParams) === 1)
60
+        if (count($aParams) === 1)
61 61
         {
62 62
             return ['call' => rtrim($aParams[0])];
63 63
         }
@@ -81,28 +81,28 @@  discard block
 block discarded – undo
81 81
      */
82 82
     public function initAnnotation(array $properties)
83 83
     {
84
-        if(!isset($properties['call']) || !is_string($properties['call']))
84
+        if (!isset($properties['call']) || !is_string($properties['call']))
85 85
         {
86 86
             throw new AnnotationException('The @' . $this->getType() .
87 87
                 ' annotation requires a property "call" of type string');
88 88
         }
89
-        if(!$this->validateMethodName($properties['call']))
89
+        if (!$this->validateMethodName($properties['call']))
90 90
         {
91 91
             throw new AnnotationException($properties['call'] .
92 92
                 ' is not a valid "call" value for the @' . $this->getType() . ' annotation');
93 93
         }
94
-        foreach(array_keys($properties) as $propName)
94
+        foreach (array_keys($properties) as $propName)
95 95
         {
96
-            if($propName !== 'call' && $propName !== 'with')
96
+            if ($propName !== 'call' && $propName !== 'with')
97 97
             {
98 98
                 throw new AnnotationException('Unknown property "' . $propName .
99 99
                     '" in the @' . $this->getType() . ' annotation');
100 100
             }
101 101
         }
102 102
         // Cannot use isset here, because it will return false in case $properties['with'] === null
103
-        if(array_key_exists('with', $properties))
103
+        if (array_key_exists('with', $properties))
104 104
         {
105
-            if(!is_array($properties['with']))
105
+            if (!is_array($properties['with']))
106 106
             {
107 107
                 throw new AnnotationException('The "with" property of the @' .
108 108
                     $this->getType() . ' annotation must be of type array');
@@ -117,7 +117,7 @@  discard block
 block discarded – undo
117 117
      */
118 118
     public function getValue()
119 119
     {
120
-        if(is_array($this->xPrevValue))
120
+        if (is_array($this->xPrevValue))
121 121
         {
122 122
             // Add the current value to the array
123 123
             $this->xPrevValue[$this->sMethodName] = $this->sMethodParams;
Please login to merge, or discard this patch.
src/Annotation/CallbackAnnotation.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -62,11 +62,11 @@
 block discarded – undo
62 62
      */
63 63
     public function initAnnotation(array $properties)
64 64
     {
65
-        if(count($properties) !== 1 || !isset($properties['name']) || !is_string($properties['name']))
65
+        if (count($properties) !== 1 || !isset($properties['name']) || !is_string($properties['name']))
66 66
         {
67 67
             throw new AnnotationException('the @callback annotation requires a single string as property');
68 68
         }
69
-        if(!$this->validateObjectName($properties['name']))
69
+        if (!$this->validateObjectName($properties['name']))
70 70
         {
71 71
             throw new AnnotationException($properties['name'] . ' is not a valid "name" value for the @callback annotation');
72 72
         }
Please login to merge, or discard this patch.
src/start.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -21,13 +21,13 @@  discard block
 block discarded – undo
21 21
  */
22 22
 function register(Container $di, bool $bForce = false)
23 23
 {
24
-    if(!$bForce && $di->h(AnnotationReader::class))
24
+    if (!$bForce && $di->h(AnnotationReader::class))
25 25
     {
26 26
         return;
27 27
     }
28 28
 
29 29
     $sCacheDirKey = 'jaxon_annotations_cache_dir';
30
-    if(!$di->h($sCacheDirKey))
30
+    if (!$di->h($sCacheDirKey))
31 31
     {
32 32
         $di->val($sCacheDirKey, sys_get_temp_dir());
33 33
     }
@@ -48,7 +48,7 @@  discard block
 block discarded – undo
48 48
 {
49 49
     $di = Ajax::getInstance()->di();
50 50
     $sEventListenerKey = AnnotationReader::class . '\\ConfigListener';
51
-    if($di->h($sEventListenerKey))
51
+    if ($di->h($sEventListenerKey))
52 52
     {
53 53
         return;
54 54
     }
@@ -61,7 +61,7 @@  discard block
 block discarded – undo
61 61
             public function onChange(Config $xConfig, string $sName)
62 62
             {
63 63
                 $sConfigKey = 'core.annotations.enabled';
64
-                if(($sName === $sConfigKey || $sName === '') && $xConfig->getOption($sConfigKey))
64
+                if (($sName === $sConfigKey || $sName === '') && $xConfig->getOption($sConfigKey))
65 65
                 {
66 66
                     register(Ajax::getInstance()->di());
67 67
                 }
Please login to merge, or discard this patch.