@@ -31,7 +31,7 @@ |
||
31 | 31 | $php = 'php'; |
32 | 32 | |
33 | 33 | if (0 >= version_compare('5.4.0', PHP_VERSION)) { |
34 | - $php = PHP_BINARY; |
|
34 | + $php = PHP_BINARY; |
|
35 | 35 | } |
36 | 36 | |
37 | 37 | $output = shell_exec(sprintf('"%s" -l %s 2>&1', $php, escapeshellarg($filename))); |
@@ -24,7 +24,7 @@ |
||
24 | 24 | * @return int |
25 | 25 | */ |
26 | 26 | public function isCorrect($filename) { |
27 | - if(1 === version_compare('5.0.4', PHP_VERSION)) { |
|
27 | + if (1 === version_compare('5.0.4', PHP_VERSION)) { |
|
28 | 28 | return php_check_syntax($filename); |
29 | 29 | } |
30 | 30 |
@@ -43,9 +43,9 @@ |
||
43 | 43 | { |
44 | 44 | $alias = $real = null; |
45 | 45 | $expression = $this->searcher->getUnder(array(';'), $n, $tokens); |
46 | - if(preg_match('!use\s+(.*)\s+as\s+(.*)!i', $expression, $matches)) { |
|
46 | + if (preg_match('!use\s+(.*)\s+as\s+(.*)!i', $expression, $matches)) { |
|
47 | 47 | list(, $real, $alias) = $matches; |
48 | - } else if(preg_match('!use\s+([^\s\(]+)\s*!i', $expression, $matches)) { |
|
48 | + } else if (preg_match('!use\s+([^\s\(]+)\s*!i', $expression, $matches)) { |
|
49 | 49 | list(, $real) = $matches; |
50 | 50 | $alias = $real; |
51 | 51 | } |
@@ -52,12 +52,12 @@ discard block |
||
52 | 52 | |
53 | 53 | $token = $tokens[$n]; |
54 | 54 | $call = null; |
55 | - switch($token->getType()) { |
|
55 | + switch ($token->getType()) { |
|
56 | 56 | case T_PAAMAYIM_NEKUDOTAYIM: |
57 | 57 | $prev = $n - 1; |
58 | 58 | $value = $this->searcher->getUnder(array('::'), $prev, $tokens); |
59 | 59 | |
60 | - switch(true) { |
|
60 | + switch (true) { |
|
61 | 61 | case $value == 'parent' && $this->currentClass: |
62 | 62 | return $this->currentClass->getParent(); |
63 | 63 | |
@@ -66,10 +66,10 @@ discard block |
||
66 | 66 | $extendPosition = $this->searcher->getExtendPosition($tokens, $n); |
67 | 67 | return $this->searcher->getFollowingName($extendPosition, $tokens); |
68 | 68 | |
69 | - case ($value == 'static' ||$value === 'self')&& $this->currentClass: |
|
69 | + case ($value == 'static' || $value === 'self') && $this->currentClass: |
|
70 | 70 | return $this->currentClass->getFullname(); |
71 | 71 | |
72 | - case ($value == 'static' ||$value === 'self'): |
|
72 | + case ($value == 'static' || $value === 'self'): |
|
73 | 73 | $extendPosition = $this->searcher->getClassNamePosition($tokens); |
74 | 74 | return $this->searcher->getFollowingName($extendPosition, $tokens); |
75 | 75 | |
@@ -79,12 +79,12 @@ discard block |
||
79 | 79 | |
80 | 80 | case T_NEW: |
81 | 81 | $call = $this->searcher->getFollowingName($n, $tokens); |
82 | - if(preg_match('!^(\w+)!', $call, $matches)) { // fixes PHP 5.4: (new MyClass)->foo() |
|
82 | + if (preg_match('!^(\w+)!', $call, $matches)) { // fixes PHP 5.4: (new MyClass)->foo() |
|
83 | 83 | $call = $matches[1]; |
84 | 84 | } |
85 | 85 | break; |
86 | 86 | } |
87 | - if(null === $call) { |
|
87 | + if (null === $call) { |
|
88 | 88 | throw new \LogicException('Classname of call not found'); |
89 | 89 | } |
90 | 90 | return $call; |
@@ -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; |