@@ -49,7 +49,7 @@ |
||
49 | 49 | { |
50 | 50 | // is PHP7 ? |
51 | 51 | $previous = $tokens->get($n - 2); |
52 | - if($previous && T_NEW === $previous->getType()) { |
|
52 | + if ($previous && T_NEW === $previous->getType()) { |
|
53 | 53 | // anonymous class |
54 | 54 | $class = new ReflectedAnonymousClass($this->namespace, 'class@anonymous'); |
55 | 55 | return $class; |
@@ -31,7 +31,7 @@ |
||
31 | 31 | * @return $this |
32 | 32 | */ |
33 | 33 | public function push($filename, Result $result) { |
34 | - $this->classes[$filename] = $result;; |
|
34 | + $this->classes[$filename] = $result; ; |
|
35 | 35 | return $this; |
36 | 36 | } |
37 | 37 |
@@ -48,7 +48,7 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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); |
@@ -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 | } |
@@ -29,9 +29,9 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 | } |
@@ -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; |
@@ -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 | } |