@@ -9,7 +9,7 @@ discard block |
||
9 | 9 | $code = preg_replace('!(\}|\)|;)\?!', '$1 ?', $code); |
10 | 10 | |
11 | 11 | // remove one line comments |
12 | - $code = preg_replace('!((\/\/|#).*\n)!', Token::T_COMMENT . ' ', $code); |
|
12 | + $code = preg_replace('!((\/\/|#).*\n)!', Token::T_COMMENT.' ', $code); |
|
13 | 13 | |
14 | 14 | // remove EOL |
15 | 15 | $code = preg_replace('!(\s+)!', ' ', $code); |
@@ -37,6 +37,6 @@ discard block |
||
37 | 37 | $code = preg_replace('!return;!i', Token::T_RETURN_VOID, $code); |
38 | 38 | |
39 | 39 | // split tokens |
40 | - return preg_split('!\s|;|,|(\{|\}|\(|\))!', $code, null, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY); |
|
40 | + return preg_split('!\s|;|,|(\{|\}|\(|\))!', $code, null, PREG_SPLIT_DELIM_CAPTURE|PREG_SPLIT_NO_EMPTY); |
|
41 | 41 | } |
42 | 42 | } |
43 | 43 | \ No newline at end of file |
@@ -19,7 +19,7 @@ |
||
19 | 19 | * @var array |
20 | 20 | */ |
21 | 21 | private $operators = array( |
22 | - ';', '*', '/', '%', '-','+', |
|
22 | + ';', '*', '/', '%', '-', '+', |
|
23 | 23 | '!', '!=', '%', '%=', '&', '&&', 'OR', 'AND', '||', '&=', '(', ')', |
24 | 24 | '[', ']', '*', '*=', '+', '++', '+=', ',', |
25 | 25 | '-', '--', '-=->', '.', '...', '/', '/=', ':', '::', |
@@ -27,7 +27,7 @@ discard block |
||
27 | 27 | */ |
28 | 28 | public function insert(Node $node) |
29 | 29 | { |
30 | - if($this->has($node->getKey())) { |
|
30 | + if ($this->has($node->getKey())) { |
|
31 | 31 | throw new GraphException(sprintf('node %s is already present', $node->getKey())); |
32 | 32 | } |
33 | 33 | $this->datas[$node->getKey()] = $node; |
@@ -41,10 +41,10 @@ discard block |
||
41 | 41 | */ |
42 | 42 | public function addEdge(Node $from, Node $to) |
43 | 43 | { |
44 | - if(!$this->has($from->getKey())) { |
|
44 | + if (!$this->has($from->getKey())) { |
|
45 | 45 | throw new GraphException('from is not is in the graph'); |
46 | 46 | } |
47 | - if(!$this->has($to->getKey())) { |
|
47 | + if (!$this->has($to->getKey())) { |
|
48 | 48 | throw new GraphException('to is not is in the graph'); |
49 | 49 | } |
50 | 50 |
@@ -23,9 +23,9 @@ discard block |
||
23 | 23 | $graph = new Graph(); |
24 | 24 | |
25 | 25 | // insert all required nodes in graph |
26 | - foreach($hash as $node) { |
|
27 | - foreach($node->getData()->getDependencies() as $dependencyName) { |
|
28 | - if(!$hash->has($dependencyName)) { |
|
26 | + foreach ($hash as $node) { |
|
27 | + foreach ($node->getData()->getDependencies() as $dependencyName) { |
|
28 | + if (!$hash->has($dependencyName)) { |
|
29 | 29 | // dependency is not registered (example: external dependency from vendors) |
30 | 30 | $adjacent = new Node($dependencyName, new Klass($dependencyName)); |
31 | 31 | $graph->insert($adjacent); |
@@ -35,8 +35,8 @@ discard block |
||
35 | 35 | } |
36 | 36 | |
37 | 37 | // relations |
38 | - foreach($hash as $from) { |
|
39 | - foreach($from->getData()->getDependencies() as $dependencyName) { |
|
38 | + foreach ($hash as $from) { |
|
39 | + foreach ($from->getData()->getDependencies() as $dependencyName) { |
|
40 | 40 | $to = $graph->get($dependencyName); |
41 | 41 | $graph->addEdge($from, $to); |
42 | 42 | } |
@@ -56,12 +56,12 @@ |
||
56 | 56 | public function getAdjacents() |
57 | 57 | { |
58 | 58 | $adjacents = []; |
59 | - foreach($this->edges as $edge) { |
|
60 | - if($edge->getFrom()->getKey() != $this->getKey()) { |
|
61 | - $adjacents[$edge->getFrom()->getKey()] = $edge->getFrom(); |
|
59 | + foreach ($this->edges as $edge) { |
|
60 | + if ($edge->getFrom()->getKey() != $this->getKey()) { |
|
61 | + $adjacents[$edge->getFrom()->getKey()] = $edge->getFrom(); |
|
62 | 62 | } |
63 | - if($edge->getTo()->getKey() != $this->getKey()) { |
|
64 | - $adjacents[$edge->getTo()->getKey()] = $edge->getTo(); |
|
63 | + if ($edge->getTo()->getKey() != $this->getKey()) { |
|
64 | + $adjacents[$edge->getTo()->getKey()] = $edge->getTo(); |
|
65 | 65 | } |
66 | 66 | } |
67 | 67 | return $adjacents; |
@@ -74,7 +74,7 @@ discard block |
||
74 | 74 | |
75 | 75 | // $instance->foo(); |
76 | 76 | if (Token::T_NEW == $token) { |
77 | - if(!isset($tokens[$i + 1]) || Token::T_BRACE_CLOSE === $tokens[$i + 1]) { |
|
77 | + if (!isset($tokens[$i + 1]) || Token::T_BRACE_CLOSE === $tokens[$i + 1]) { |
|
78 | 78 | throw new IncorrectSyntaxException('"new" is not followed by classname'); |
79 | 79 | } |
80 | 80 | |
@@ -99,10 +99,10 @@ discard block |
||
99 | 99 | } |
100 | 100 | |
101 | 101 | // $this->foo(); |
102 | - if(preg_match('!^\$this\->(.+)!', $token, $matches)) { |
|
102 | + if (preg_match('!^\$this\->(.+)!', $token, $matches)) { |
|
103 | 103 | list(, $methodName) = $matches; |
104 | 104 | // next token should be "(" |
105 | - if(isset($tokens[$i + 1]) &&Token::T_PARENTHESIS_OPEN === $tokens[$i + 1]) { |
|
105 | + if (isset($tokens[$i + 1]) && Token::T_PARENTHESIS_OPEN === $tokens[$i + 1]) { |
|
106 | 106 | $call = new Call(null, $methodName); |
107 | 107 | $call->setIsItself(true); |
108 | 108 | array_push($calls, $call); |
@@ -47,23 +47,23 @@ |
||
47 | 47 | |
48 | 48 | $start = $this->searcher->getNext($method->getTokens(), 0, '{') + 1; |
49 | 49 | $len = sizeof($method->getTokens()); |
50 | - $tokens = array_slice($method->getTokens(), $start, ($len - $start) - 1); |
|
50 | + $tokens = array_slice($method->getTokens(), $start, ($len - $start) - 1); |
|
51 | 51 | |
52 | - foreach($tokens as $n => $token) { |
|
52 | + foreach ($tokens as $n => $token) { |
|
53 | 53 | // replace $this->aaa by "class_attribute |
54 | - if(preg_match('!^\$this\->\w+$!', $token)) { |
|
54 | + if (preg_match('!^\$this\->\w+$!', $token)) { |
|
55 | 55 | $tokens[$n] = 'class_attribute'; |
56 | 56 | } |
57 | 57 | |
58 | 58 | // replace vars by "var" |
59 | - if(preg_match('!^\$\w+$!', $token) && $token != '$this') { |
|
59 | + if (preg_match('!^\$\w+$!', $token) && $token != '$this') { |
|
60 | 60 | $tokens[$n] = 'var'; |
61 | 61 | } |
62 | 62 | } |
63 | - switch($tokens) { |
|
63 | + switch ($tokens) { |
|
64 | 64 | // getters |
65 | 65 | case array('return', 'cast', 'class_attribute'): |
66 | - case array('return','class_attribute'): |
|
66 | + case array('return', 'class_attribute'): |
|
67 | 67 | return MethodUsage::USAGE_GETTER; |
68 | 68 | break; |
69 | 69 |
@@ -72,7 +72,7 @@ |
||
72 | 72 | $i = $i + 2; |
73 | 73 | // look for default value |
74 | 74 | if (!isset($tokens[$i]) || Token::T_PARENTHESIS_CLOSE == $tokens[$i]) { |
75 | - throw new IncorrectSyntaxException('not default value found for parameter ' . $token); |
|
75 | + throw new IncorrectSyntaxException('not default value found for parameter '.$token); |
|
76 | 76 | } |
77 | 77 | $value = $tokens[$i]; |
78 | 78 |
@@ -51,8 +51,8 @@ discard block |
||
51 | 51 | |
52 | 52 | // PHP 7 return |
53 | 53 | $closingParenthesis = $this->searcher->getNext($tokens, 0, Token::T_PARENTHESIS_CLOSE); |
54 | - if($closingParenthesis + 2 <= sizeof($tokens)) { |
|
55 | - if(Token::T_FUNCTION_RETURN === $tokens[$closingParenthesis + 1]) { |
|
54 | + if ($closingParenthesis + 2 <= sizeof($tokens)) { |
|
55 | + if (Token::T_FUNCTION_RETURN === $tokens[$closingParenthesis + 1]) { |
|
56 | 56 | $class = $this->namespaceResolver->resolve($tokens[$closingParenthesis + 2]); |
57 | 57 | array_push($returns, new ReturnedValue($class)); |
58 | 58 | } |
@@ -61,20 +61,20 @@ discard block |
||
61 | 61 | // returns in code |
62 | 62 | $typeResolver = new TypeResolver(); |
63 | 63 | $len = sizeof($tokens); |
64 | - for($i = 0; $i < $len; $i++) { |
|
64 | + for ($i = 0; $i < $len; $i++) { |
|
65 | 65 | |
66 | 66 | $token = $tokens[$i]; |
67 | 67 | |
68 | - if(Token::T_RETURN_VOID === $token) { |
|
68 | + if (Token::T_RETURN_VOID === $token) { |
|
69 | 69 | array_push($returns, new ReturnedValue(Token::T_VALUE_VOID)); |
70 | 70 | continue; |
71 | 71 | } |
72 | 72 | |
73 | - if(Token::T_RETURN === $token) { |
|
73 | + if (Token::T_RETURN === $token) { |
|
74 | 74 | // return with value |
75 | 75 | $next = $tokens[$i + 1]; |
76 | - if(Token::T_NEW === $next) { |
|
77 | - if(!isset($tokens[$i + 2])) { |
|
76 | + if (Token::T_NEW === $next) { |
|
77 | + if (!isset($tokens[$i + 2])) { |
|
78 | 78 | throw new IncorrectSyntaxException('"return new" without classname'); |
79 | 79 | } |
80 | 80 | $classname = $tokens[$i + 2]; |