Passed
Push — main ( e8812c...7db43c )
by Thierry
01:57
created
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.