Completed
Pull Request — master (#182)
by personal
05:57
created
src/Hal/Component/OOP/Extractor/CallExtractor.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -52,12 +52,12 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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;
Please login to merge, or discard this patch.
src/Hal/Component/OOP/Extractor/ClassExtractor.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -49,7 +49,7 @@
 block discarded – undo
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;
Please login to merge, or discard this patch.
src/Hal/Component/OOP/Extractor/ClassMap.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -31,7 +31,7 @@
 block discarded – undo
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
 
Please login to merge, or discard this patch.
src/Hal/Component/OOP/Extractor/Extractor.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -48,7 +48,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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);
Please login to merge, or discard this patch.
src/Hal/Component/OOP/Extractor/Result.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -31,7 +31,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
         }
Please login to merge, or discard this patch.
src/Hal/Component/OOP/Extractor/Searcher.php 1 patch
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -29,9 +29,9 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
         }
Please login to merge, or discard this patch.
src/Hal/Component/OOP/Reflected/ReflectedClass.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -136,11 +136,11 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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;
Please login to merge, or discard this patch.
src/Hal/Component/OOP/Resolver/NameResolver.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -43,7 +43,7 @@
 block discarded – undo
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
 
Please login to merge, or discard this patch.
src/Hal/Component/OOP/Resolver/TypeResolver.php 1 patch
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -41,47 +41,47 @@
 block discarded – undo
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
 
Please login to merge, or discard this patch.