Completed
Push — master ( 256029...39e557 )
by personal
02:46
created
src/Hal/Component/OOP/Extractor/Extractor.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -48,7 +48,7 @@  discard block
 block discarded – undo
48 48
 
49 49
         $this->tokenizer = $tokenizer;
50 50
         $this->searcher = new Searcher();
51
-        $this->result= new Result;
51
+        $this->result = new Result;
52 52
 
53 53
         $this->extractors = (object) array(
54 54
             'class' => new ClassExtractor($this->searcher)
@@ -80,9 +80,9 @@  discard block
 block discarded – undo
80 80
         $endAnonymous = 0;
81 81
         $mainContextClass = null; // class containing a anonymous class
82 82
 
83
-        for($n = 0; $n < $len; $n++) {
83
+        for ($n = 0; $n < $len; $n++) {
84 84
 
85
-            if($mainContextClass && $n > $endAnonymous) {
85
+            if ($mainContextClass && $n > $endAnonymous) {
86 86
                 // anonymous class is finished. We back to parent class
87 87
                 // methods will be added to the main class now
88 88
                 $class = $mainContextClass;
@@ -91,7 +91,7 @@  discard block
 block discarded – undo
91 91
 
92 92
             $token = $tokens[$n];
93 93
 
94
-            switch($token->getType()) {
94
+            switch ($token->getType()) {
95 95
 
96 96
                 case T_USE:
97 97
                     $alias = $this->extractors->alias->extract($n, $tokens);
@@ -136,14 +136,14 @@  discard block
 block discarded – undo
136 136
                     $result->pushClass($c);
137 137
 
138 138
                     // PHP 7 and inner classes
139
-                    if($c instanceof ReflectedAnonymousClass) {
139
+                    if ($c instanceof ReflectedAnonymousClass) {
140 140
                         // avoid to consider anonymous class as main class
141 141
                         $p = $n;
142 142
                         $endAnonymous = $this->searcher->getPositionOfClosingBrace($p, $tokens);
143 143
                         $mainContextClass = $class;
144 144
 
145 145
                         // add anonymous class in method
146
-                        if($method) {
146
+                        if ($method) {
147 147
                             $method->pushAnonymousClass($c);
148 148
                         }
149 149
                     }
@@ -151,10 +151,10 @@  discard block
 block discarded – undo
151 151
                     break;
152 152
 
153 153
                 case T_FUNCTION:
154
-                    if($class) {
154
+                    if ($class) {
155 155
                         // avoid closure
156 156
                         $next = $tokens[$n + 1];
157
-                        if(T_WHITESPACE != $next->getType()) {
157
+                        if (T_WHITESPACE != $next->getType()) {
158 158
                             continue;
159 159
                         }
160 160
                         $method = $this->extractors->method->extract($n, $tokens, $class);
Please login to merge, or discard this patch.
src/Hal/Component/OOP/Extractor/MethodExtractor.php 1 patch
Spacing   +32 added lines, -32 removed lines patch added patch discarded remove patch
@@ -55,7 +55,7 @@  discard block
 block discarded – undo
55 55
         $start = $n;
56 56
 
57 57
         $declaration = $this->searcher->getUnder(array(')'), $n, $tokens);
58
-        if(!preg_match('!function\s+(.*)\(\s*(.*)!is', $declaration, $matches)) {
58
+        if (!preg_match('!function\s+(.*)\(\s*(.*)!is', $declaration, $matches)) {
59 59
             throw new \Exception(sprintf("Closure detected instead of method\nDetails:\n%s", $declaration));
60 60
         }
61 61
         list(, $name, $args) = $matches;
@@ -68,21 +68,21 @@  discard block
 block discarded – undo
68 68
         $this->extractState($method, $p = $start, $tokens); // please keep "p = start"
69 69
 
70 70
         $arguments = preg_split('!\s*,\s*!m', $args);
71
-        foreach($arguments as $argDecl) {
71
+        foreach ($arguments as $argDecl) {
72 72
 
73
-            if(0 == strlen($argDecl)) {
73
+            if (0 == strlen($argDecl)) {
74 74
                 continue;
75 75
             }
76 76
 
77 77
             $elems = preg_split('!([\s=]+)!', $argDecl);
78 78
             $isRequired = 2 == sizeof($elems, COUNT_NORMAL);
79 79
 
80
-            if(sizeof($elems, COUNT_NORMAL) == 1) {
80
+            if (sizeof($elems, COUNT_NORMAL) == 1) {
81 81
                 list($name, $type) = array_pad($elems, 2, null);
82 82
             } else {
83
-                if('$' == $elems[0][0]) {
83
+                if ('$' == $elems[0][0]) {
84 84
                     $name = $elems[0];
85
-                    $type  = null;
85
+                    $type = null;
86 86
                     $isRequired = false;
87 87
                 } else {
88 88
                     list($type, $name) = array_pad($elems, 2, null);
@@ -96,9 +96,9 @@  discard block
 block discarded – undo
96 96
 
97 97
 
98 98
         // does method has body ? (example: interface ; abstract classes)
99
-        $p = $n  + 1;
99
+        $p = $n + 1;
100 100
         $underComma = trim($this->searcher->getUnder(array(';'), $p, $tokens));
101
-        if(strlen($underComma) > 0) {
101
+        if (strlen($underComma) > 0) {
102 102
             //
103 103
             // Body
104 104
             $this->extractContent($method, $n, $tokens);
@@ -108,7 +108,7 @@  discard block
 block discarded – undo
108 108
 
109 109
             // Tokens
110 110
             $end = $this->searcher->getPositionOfClosingBrace($n, $tokens);
111
-            if($end > 0) {
111
+            if ($end > 0) {
112 112
                 $method->setTokens($tokens->extract($n, $end));
113 113
             }
114 114
         } else {
@@ -138,7 +138,7 @@  discard block
 block discarded – undo
138 138
      * @return $this
139 139
      */
140 140
     public function extractVisibility(ReflectedMethod $method, $n, TokenCollection $tokens) {
141
-        switch(true) {
141
+        switch (true) {
142 142
             case $this->searcher->isPrecededBy(T_PRIVATE, $n, $tokens, 4):
143 143
                 $visibility = ReflectedMethod::VISIBILITY_PRIVATE;
144 144
                 break;
@@ -163,7 +163,7 @@  discard block
 block discarded – undo
163 163
      * @return $this
164 164
      */
165 165
     public function extractState(ReflectedMethod $method, $n, TokenCollection $tokens) {
166
-        if($this->searcher->isPrecededBy(T_STATIC, $n, $tokens, 4)) {
166
+        if ($this->searcher->isPrecededBy(T_STATIC, $n, $tokens, 4)) {
167 167
             $method->setState(ReflectedMethod::STATE_STATIC);
168 168
         }
169 169
         return $this;
@@ -179,7 +179,7 @@  discard block
 block discarded – undo
179 179
      */
180 180
     private function extractContent(ReflectedMethod $method, $n, TokenCollection $tokens) {
181 181
         $end = $this->searcher->getPositionOfClosingBrace($n, $tokens);
182
-        if($end > 0) {
182
+        if ($end > 0) {
183 183
             $collection = $tokens->extract($n, $end);
184 184
             $method->setContent($collection->asString());
185 185
         }
@@ -202,13 +202,13 @@  discard block
 block discarded – undo
202 202
         $extractor = new CallExtractor($this->searcher, $currentClass);
203 203
         $start = $n;
204 204
         $len = sizeof($tokens, COUNT_NORMAL);
205
-        for($i = $start; $i < $len; $i++) {
205
+        for ($i = $start; $i < $len; $i++) {
206 206
             $token = $tokens[$i];
207
-            switch($token->getType()) {
207
+            switch ($token->getType()) {
208 208
                 case T_PAAMAYIM_NEKUDOTAYIM:
209 209
                 case T_NEW:
210 210
                     $call = $extractor->extract($i, $tokens, $currentClass);
211
-                    if($call !== 'class') { // anonymous class
211
+                    if ($call !== 'class') { // anonymous class
212 212
                         $method->pushDependency($call);
213 213
                         $method->pushInstanciedClass($call);
214 214
                     }
@@ -219,9 +219,9 @@  discard block
 block discarded – undo
219 219
         //
220 220
         // Parameters in Method API
221 221
         $resolver = new TypeResolver();
222
-        foreach($method->getArguments() as $argument) {
222
+        foreach ($method->getArguments() as $argument) {
223 223
             $name = $argument->getType();
224
-            if(strlen($name) > 0 && !$resolver->isNative($name)) {
224
+            if (strlen($name) > 0 && !$resolver->isNative($name)) {
225 225
                 $method->pushDependency($name);
226 226
             }
227 227
         }
@@ -240,10 +240,10 @@  discard block
 block discarded – undo
240 240
     private function extractCalls(ReflectedMethod $method, $n, TokenCollection $tokens) {
241 241
 
242 242
         // $this->foo(), $c->foo()
243
-        if(preg_match_all('!(\$[\w]*)\-\>(\w*?)\(!', $method->getContent(), $matches, PREG_SET_ORDER)) {
244
-            foreach($matches as $m) {
243
+        if (preg_match_all('!(\$[\w]*)\-\>(\w*?)\(!', $method->getContent(), $matches, PREG_SET_ORDER)) {
244
+            foreach ($matches as $m) {
245 245
                 $function = $m[2];
246
-                if('$this' == $m[1]) {
246
+                if ('$this' == $m[1]) {
247 247
                     $method->pushInternalCall($function);
248 248
                 } else {
249 249
                     $method->pushExternalCall($m[1], $function);
@@ -251,8 +251,8 @@  discard block
 block discarded – undo
251 251
             }
252 252
         }
253 253
         // (new X)->foo()
254
-        if(preg_match_all('!\(new (\w+?).*?\)\->(\w+)\(!', $method->getContent(), $matches, PREG_SET_ORDER)) {
255
-            foreach($matches as $m) {
254
+        if (preg_match_all('!\(new (\w+?).*?\)\->(\w+)\(!', $method->getContent(), $matches, PREG_SET_ORDER)) {
255
+            foreach ($matches as $m) {
256 256
                 $method->pushExternalCall($m[1], $m[2]);
257 257
             }
258 258
         }
@@ -272,9 +272,9 @@  discard block
 block discarded – undo
272 272
         // we cannot use specific token. The ":" delimiter is a T_STRING token
273 273
         // in regex we match ":" followed by any character except another ":"
274 274
         $following = $this->searcher->getUnder(array('{', ';'), $n, $tokens);
275
-        if(preg_match('@(?<!:):\s*(\w+)@', $following, $matches)) {
275
+        if (preg_match('@(?<!:):\s*(\w+)@', $following, $matches)) {
276 276
             $type = trim($matches[1]);
277
-            if(empty($type)) {
277
+            if (empty($type)) {
278 278
                 return $this;
279 279
             }
280 280
             $return = new ReflectedReturn($type, ReflectedReturn::VALUE_UNKNOW, ReflectedReturn::STRICT_TYPE_HINT);
@@ -283,8 +283,8 @@  discard block
 block discarded – undo
283 283
         }
284 284
 
285 285
         // array of available values based on code
286
-        if(preg_match_all('!([\s;]return\s|^return\s+)(.*?);!', $method->getContent(), $matches)) {
287
-            foreach($matches[2] as $m) {
286
+        if (preg_match_all('!([\s;]return\s|^return\s+)(.*?);!', $method->getContent(), $matches)) {
287
+            foreach ($matches[2] as $m) {
288 288
                 $value = trim($m, ";\t\n\r\0\x0B");
289 289
                 $return = new ReflectedReturn($resolver->resolve($m), $value, ReflectedReturn::ESTIMATED_TYPE_HINT);
290 290
                 $method->pushReturn($return);
@@ -302,21 +302,21 @@  discard block
 block discarded – undo
302 302
     private function extractUsage(ReflectedMethod $method) {
303 303
         $tokens = $method->getTokens();
304 304
         $codes = $values = array();
305
-        foreach($tokens as $token) {
306
-            if(in_array($token->getType(), array(T_WHITESPACE, T_BOOL_CAST, T_INT_CAST, T_STRING_CAST, T_DOUBLE_CAST, T_OBJECT_CAST))) {
305
+        foreach ($tokens as $token) {
306
+            if (in_array($token->getType(), array(T_WHITESPACE, T_BOOL_CAST, T_INT_CAST, T_STRING_CAST, T_DOUBLE_CAST, T_OBJECT_CAST))) {
307 307
                 continue;
308 308
             }
309 309
             array_push($codes, $token->getType());
310 310
             array_push($values, $token->getValue());
311 311
         }
312
-        switch(true) {
313
-            case preg_match('!^(get)|(is)|(has).*!',$method->getName()) && $codes == array(T_RETURN, T_VARIABLE, T_OBJECT_OPERATOR, T_STRING, T_STRING):
312
+        switch (true) {
313
+            case preg_match('!^(get)|(is)|(has).*!', $method->getName()) && $codes == array(T_RETURN, T_VARIABLE, T_OBJECT_OPERATOR, T_STRING, T_STRING):
314 314
                 $method->setUsage(MethodUsage::USAGE_GETTER);
315 315
                 break;
316 316
             // basic setter
317
-            case preg_match('!^set.*!',$method->getName()) && $codes == array(T_VARIABLE, T_OBJECT_OPERATOR,T_STRING,T_STRING, T_VARIABLE, T_STRING) && $values[3] == '=':
317
+            case preg_match('!^set.*!', $method->getName()) && $codes == array(T_VARIABLE, T_OBJECT_OPERATOR, T_STRING, T_STRING, T_VARIABLE, T_STRING) && $values[3] == '=':
318 318
             // fluent setter
319
-            case preg_match('!^set.*!',$method->getName()) && $codes == array(T_VARIABLE, T_OBJECT_OPERATOR,T_STRING,T_STRING, T_VARIABLE, T_STRING, T_RETURN, T_VARIABLE, T_STRING)
319
+            case preg_match('!^set.*!', $method->getName()) && $codes == array(T_VARIABLE, T_OBJECT_OPERATOR, T_STRING, T_STRING, T_VARIABLE, T_STRING, T_RETURN, T_VARIABLE, T_STRING)
320 320
                 && $values[3] == '=' && $values[7] == '$this':
321 321
                 $method->setUsage(MethodUsage::USAGE_SETTER);
322 322
                 break;
Please login to merge, or discard this patch.
src/Hal/Component/OOP/Extractor/Result.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -31,7 +31,7 @@  discard block
 block discarded – undo
31 31
     public function asArray() {
32 32
 
33 33
         $nom = 0;
34
-        foreach($this->getClasses() as $class) {
34
+        foreach ($this->getClasses() as $class) {
35 35
             $nom += sizeof($class->getMethods(), COUNT_NORMAL);
36 36
         }
37 37
 
@@ -71,8 +71,8 @@  discard block
 block discarded – undo
71 71
      */
72 72
     public function getAbstractClasses() {
73 73
         $result = array();
74
-        foreach($this->getClasses() as $class) {
75
-            if($class->isAbstract() ||$class instanceof ReflectedInterface) {
74
+        foreach ($this->getClasses() as $class) {
75
+            if ($class->isAbstract() || $class instanceof ReflectedInterface) {
76 76
                 array_push($result, $class);
77 77
             }
78 78
         }
@@ -86,8 +86,8 @@  discard block
 block discarded – undo
86 86
      */
87 87
     public function getAnonymousClasses() {
88 88
         $result = array();
89
-        foreach($this->getClasses() as $class) {
90
-            if($class instanceof ReflectedClass\ReflectedAnonymousClass) {
89
+        foreach ($this->getClasses() as $class) {
90
+            if ($class instanceof ReflectedClass\ReflectedAnonymousClass) {
91 91
                 array_push($result, $class);
92 92
             }
93 93
         }
@@ -101,8 +101,8 @@  discard block
 block discarded – undo
101 101
      */
102 102
     public function getInterfaces() {
103 103
         $result = array();
104
-        foreach($this->getClasses() as $class) {
105
-            if($class instanceof ReflectedInterface) {
104
+        foreach ($this->getClasses() as $class) {
105
+            if ($class instanceof ReflectedInterface) {
106 106
                 array_push($result, $class);
107 107
             }
108 108
         }
@@ -116,8 +116,8 @@  discard block
 block discarded – undo
116 116
      */
117 117
     public function getConcreteClasses() {
118 118
         $result = array();
119
-        foreach($this->getClasses() as $class) {
120
-            if(!$class->isAbstract() &&!$class instanceof ReflectedInterface  && !$class instanceof ReflectedClass\ReflectedAnonymousClass) {
119
+        foreach ($this->getClasses() as $class) {
120
+            if (!$class->isAbstract() && !$class instanceof ReflectedInterface && !$class instanceof ReflectedClass\ReflectedAnonymousClass) {
121 121
                 array_push($result, $class);
122 122
             }
123 123
         }
Please login to merge, or discard this patch.
src/Hal/Component/OOP/Extractor/Searcher.php 1 patch
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -29,9 +29,9 @@  discard block
 block discarded – undo
29 29
     public function getUnder(array $delimiters, &$n, TokenCollection $tokens) {
30 30
         $end = sizeof($tokens, COUNT_NORMAL);
31 31
         $value = '';
32
-        while($n < $end) {
32
+        while ($n < $end) {
33 33
             $token = $tokens[$n];
34
-            if(in_array($token->getValue(), $delimiters)) {
34
+            if (in_array($token->getValue(), $delimiters)) {
35 35
                 return $value;
36 36
             }
37 37
             $value .= $token->getValue();
@@ -49,8 +49,8 @@  discard block
 block discarded – undo
49 49
      */
50 50
     public function getPrevious(&$n, TokenCollection $tokens) {
51 51
         $p = $n - 1;
52
-        for($i = $p ; $i > 0; $i--) {
53
-            if(T_WHITESPACE !== $tokens[$i]->getType()) {
52
+        for ($i = $p; $i > 0; $i--) {
53
+            if (T_WHITESPACE !== $tokens[$i]->getType()) {
54 54
                 return $tokens[$i];
55 55
             }
56 56
         }
@@ -81,19 +81,19 @@  discard block
 block discarded – undo
81 81
         $openBrace = 0;
82 82
         $start = null;
83 83
         $len = sizeof($tokens);
84
-        for($i = $n; $i < $len; $i++) {
84
+        for ($i = $n; $i < $len; $i++) {
85 85
             $token = $tokens[$i];
86
-            if(T_STRING == $token->getType()) {
87
-                switch($token->getValue()) {
86
+            if (T_STRING == $token->getType()) {
87
+                switch ($token->getValue()) {
88 88
                     case '{':
89 89
                         $openBrace++;
90
-                        if(is_null($start)) {
90
+                        if (is_null($start)) {
91 91
                             $start = $n = $i + 1;
92 92
                         }
93 93
                         break;
94 94
                     case '}':
95 95
                         $openBrace--;
96
-                        if($openBrace <= 0) {
96
+                        if ($openBrace <= 0) {
97 97
                             return $i;
98 98
                         }
99 99
                         break;
@@ -105,7 +105,7 @@  discard block
 block discarded – undo
105 105
 
106 106
     public function getExtendPosition(TokenCollection $tokens, $start)
107 107
     {
108
-        for($i = $start; $i > 0; $i--) {
108
+        for ($i = $start; $i > 0; $i--) {
109 109
             $token = $tokens[$i];
110 110
             if ($token->getValue() === 'extends') {
111 111
                 return $i;
@@ -116,7 +116,7 @@  discard block
 block discarded – undo
116 116
     public function getClassNamePosition(TokenCollection $tokens)
117 117
     {
118 118
         $len = sizeof($tokens);
119
-        for($i = 0; $i < $len; $i++) {
119
+        for ($i = 0; $i < $len; $i++) {
120 120
             $token = $tokens[$i];
121 121
             if ($token->getValue() === 'class') {
122 122
                 return $i;
@@ -126,8 +126,8 @@  discard block
 block discarded – undo
126 126
     }
127 127
 
128 128
     public function getPositionOfPrevious($tokenType, $n, TokenCollection $tokens) {
129
-        for($i = $n; $i > 0; $i--) {
130
-            if($tokenType == $tokens->get($i)->getType()) {
129
+        for ($i = $n; $i > 0; $i--) {
130
+            if ($tokenType == $tokens->get($i)->getType()) {
131 131
                 return $i;
132 132
             }
133 133
         }
@@ -136,8 +136,8 @@  discard block
 block discarded – undo
136 136
 
137 137
     public function getPositionOfNext($tokenType, $n, TokenCollection $tokens) {
138 138
         $len = sizeof($tokens);
139
-        for($i = $n; $i < $len; $i++) {
140
-            if($tokenType == $tokens->get($i)->getType()) {
139
+        for ($i = $n; $i < $len; $i++) {
140
+            if ($tokenType == $tokens->get($i)->getType()) {
141 141
                 return $i;
142 142
             }
143 143
         }
Please login to merge, or discard this patch.
src/Hal/Component/OOP/Reflected/ReflectedClass.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -136,11 +136,11 @@  discard block
 block discarded – undo
136 136
     public function getDependencies()
137 137
     {
138 138
         $dependencies = array();
139
-        foreach($this->getMethods() as $method) {
139
+        foreach ($this->getMethods() as $method) {
140 140
             $dependencies = array_merge($dependencies, $method->getDependencies());
141 141
         }
142
-        foreach($dependencies as &$name) {
143
-            if(in_array($name, array('self', 'static'))) {
142
+        foreach ($dependencies as &$name) {
143
+            if (in_array($name, array('self', 'static'))) {
144 144
                 $name = $this->getFullname();
145 145
             }
146 146
             $name = $this->nameResolver->resolve($name, $this->namespace);
@@ -207,7 +207,7 @@  discard block
 block discarded – undo
207 207
     public function getInterfaces()
208 208
     {
209 209
         $resolvedInterfaces = array();
210
-        foreach($this->interfaces as $interface) {
210
+        foreach ($this->interfaces as $interface) {
211 211
             array_push($resolvedInterfaces, $this->nameResolver->resolve($interface, $this->namespace));
212 212
         }
213 213
         return $resolvedInterfaces;
@@ -230,7 +230,7 @@  discard block
 block discarded – undo
230 230
      */
231 231
     public function getAnonymousClasses() {
232 232
         $result = array();
233
-        foreach($this->methods as $method) {
233
+        foreach ($this->methods as $method) {
234 234
             $result = array_merge($result, $method->getAnonymousClasses());
235 235
         }
236 236
         return $result;
Please login to merge, or discard this patch.
src/Hal/Component/OOP/Reflected/ReflectedMethod.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -189,10 +189,10 @@  discard block
 block discarded – undo
189 189
         // on read : compare with aliases. We cannot make it in pushDependency() => aliases aren't yet known
190 190
         $result = array();
191 191
         $resolver = new TypeResolver();
192
-        foreach($this->returns as $return) {
192
+        foreach ($this->returns as $return) {
193 193
             $type = $this->nameResolver->resolve($return->getType(), null);
194 194
 
195
-            if("\\" !== $type[0] &&!$resolver->isNative($type)) {
195
+            if ("\\" !== $type[0] && !$resolver->isNative($type)) {
196 196
                 $type = $this->namespace.'\\'.$type;
197 197
             }
198 198
 
@@ -233,21 +233,21 @@  discard block
 block discarded – undo
233 233
     {
234 234
         // on read : compare with aliases. We cannot make it in pushDependency() => aliases aren't yet known
235 235
         $dependencies = array();
236
-        foreach($this->dependencies as $name) {
236
+        foreach ($this->dependencies as $name) {
237 237
             array_push($dependencies, $this->nameResolver->resolve($name, null));
238 238
         }
239 239
 
240 240
         // returned values
241 241
         $resolver = new TypeResolver();
242
-        foreach($this->returns as $return) {
242
+        foreach ($this->returns as $return) {
243 243
             $name = $return->getType();
244
-            if(!$resolver->isNative($name)) {
244
+            if (!$resolver->isNative($name)) {
245 245
                 array_push($dependencies, $this->nameResolver->resolve($name, null));
246 246
             }
247 247
         }
248 248
 
249 249
         // anonymous classes in method (inner class)
250
-        foreach($this->anonymousClasses as $c) {
250
+        foreach ($this->anonymousClasses as $c) {
251 251
             array_push($dependencies, $c->getParent());
252 252
             $dependencies = array_merge($dependencies, $c->getDependencies());
253 253
         }
@@ -379,7 +379,7 @@  discard block
 block discarded – undo
379 379
     public function getInstanciedClasses()
380 380
     {
381 381
         $classes = array();
382
-        foreach($this->instanciedClasses as $name) {
382
+        foreach ($this->instanciedClasses as $name) {
383 383
             array_push($classes, $this->nameResolver->resolve($name, null));
384 384
         }
385 385
         return $classes;
Please login to merge, or discard this patch.
src/Hal/Component/OOP/Resolver/NameResolver.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -43,7 +43,7 @@
 block discarded – undo
43 43
         }
44 44
 
45 45
         // anonymous class
46
-        if('class@anonymous' == $name ) {
46
+        if ('class@anonymous' == $name) {
47 47
             return $name;
48 48
         }
49 49
 
Please login to merge, or discard this patch.
src/Hal/Component/OOP/Resolver/TypeResolver.php 1 patch
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -41,47 +41,47 @@
 block discarded – undo
41 41
         $string = $cased = trim($string, ";\t\n\r\0\x0B");
42 42
         $string = strtolower($string);
43 43
 
44
-        if(strlen($string) == 0) {
44
+        if (strlen($string) == 0) {
45 45
             return self::TYPE_VOID;
46 46
         }
47 47
 
48
-        if(preg_match('!^\d+$!', $string)) {
48
+        if (preg_match('!^\d+$!', $string)) {
49 49
             return self::TYPE_INTEGER;
50 50
         }
51 51
 
52
-        if(preg_match('!^\d+\.\d+$!', $string)) {
52
+        if (preg_match('!^\d+\.\d+$!', $string)) {
53 53
             return self::TYPE_FLOAT;
54 54
         }
55 55
 
56
-        if('null' == $string) {
56
+        if ('null' == $string) {
57 57
             return self::TYPE_NULL;
58 58
         }
59 59
 
60
-        if(preg_match('!(^\[|^array\()!', $string)) {
60
+        if (preg_match('!(^\[|^array\()!', $string)) {
61 61
             return self::TYPE_ARRAY;
62 62
         }
63 63
 
64
-        if(preg_match('!^new\s+class\s+!', $string, $matches)) {
64
+        if (preg_match('!^new\s+class\s+!', $string, $matches)) {
65 65
             return self::TYPE_ANONYMOUS_CLASS;
66 66
         }
67 67
 
68
-        if(preg_match('!^(new\s+)(.*?)(\s*[\(;].*|$)!', $cased, $matches)) {
68
+        if (preg_match('!^(new\s+)(.*?)(\s*[\(;].*|$)!', $cased, $matches)) {
69 69
             return $matches[2];
70 70
         }
71 71
 
72
-        if(preg_match('!^\$this$!', $string, $matches)) {
72
+        if (preg_match('!^\$this$!', $string, $matches)) {
73 73
             return self::TYPE_FLUENT_INTERFACE;
74 74
         }
75 75
 
76
-        if(preg_match('!^(true|false)!', $string, $matches)) {
76
+        if (preg_match('!^(true|false)!', $string, $matches)) {
77 77
             return self::TYPE_BOOL;
78 78
         }
79 79
 
80
-        if(preg_match('!^function!', $string, $matches)) {
80
+        if (preg_match('!^function!', $string, $matches)) {
81 81
             return self::TYPE_CALLABLE;
82 82
         }
83 83
 
84
-        if(preg_match('!^["\']!', $string, $matches)) {
84
+        if (preg_match('!^["\']!', $string, $matches)) {
85 85
             return self::TYPE_STRING;
86 86
         }
87 87
 
Please login to merge, or discard this patch.
src/Hal/Component/Phar/Updater.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -46,7 +46,7 @@  discard block
 block discarded – undo
46 46
      */
47 47
     public function updates($version = self::LATEST) {
48 48
         $tag = $version;
49
-        if(self::LATEST == $version) {
49
+        if (self::LATEST == $version) {
50 50
             $tag = 'master';
51 51
         }
52 52
 
@@ -59,11 +59,11 @@  discard block
 block discarded – undo
59 59
         }
60 60
 
61 61
         $currentPharLocation = \Phar::running(false);
62
-        if(!file_exists($currentPharLocation) ||strlen($currentPharLocation) == 0) {
62
+        if (!file_exists($currentPharLocation) || strlen($currentPharLocation) == 0) {
63 63
             throw new \LogicException("You're not currently using Phar. If you have installed PhpMetrics with Composer, please updates it using Composer.");
64 64
         }
65 65
 
66
-        if(!is_writable($currentPharLocation)) {
66
+        if (!is_writable($currentPharLocation)) {
67 67
             throw new \RuntimeException(sprintf('%s is not writable', $currentPharLocation));
68 68
         }
69 69
 
@@ -74,7 +74,7 @@  discard block
 block discarded – undo
74 74
         $content = file_get_contents($url, false, $ctx);
75 75
 
76 76
         // replacing file
77
-        if(!$content) {
77
+        if (!$content) {
78 78
             throw new \RuntimeException('Download failed');
79 79
         }
80 80
 
@@ -82,13 +82,13 @@  discard block
 block discarded – undo
82 82
         $tmpfile = tempnam(sys_get_temp_dir(), 'phar');
83 83
         file_put_contents($tmpfile, $content);
84 84
         $output = shell_exec(sprintf('"%s" "%s" --version', PHP_BINARY, $tmpfile));
85
-        if(!preg_match('!(v\d+\.\d+\.\d+)!', $output, $matches)) {
85
+        if (!preg_match('!(v\d+\.\d+\.\d+)!', $output, $matches)) {
86 86
             throw new \RuntimeException('Phar is corrupted. Please retry');
87 87
         }
88 88
 
89 89
         // compare versions
90 90
         $downloadedVersion = $matches[1];
91
-        if(self::LATEST !==$version &&$downloadedVersion !== $version) {
91
+        if (self::LATEST !== $version && $downloadedVersion !== $version) {
92 92
             throw new \RuntimeException('Incorrect version. Please retry');
93 93
         }
94 94
 
@@ -112,12 +112,12 @@  discard block
 block discarded – undo
112 112
         static $filesize = null;
113 113
         static $progress = null;
114 114
 
115
-        switch($notification_code) {
115
+        switch ($notification_code) {
116 116
             case STREAM_NOTIFY_AUTH_REQUIRED:
117 117
             case STREAM_NOTIFY_AUTH_RESULT:
118 118
                 break;
119 119
             case STREAM_NOTIFY_CONNECT:
120
-                if(!$progress) {
120
+                if (!$progress) {
121 121
                     $this->output->writeln(sprintf("<info>Downloading</info>"));
122 122
                 }
123 123
                 break;
@@ -131,7 +131,7 @@  discard block
 block discarded – undo
131 131
             case STREAM_NOTIFY_PROGRESS:
132 132
                 if ($bytes_transferred > 0) {
133 133
                     if (!isset($filesize)) {
134
-                        $this->output->writeln(sprintf("<info>Unknown file size.. %2d kb done..</info>", $bytes_transferred/1024));
134
+                        $this->output->writeln(sprintf("<info>Unknown file size.. %2d kb done..</info>", $bytes_transferred / 1024));
135 135
                     } else {
136 136
                         $progress->setProgress($bytes_transferred / 100);
137 137
                     }
@@ -140,7 +140,7 @@  discard block
 block discarded – undo
140 140
 
141 141
             case STREAM_NOTIFY_COMPLETED:
142 142
             case STREAM_NOTIFY_FAILURE:
143
-                if($progress) {
143
+                if ($progress) {
144 144
                     $progress->clear();
145 145
                     $progress->finish();
146 146
                 }
Please login to merge, or discard this patch.