Completed
Pull Request — master (#226)
by Oskar
03:03
created
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.
src/Hal/Component/Phar/Updater.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -46,7 +46,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
                 }
Please login to merge, or discard this patch.
src/Hal/Component/Result/ResultCollection.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -46,7 +46,7 @@
 block discarded – undo
46 46
      */
47 47
     public function asArray() {
48 48
         $array = array();
49
-        foreach($this->results as $result) {
49
+        foreach ($this->results as $result) {
50 50
             array_push($array, $result->asArray());
51 51
         }
52 52
         return $array;
Please login to merge, or discard this patch.
src/Hal/Component/Score/ScoringInterface.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -16,7 +16,7 @@
 block discarded – undo
16 16
  *
17 17
  * @author Jean-François Lépine <https://twitter.com/Halleck45>
18 18
  */
19
-interface ScoringInterface  {
19
+interface ScoringInterface {
20 20
 
21 21
     /**
22 22
      * Calculates score
Please login to merge, or discard this patch.
src/Hal/Component/Token/Token.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -35,7 +35,7 @@  discard block
 block discarded – undo
35 35
      */
36 36
     public function __construct($data)
37 37
     {
38
-        if(!is_array($data)) {
38
+        if (!is_array($data)) {
39 39
             $this->type = T_STRING;
40 40
             $this->value = $data;
41 41
         } else {
@@ -44,7 +44,7 @@  discard block
 block discarded – undo
44 44
         }
45 45
 
46 46
         // reduce multiple spaces to one
47
-        if(T_WHITESPACE  === $this->type && preg_match('/^\s*$/', $this->value)) {
47
+        if (T_WHITESPACE === $this->type && preg_match('/^\s*$/', $this->value)) {
48 48
             $this->value = ' ';
49 49
         }
50 50
     }
Please login to merge, or discard this patch.
src/Hal/Component/Token/TokenCollection.php 2 patches
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -80,7 +80,7 @@
 block discarded – undo
80 80
      */
81 81
     public function offsetExists($offset)
82 82
     {
83
-       return isset($this->tokens[$offset]);
83
+        return isset($this->tokens[$offset]);
84 84
     }
85 85
 
86 86
     /**
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -28,8 +28,8 @@  discard block
 block discarded – undo
28 28
      */
29 29
     public function __construct(array $tokens)
30 30
     {
31
-        foreach($tokens as $index => &$token) {
32
-            if(!$token instanceof Token) {
31
+        foreach ($tokens as $index => &$token) {
32
+            if (!$token instanceof Token) {
33 33
                 $token = new Token($token);
34 34
             }
35 35
         }
@@ -57,7 +57,7 @@  discard block
 block discarded – undo
57 57
      * @return TokenCollection
58 58
      */
59 59
     public function extract($start, $end) {
60
-        $concerned = array_slice($this->asArray(), $start, $end - $start );
60
+        $concerned = array_slice($this->asArray(), $start, $end - $start);
61 61
         return new TokenCollection($concerned);
62 62
     }
63 63
 
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
      */
69 69
     public function asString() {
70 70
         $c = '';
71
-        foreach($this->tokens as $token) {
71
+        foreach ($this->tokens as $token) {
72 72
             $c .= $token->asString();
73 73
         }
74 74
         $c = preg_replace('!(\n\s+)!', "\n", $c);
@@ -96,7 +96,7 @@  discard block
 block discarded – undo
96 96
      */
97 97
     public function offsetSet($offset, $value)
98 98
     {
99
-        if(!$value instanceof Token) {
99
+        if (!$value instanceof Token) {
100 100
             $value = new Token($value);
101 101
         }
102 102
         $this->tokens[$offset] = $value;
Please login to merge, or discard this patch.
src/Hal/Component/Token/TokenCollectionCompatibility.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -23,17 +23,17 @@  discard block
 block discarded – undo
23 23
      */
24 24
     public function decorate(array $tokens)
25 25
     {
26
-        if(-1 !== version_compare(PHP_VERSION, '7.0.0')) {
26
+        if (-1 !== version_compare(PHP_VERSION, '7.0.0')) {
27 27
             return $tokens;
28 28
         }
29 29
 
30 30
         $previous = null;
31
-        foreach($tokens as $index => &$token) {
31
+        foreach ($tokens as $index => &$token) {
32 32
 
33 33
             // coalesce operator
34
-            if(T_STRING == $token->getType()&&'?' == $token->getValue()
34
+            if (T_STRING == $token->getType() && '?' == $token->getValue()
35 35
                 && $index > 0
36
-                && T_STRING == $previous->getType()&&'?' == $previous->getValue()
36
+                && T_STRING == $previous->getType() && '?' == $previous->getValue()
37 37
             ) {
38 38
                 unset($tokens[$index]);
39 39
                 $tokens[$index - 1] = new Token(array(T_COALESCE, T_COALESCE));
@@ -42,7 +42,7 @@  discard block
 block discarded – undo
42 42
 
43 43
 
44 44
             // spaceship operator
45
-            if($index > 2
45
+            if ($index > 2
46 46
                 && T_STRING == $tokens[$index]->getType() && '>' === $tokens[$index]->getValue()
47 47
                 && T_IS_SMALLER_OR_EQUAL == $previous->getType()
48 48
             ) {
Please login to merge, or discard this patch.
src/Hal/Component/Token/TokenType.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -104,7 +104,7 @@  discard block
 block discarded – undo
104 104
      * @var array
105 105
      */
106 106
     private $operatorsStrings = array(
107
-        ';', '*', '/', '%', '-','+'
107
+        ';', '*', '/', '%', '-', '+'
108 108
     , '!', '!=', '%', '%=', '&', '&&', '||', '&=', '(', ')'
109 109
         /*, '{', '}'*/, '[', ']', '*', '*=', '+', '++', '+=', ','
110 110
     , '-', '--', '-=->', '.', '...', '/', '/=', ':', '::'
@@ -120,7 +120,7 @@  discard block
 block discarded – undo
120 120
      */
121 121
     private $byPass = array(
122 122
         '{', '}' // in PHP, these case are counted with T_IF, '(', ...
123
-    , ')' , '('   // we count only the first (
123
+    , ')', '('   // we count only the first (
124 124
     , ','
125 125
     );
126 126
 
@@ -128,7 +128,7 @@  discard block
 block discarded – undo
128 128
      * Constructor
129 129
      */
130 130
     public function __construct() {
131
-        if(version_compare(PHP_VERSION, '5.4.0') >= 0) {
131
+        if (version_compare(PHP_VERSION, '5.4.0') >= 0) {
132 132
             $this->operators = array_merge($this->operators, array(
133 133
                 T_INSTEADOF
134 134
             , T_TRAIT_C
@@ -141,9 +141,9 @@  discard block
 block discarded – undo
141 141
 
142 142
         // performance : key will be equals to it value
143 143
         $this->operands = array_combine($this->operands, $this->operands);
144
-        $this->operators= array_combine($this->operators, $this->operators);
144
+        $this->operators = array_combine($this->operators, $this->operators);
145 145
         $this->operatorsStrings = array_combine($this->operatorsStrings, $this->operatorsStrings);
146
-        $this->byPass= array_combine($this->byPass, $this->byPass);
146
+        $this->byPass = array_combine($this->byPass, $this->byPass);
147 147
     }
148 148
 
149 149
     /**
@@ -154,8 +154,8 @@  discard block
 block discarded – undo
154 154
      */
155 155
     public function isOperand(Token $token)
156 156
     {
157
-        if(T_STRING == $token->getType()) {
158
-            return !(isset($this->byPass[$token->getValue()]) ||isset($this->operatorsStrings[$token->getValue()]));
157
+        if (T_STRING == $token->getType()) {
158
+            return !(isset($this->byPass[$token->getValue()]) || isset($this->operatorsStrings[$token->getValue()]));
159 159
         }
160 160
 
161 161
         return isset($this->operands[$token->getType()]);
@@ -169,8 +169,8 @@  discard block
 block discarded – undo
169 169
      */
170 170
     public function isOperator(Token $token)
171 171
     {
172
-        if(T_STRING == $token->getType()) {
173
-            if(isset($this->byPass[$token->getValue()])) {
172
+        if (T_STRING == $token->getType()) {
173
+            if (isset($this->byPass[$token->getValue()])) {
174 174
                 return false;
175 175
             }
176 176
             return isset($this->operatorsStrings[$token->getValue()]);
Please login to merge, or discard this patch.
src/Hal/Metrics/Complexity/Component/McCabe/McCabe.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -56,9 +56,9 @@  discard block
 block discarded – undo
56 56
         $tokens = $this->tokenizer->tokenize($filename);
57 57
 
58 58
         $ccn = 1; // default path
59
-        foreach($tokens as $token) {
59
+        foreach ($tokens as $token) {
60 60
 
61
-            switch($token->getType()) {
61
+            switch ($token->getType()) {
62 62
                 case T_IF:
63 63
                 case T_ELSEIF:
64 64
                 case T_FOREACH:
@@ -77,7 +77,7 @@  discard block
 block discarded – undo
77 77
                     $ccn++;
78 78
                     break;
79 79
                 case T_STRING:
80
-                    if('?' == $token->getValue()) {
80
+                    if ('?' == $token->getValue()) {
81 81
                         $ccn = $ccn + 2;
82 82
                     }
83 83
                     break;
Please login to merge, or discard this patch.