Passed
Push — main ( e8812c...7db43c )
by Thierry
01:57
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/CallbackAnnotation.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/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 1 patch
Spacing   +19 added lines, -19 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->getMemberType() === AnnotationManager::MEMBER_PROPERTY)
152
+            if ($this->xReader->getMemberType() === AnnotationManager::MEMBER_PROPERTY)
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->getMemberType() === AnnotationManager::MEMBER_PROPERTY)
171
+            if ($this->xReader->getMemberType() === AnnotationManager::MEMBER_PROPERTY)
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
             }
@@ -196,28 +196,28 @@  discard block
 block discarded – undo
196 196
     private function parseProperties()
197 197
     {
198 198
         $nCount = count($this->properties);
199
-        if($nCount > 2 ||
199
+        if ($nCount > 2 ||
200 200
             ($nCount === 2 && !(isset($this->properties['attr']) && isset($this->properties['class']))) ||
201 201
             ($nCount === 1 && !(isset($this->properties['attr']) || isset($this->properties['class']))))
202 202
         {
203 203
             throw new AnnotationException('The @di annotation accepts only "attr" or "class" as properties');
204 204
         }
205 205
 
206
-        if(isset($this->properties['attr']))
206
+        if (isset($this->properties['attr']))
207 207
         {
208
-            if($this->xReader->getMemberType() === AnnotationManager::MEMBER_PROPERTY)
208
+            if ($this->xReader->getMemberType() === AnnotationManager::MEMBER_PROPERTY)
209 209
             {
210 210
                 throw new AnnotationException('The @di annotation does not allow the "attr" property on class attributes');
211 211
             }
212
-            if(!is_string($this->properties['attr']))
212
+            if (!is_string($this->properties['attr']))
213 213
             {
214 214
                 throw new AnnotationException('The @di annotation requires a property "attr" of type string');
215 215
             }
216 216
             $this->sAttr = $this->properties['attr'];
217 217
         }
218
-        if(isset($this->properties['class']))
218
+        if (isset($this->properties['class']))
219 219
         {
220
-            if(!is_string($this->properties['class']))
220
+            if (!is_string($this->properties['class']))
221 221
             {
222 222
                 throw new AnnotationException('The @di annotation requires a property "class" of type string');
223 223
             }
@@ -235,21 +235,21 @@  discard block
 block discarded – undo
235 235
 
236 236
         // The type in the @di annotations can be set from the values in the @var annotations
237 237
         $aPropTypes = $this->xReader->getPropTypes();
238
-        if($this->sClass === '' && isset($aPropTypes[$this->sAttr]))
238
+        if ($this->sClass === '' && isset($aPropTypes[$this->sAttr]))
239 239
         {
240 240
             $this->sClass = ltrim($aPropTypes[$this->sAttr], '\\');
241 241
         }
242 242
 
243
-        if(!$this->validateAttrName($this->sAttr))
243
+        if (!$this->validateAttrName($this->sAttr))
244 244
         {
245 245
             throw new AnnotationException($this->sAttr . ' is not a valid "attr" value for the @di annotation');
246 246
         }
247
-        if(!$this->validateClassName($this->sClass))
247
+        if (!$this->validateClassName($this->sClass))
248 248
         {
249 249
             throw new AnnotationException($this->sClass . ' is not a valid "class" value for the @di annotation');
250 250
         }
251 251
 
252
-        if(is_array($this->xPrevValue))
252
+        if (is_array($this->xPrevValue))
253 253
         {
254 254
             $this->xPrevValue[$this->sAttr] = $this->sClass; // Append the current value to the array
255 255
             return $this->xPrevValue;
Please login to merge, or discard this patch.
src/AnnotationReader.php 2 patches
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -86,12 +86,12 @@  discard block
 block discarded – undo
86 86
      */
87 87
     public static function register(Container $di, bool $bForce = false)
88 88
     {
89
-        if(!$bForce && $di->h(AnnotationReader::class))
89
+        if (!$bForce && $di->h(AnnotationReader::class))
90 90
         {
91 91
             return;
92 92
         }
93 93
         $sCacheDirKey = 'jaxon_annotations_cache_dir';
94
-        if(!$di->h($sCacheDirKey))
94
+        if (!$di->h($sCacheDirKey))
95 95
         {
96 96
             $di->val($sCacheDirKey, sys_get_temp_dir());
97 97
         }
@@ -133,13 +133,13 @@  discard block
 block discarded – undo
133 133
         });
134 134
 
135 135
         $aAttributes = [];
136
-        foreach($aAnnotations as $xAnnotation)
136
+        foreach ($aAnnotations as $xAnnotation)
137 137
         {
138 138
             $xAnnotation->setReader($this);
139 139
             $sName = $xAnnotation->getName();
140 140
             $xAnnotation->setPrevValue($aAttributes[$sName] ?? null);
141 141
             $xValue = $xAnnotation->getValue();
142
-            if($sName !== 'protected' || ($xValue)) // Ignore annotation @exclude with value false
142
+            if ($sName !== 'protected' || ($xValue)) // Ignore annotation @exclude with value false
143 143
             {
144 144
                 $aAttributes[$sName] = $xValue;
145 145
             }
@@ -159,7 +159,7 @@  discard block
 block discarded – undo
159 159
         // Only keep the annotations declared in this package.
160 160
         $aAnnotations = array_filter($aAnnotations, function($xAnnotation) use($sProperty) {
161 161
             // Save the property type
162
-            if(is_a($xAnnotation, VarAnnotation::class))
162
+            if (is_a($xAnnotation, VarAnnotation::class))
163 163
             {
164 164
                 $this->aPropTypes[$sProperty] = $xAnnotation->type;
165 165
             }
@@ -168,11 +168,11 @@  discard block
 block discarded – undo
168 168
         });
169 169
 
170 170
         $nCount = count($aAnnotations);
171
-        if($nCount === 0)
171
+        if ($nCount === 0)
172 172
         {
173 173
             return ['', null];
174 174
         }
175
-        if($nCount > 1)
175
+        if ($nCount > 1)
176 176
         {
177 177
             throw new AnnotationException('Only one @di annotation is allowed on a property');
178 178
         }
@@ -203,10 +203,10 @@  discard block
 block discarded – undo
203 203
             $this->aPropTypes = [];
204 204
             $aPropAttrs = [];
205 205
             // Properties annotations
206
-            foreach($aProperties as $sProperty)
206
+            foreach ($aProperties as $sProperty)
207 207
             {
208 208
                 [$sName, $xValue] = $this->propAnnotations($sProperty, $this->xManager->getPropertyAnnotations($sClass, $sProperty));
209
-                if($xValue !== null)
209
+                if ($xValue !== null)
210 210
                 {
211 211
                     $aPropAttrs[$sName] = array_merge($aPropAttrs[$sName] ?? [], $xValue);
212 212
                 }
@@ -216,13 +216,13 @@  discard block
 block discarded – undo
216 216
             $this->sMemberType = AnnotationManager::MEMBER_CLASS;
217 217
 
218 218
             $aClassAttrs = $this->filterAnnotations($this->xManager->getClassAnnotations($sClass));
219
-            if(isset($aClassAttrs['protected']))
219
+            if (isset($aClassAttrs['protected']))
220 220
             {
221 221
                 return [true, [], []]; // The entire class is not to be exported.
222 222
             }
223 223
 
224 224
             // Merge attributes and class annotations
225
-            foreach($aPropAttrs as $sName => $xValue)
225
+            foreach ($aPropAttrs as $sName => $xValue)
226 226
             {
227 227
                 $aClassAttrs[$sName] = array_merge($aClassAttrs[$sName] ?? [], $xValue);
228 228
             }
@@ -232,21 +232,21 @@  discard block
 block discarded – undo
232 232
 
233 233
             $aAttributes = count($aClassAttrs) > 0 ? ['*' => $aClassAttrs] : [];
234 234
             $aProtected = [];
235
-            foreach($aMethods as $sMethod)
235
+            foreach ($aMethods as $sMethod)
236 236
             {
237 237
                 $aMethodAttrs = $this->filterAnnotations($this->xManager->getMethodAnnotations($sClass, $sMethod));
238
-                if(isset($aMethodAttrs['protected']))
238
+                if (isset($aMethodAttrs['protected']))
239 239
                 {
240 240
                     $aProtected[] = $sMethod; // The method is not to be exported.
241 241
                 }
242
-                elseif(count($aMethodAttrs) > 0)
242
+                elseif (count($aMethodAttrs) > 0)
243 243
                 {
244 244
                     $aAttributes[$sMethod] = $aMethodAttrs;
245 245
                 }
246 246
             }
247 247
             return [false, $aAttributes, $aProtected];
248 248
         }
249
-        catch(AnnotationException $e)
249
+        catch (AnnotationException $e)
250 250
         {
251 251
             throw new SetupException($e->getMessage());
252 252
         }
Please login to merge, or discard this patch.
Braces   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -139,10 +139,12 @@  discard block
 block discarded – undo
139 139
             $sName = $xAnnotation->getName();
140 140
             $xAnnotation->setPrevValue($aAttributes[$sName] ?? null);
141 141
             $xValue = $xAnnotation->getValue();
142
-            if($sName !== 'protected' || ($xValue)) // Ignore annotation @exclude with value false
142
+            if($sName !== 'protected' || ($xValue)) {
143
+                // Ignore annotation @exclude with value false
143 144
             {
144 145
                 $aAttributes[$sName] = $xValue;
145 146
             }
147
+            }
146 148
         }
147 149
         return $aAttributes;
148 150
     }
@@ -238,15 +240,13 @@  discard block
 block discarded – undo
238 240
                 if(isset($aMethodAttrs['protected']))
239 241
                 {
240 242
                     $aProtected[] = $sMethod; // The method is not to be exported.
241
-                }
242
-                elseif(count($aMethodAttrs) > 0)
243
+                } elseif(count($aMethodAttrs) > 0)
243 244
                 {
244 245
                     $aAttributes[$sMethod] = $aMethodAttrs;
245 246
                 }
246 247
             }
247 248
             return [false, $aAttributes, $aProtected];
248
-        }
249
-        catch(AnnotationException $e)
249
+        } catch(AnnotationException $e)
250 250
         {
251 251
             throw new SetupException($e->getMessage());
252 252
         }
Please login to merge, or discard this patch.