Completed
Pull Request — master (#221)
by personal
04:09
created
src/Hal/Component/Tree/Graph.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -27,7 +27,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 
Please login to merge, or discard this patch.
src/Hal/Component/Tree/GraphFactory.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -23,9 +23,9 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
             }
Please login to merge, or discard this patch.
src/Hal/Component/Tree/Node.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -56,12 +56,12 @@
 block discarded – undo
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;
Please login to merge, or discard this patch.
src/Hal/Component/Parser/CodeParser/CallsParser.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -74,7 +74,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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);
Please login to merge, or discard this patch.
src/Hal/Component/Parser/CodeParser/MethodUsageParser.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -47,23 +47,23 @@
 block discarded – undo
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
 
Please login to merge, or discard this patch.
src/Hal/Component/Parser/CodeParser/ArgumentsParser.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -72,7 +72,7 @@
 block discarded – undo
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
 
Please login to merge, or discard this patch.
src/Hal/Component/Parser/CodeParser/ReturnParser.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -51,8 +51,8 @@  discard block
 block discarded – undo
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
 block discarded – undo
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];
Please login to merge, or discard this patch.
src/Hal/Component/Parser/Resolver/NamespaceResolver.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -46,7 +46,7 @@  discard block
 block discarded – undo
46 46
                 if (!isset($tokens[$next])) {
47 47
                     throw new IncorrectSyntaxException;
48 48
                 }
49
-                $this->currentNamespace = '\\' . $tokens[$next];
49
+                $this->currentNamespace = '\\'.$tokens[$next];
50 50
                 continue;
51 51
             }
52 52
 
@@ -106,8 +106,8 @@  discard block
 block discarded – undo
106 106
         if ('\\' === $alias[0]) {
107 107
             return $alias;
108 108
         }
109
-        if ($this->has('\\' . $alias)) {
110
-            return '\\' . $alias;
109
+        if ($this->has('\\'.$alias)) {
110
+            return '\\'.$alias;
111 111
         }
112 112
         if ($this->has($alias)) {
113 113
             return sprintf('%s\\%s', $this->currentNamespace, $this->namespaces[$alias]);
Please login to merge, or discard this patch.
src/Hal/Component/Parser/Helper/TypeResolver.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -28,7 +28,7 @@  discard block
 block discarded – undo
28 28
     public function resolve($token)
29 29
     {
30 30
 
31
-        if(strlen($token) == 0) {
31
+        if (strlen($token) == 0) {
32 32
             return Token::T_VALUE_VOID;
33 33
         }
34 34
 
@@ -36,35 +36,35 @@  discard block
 block discarded – undo
36 36
             return $token;
37 37
         }
38 38
 
39
-        if(preg_match('!^\d+$!', $token)) {
39
+        if (preg_match('!^\d+$!', $token)) {
40 40
             return Token::T_VALUE_INTEGER;
41 41
         }
42 42
 
43
-        if(preg_match('!^\d+\.\d+$!', $token)) {
43
+        if (preg_match('!^\d+\.\d+$!', $token)) {
44 44
             return Token::T_VALUE_FLOAT;
45 45
         }
46 46
 
47
-        if('null' == $token) {
47
+        if ('null' == $token) {
48 48
             return Token::T_VALUE_NULL;
49 49
         }
50 50
 
51
-        if(preg_match('!^\$\w+$!', $token)) {
51
+        if (preg_match('!^\$\w+$!', $token)) {
52 52
             return Token::T_VAR;
53 53
         }
54 54
 
55
-        if(preg_match('!(^\[|^array\()!', $token)) {
55
+        if (preg_match('!(^\[|^array\()!', $token)) {
56 56
             return Token::T_VALUE_ARRAY;
57 57
         }
58 58
 
59
-        if(preg_match('!^(true|false)!', $token)) {
59
+        if (preg_match('!^(true|false)!', $token)) {
60 60
             return Token::T_VALUE_BOOLEAN;
61 61
         }
62 62
 
63
-        if(preg_match('!^function!', $token)) {
63
+        if (preg_match('!^function!', $token)) {
64 64
             return Token::T_FUNCTION;
65 65
         }
66 66
 
67
-        if(preg_match('!^["\']!', $token)) {
67
+        if (preg_match('!^["\']!', $token)) {
68 68
             return Token::T_VALUE_STRING;
69 69
         }
70 70
 
@@ -86,7 +86,7 @@  discard block
 block discarded – undo
86 86
      */
87 87
     public function isObject($value)
88 88
     {
89
-        return !$this->isScalar($value) &&Token::T_VALUE_ARRAY !== $this->resolve($value);
89
+        return !$this->isScalar($value) && Token::T_VALUE_ARRAY !== $this->resolve($value);
90 90
     }
91 91
 
92 92
 }
93 93
\ No newline at end of file
Please login to merge, or discard this patch.