Passed
Push — main ( 3c9057...95769b )
by Thierry
10:09 queued 07:11
created
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/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 = Jaxon::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(Jaxon::getInstance()->di());
67 67
                 }
Please login to merge, or discard this patch.
src/Annotation/ContainerAnnotation.php 1 patch
Spacing   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -145,38 +145,38 @@  discard block
 block discarded – undo
145 145
         $value = $this->properties['__value__'];
146 146
         $aParams = preg_split('/[\s]+/', $value, 3);
147 147
         $nParamCount = count($aParams);
148
-        if($nParamCount === 1)
148
+        if ($nParamCount === 1)
149 149
         {
150 150
             // For a property, the only parameter is the class. Otherwise, it is the attribute.
151
-            if($this->xReader->annotationIsOnProperty())
151
+            if ($this->xReader->annotationIsOnProperty())
152 152
             {
153
-                if(substr($aParams[0], 0, 1) === '$')
153
+                if (substr($aParams[0], 0, 1) === '$')
154 154
                 {
155 155
                     throw new AnnotationException('The only property of the @di annotation must be a class name');
156 156
                 }
157 157
                 $this->sClass = $this->getFullClassName($aParams[0]);
158 158
                 return;
159 159
             }
160
-            if(substr($aParams[0], 0, 1) !== '$')
160
+            if (substr($aParams[0], 0, 1) !== '$')
161 161
             {
162 162
                 throw new AnnotationException('The only property of the @di annotation must be a var name');
163 163
             }
164 164
             $this->sAttr = substr($aParams[0], 1);
165 165
             return;
166 166
         }
