@@ -31,7 +31,7 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 | } |
@@ -136,11 +136,11 @@ discard block |
||
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 |
||
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 |
||
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; |
@@ -189,10 +189,10 @@ discard block |
||
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 |
||
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 |
||
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; |
@@ -163,7 +163,7 @@ discard block |
||
163 | 163 | } |
164 | 164 | |
165 | 165 | /** |
166 | - * @return TokenCollection |
|
166 | + * @return \Hal\Component\Token\TokenCollection |
|
167 | 167 | */ |
168 | 168 | public function getTokens() |
169 | 169 | { |
@@ -365,7 +365,7 @@ discard block |
||
365 | 365 | } |
366 | 366 | |
367 | 367 | /** |
368 | - * @param $class |
|
368 | + * @param string|null $class |
|
369 | 369 | * @return $this |
370 | 370 | */ |
371 | 371 | public function pushInstanciedClass($class) { |
@@ -386,7 +386,7 @@ discard block |
||
386 | 386 | } |
387 | 387 | |
388 | 388 | /** |
389 | - * @param $call |
|
389 | + * @param string $call |
|
390 | 390 | * @return $this |
391 | 391 | */ |
392 | 392 | public function pushInternalCall($call) |
@@ -404,7 +404,7 @@ discard block |
||
404 | 404 | } |
405 | 405 | |
406 | 406 | /** |
407 | - * @param $call |
|
407 | + * @param string $call |
|
408 | 408 | * @return $this |
409 | 409 | */ |
410 | 410 | public function pushExternalCall($call) |
@@ -43,7 +43,7 @@ |
||
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 |
@@ -41,47 +41,47 @@ |
||
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 |
@@ -46,7 +46,7 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 | } |
@@ -46,7 +46,7 @@ |
||
46 | 46 | */ |
47 | 47 | public function asArray() { |
48 | 48 | $array = array(); |
49 | - foreach($this->results as $result) { |
|
49 | + foreach ($this->results as $result) { |
|
50 | 50 | array_push($array, $result->asArray()); |
51 | 51 | } |
52 | 52 | return $array; |
@@ -16,7 +16,7 @@ |
||
16 | 16 | * |
17 | 17 | * @author Jean-François Lépine <https://twitter.com/Halleck45> |
18 | 18 | */ |
19 | -interface ScoringInterface { |
|
19 | +interface ScoringInterface { |
|
20 | 20 | |
21 | 21 | /** |
22 | 22 | * Calculates score |
@@ -35,7 +35,7 @@ discard block |
||
35 | 35 | */ |
36 | 36 | public function __construct($data) |
37 | 37 | { |
38 | - if(!is_array($data)) { |
|
38 | + if (!is_array($data)) { |
|
39 | 39 | $this->type = T_STRING; |
40 | 40 | $this->value = $data; |
41 | 41 | } else { |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | } |
45 | 45 | |
46 | 46 | // reduce multiple spaces to one |
47 | - if(T_WHITESPACE === $this->type && preg_match('/^\s*$/', $this->value)) { |
|
47 | + if (T_WHITESPACE === $this->type && preg_match('/^\s*$/', $this->value)) { |
|
48 | 48 | $this->value = ' '; |
49 | 49 | } |
50 | 50 | } |