167
-        if($nParamCount === 2)
167
+        if ($nParamCount === 2)
168 168
         {
169 169
             // For a property, having 2 parameters is not allowed.
170
-            if($this->xReader->annotationIsOnProperty())
170
+            if ($this->xReader->annotationIsOnProperty())
171 171
             {
172 172
                 throw new AnnotationException('The @di annotation accepts only one property on a class attribute');
173 173
             }
174 174
 
175
-            if(substr($aParams[0], 0, 1) !== '$')
175
+            if (substr($aParams[0], 0, 1) !== '$')
176 176
             {
177 177
                 throw new AnnotationException('The only property of the @di annotation must be a var name');
178 178
             }
179
-            if(substr($aParams[1], 0, 1) === '$')
179
+            if (substr($aParams[1], 0, 1) === '$')
180 180
             {
181 181
                 throw new AnnotationException('The first property of the @di annotation must be a class name');
182 182
             }
@@ -194,7 +194,7 @@  discard block
 block discarded – undo
194 194
     private function checkPropertiesNames(): bool
195 195
     {
196 196
         $nCount = count($this->properties);
197
-        switch($nCount)
197
+        switch ($nCount)
198 198
         {
199 199
         case 0:
200 200
             return true;
@@ -213,26 +213,26 @@  discard block
 block discarded – undo
213 213
      */
214 214
     private function parseProperties()
215 215
     {
216
-        if(!$this->checkPropertiesNames())
216
+        if (!$this->checkPropertiesNames())
217 217
         {
218 218
             throw new AnnotationException('The @di annotation accepts only "attr" or "class" as properties');
219 219
         }
220 220
 
221
-        if(isset($this->properties['attr']))
221
+        if (isset($this->properties['attr']))
222 222
         {
223
-            if($this->xReader->annotationIsOnProperty())
223
+            if ($this->xReader->annotationIsOnProperty())
224 224
             {
225 225
                 throw new AnnotationException('The @di annotation does not allow the "attr" property on class attributes');
226 226
             }
227
-            if(!is_string($this->properties['attr']))
227
+            if (!is_string($this->properties['attr']))
228 228
             {
229 229
                 throw new AnnotationException('The @di annotation requires a property "attr" of type string');
230 230
             }
231 231
             $this->sAttr = $this->properties['attr'];
232 232
         }
233
-        if(isset($this->properties['class']))
233
+        if (isset($this->properties['class']))
234 234
         {
235
-            if(!is_string($this->properties['class']))
235
+            if (!is_string($this->properties['class']))
236 236
             {
237 237
                 throw new AnnotationException('The @di annotation requires a property "class" of type string');
238 238
             }
@@ -250,25 +250,25 @@  discard block
 block discarded – undo
250 250
 
251 251
         // The type in the @di annotations can be set from the values in the @var annotations
252 252
         $aPropTypes = $this->xReader->getPropTypes();
253
-        if($this->sClass === '' && isset($aPropTypes[$this->sAttr]))
253
+        if ($this->sClass === '' && isset($aPropTypes[$this->sAttr]))
254 254
         {
255 255
             $this->sClass = ltrim($aPropTypes[$this->sAttr], '\\');
256 256
         }
257 257
 
258
-        if($this->xReader->annotationIsOnProperty() && $this->xPrevValue !== null)
258
+        if ($this->xReader->annotationIsOnProperty() && $this->xPrevValue !== null)
259 259
         {
260 260
             throw new AnnotationException('Only one @di annotation is allowed on a property');
261 261
         }
262
-        if(!$this->validateAttrName($this->sAttr))
262
+        if (!$this->validateAttrName($this->sAttr))
263 263
         {
264 264
             throw new AnnotationException($this->sAttr . ' is not a valid "attr" value for the @di annotation');
265 265
         }
266
-        if(!$this->validateClassName($this->sClass))
266
+        if (!$this->validateClassName($this->sClass))
267 267
         {
268 268
             throw new AnnotationException($this->sClass . ' is not a valid "class" value for the @di annotation');
269 269
         }
270 270
 
271
-        if(is_array($this->xPrevValue))
271
+        if (is_array($this->xPrevValue))
272 272
         {
273 273
             $this->xPrevValue[$this->sAttr] = $this->sClass; // Append the current value to the array
274 274
             return $this->xPrevValue;
Please login to merge, or discard this patch.
src/AnnotationReader.php 1 patch
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -107,13 +107,13 @@  discard block
 block discarded – undo
107 107
         });
108 108
 
109 109
         $aAttributes = [];
110
-        foreach($aAnnotations as $xAnnotation)
110
+        foreach ($aAnnotations as $xAnnotation)
111 111
         {
112 112
             $xAnnotation->setReader($this);
113 113
             $sName = $xAnnotation->getName();
114 114
             $xAnnotation->setPrevValue($aAttributes[$sName] ?? null);
115 115
             $xValue = $xAnnotation->getValue();
116
-            if($sName === 'protected' && !$xValue)
116
+            if ($sName === 'protected' && !$xValue)
117 117
             {
118 118
                 // Ignore annotation @exclude with value false
119 119
                 continue;
@@ -160,7 +160,7 @@  discard block
 block discarded – undo
160 160
         // Only keep the annotations declared in this package.
161 161
         $aAnnotations = array_filter($aAnnotations, function($xAnnotation) use($sProperty) {
162 162
             // Save the property type
163
-            if(is_a($xAnnotation, VarAnnotation::class))
163
+            if (is_a($xAnnotation, VarAnnotation::class))
164 164
             {
165 165
                 $this->aPropTypes[$sProperty] = $xAnnotation->type;
166 166
             }
@@ -169,7 +169,7 @@  discard block
 block discarded – undo
169 169
         });
170 170
 
171 171
         $aAttributes = [];
172
-        foreach($aAnnotations as $xAnnotation)
172
+        foreach ($aAnnotations as $xAnnotation)
173 173
         {
174 174
             $xAnnotation->setReader($this);
175 175
             $xAnnotation->setAttr($sProperty);
@@ -189,7 +189,7 @@  discard block
 block discarded – undo
189 189
      *
190 190
      * @return array
191 191
      */
192
-    public function getAttributes(ReflectionClass|string $xReflectionClass,
192
+    public function getAttributes(ReflectionClass | string $xReflectionClass,
193 193
         array $aMethods = [], array $aProperties = []): array
194 194
     {
195 195
         $this->aPropTypes = [];
@@ -201,10 +201,10 @@  discard block
 block discarded – undo
201 201
 
202 202
             $aPropAttrs = [];
203 203
             // Properties annotations
204
-            foreach($aProperties as $sProperty)
204
+            foreach ($aProperties as $sProperty)
205 205
             {
206 206
                 $aPropertyAttrs = $this->getPropertyAttrs($sClass, $sProperty);
207
-                foreach($aPropertyAttrs as $sName => $xValue)
207
+                foreach ($aPropertyAttrs as $sName => $xValue)
208 208
                 {
209 209
                     $aPropAttrs[$sName] = array_merge($aPropAttrs[$sName] ?? [], $xValue);
210 210
                 }
@@ -214,13 +214,13 @@  discard block
 block discarded – undo
214 214
             $this->sCurrMemberType = AnnotationManager::MEMBER_CLASS;
215 215
 
216 216
             $aClassAttrs = $this->getClassAttrs($sClass);
217
-            if(isset($aClassAttrs['protected']))
217
+            if (isset($aClassAttrs['protected']))
218 218
             {
219 219
                 return [true, [], []]; // The entire class is not to be exported.
220 220
             }
221 221
 
222 222
             // Merge attributes and class annotations
223
-            foreach($aPropAttrs as $sName => $xValue)
223
+            foreach ($aPropAttrs as $sName => $xValue)
224 224
             {
225 225
                 $aClassAttrs[$sName] = array_merge($aClassAttrs[$sName] ?? [], $xValue);
226 226
             }
@@ -230,21 +230,21 @@  discard block
 block discarded – undo
230 230
 
231 231
             $aAttributes = count($aClassAttrs) > 0 ? ['*' => $aClassAttrs] : [];
232 232
             $aProtected = [];
233
-            foreach($aMethods as $sMethod)
233
+            foreach ($aMethods as $sMethod)
234 234
             {
235 235
                 $aMethodAttrs = $this->getMethodAttrs($sClass, $sMethod);
236
-                if(isset($aMethodAttrs['protected']))
236
+                if (isset($aMethodAttrs['protected']))
237 237
                 {
238 238
                     $aProtected[] = $sMethod; // The method is not to be exported.
239 239
                 }
240
-                elseif(count($aMethodAttrs) > 0)
240
+                elseif (count($aMethodAttrs) > 0)
241 241
                 {
242 242
                     $aAttributes[$sMethod] = $aMethodAttrs;
243 243
                 }
244 244
             }
245 245
             return [false, $aAttributes, $aProtected];
246 246
         }
247
-        catch(AnnotationException $e)
247
+        catch (AnnotationException $e)
248 248
         {
249 249
             throw new SetupException($e->getMessage());
250 250
         }
Please login to merge, or discard this patch.