Completed
Pull Request — master (#221)
by personal
04:09
created
src/Hal/Metrics/Complexity/Text/Halstead/Halstead.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -59,7 +59,7 @@
 block discarded – undo
59 59
     /**
60 60
      * Inventories tokens
61 61
      *
62
-     * @param array $tokens
62
+     * @param \SplFixedArray $tokens
63 63
      * @return $this
64 64
      */
65 65
     private function inventory($tokens)
Please login to merge, or discard this patch.
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -66,11 +66,11 @@  discard block
 block discarded – undo
66 66
     {
67 67
         $this->operators = $this->operands = array();
68 68
 
69
-        foreach($tokens as $token) {
70
-            if($this->tokenType->isOperator($token)) {
69
+        foreach ($tokens as $token) {
70
+            if ($this->tokenType->isOperator($token)) {
71 71
                 $this->operators[] = $token;
72 72
             }
73
-            else if($this->tokenType->isOperand($token)) {
73
+            else if ($this->tokenType->isOperand($token)) {
74 74
                 $this->operands[] = $token;
75 75
             }
76 76
         }
@@ -93,23 +93,23 @@  discard block
 block discarded – undo
93 93
         $this->inventory($class->getTokens());
94 94
         $result = new Result;
95 95
 
96
-        $uniqueOperators = array_map( 'unserialize', array_unique( array_map( 'serialize', $this->operators ) ) );
97
-        $uniqueOperands = array_map( 'unserialize', array_unique( array_map( 'serialize', $this->operands ) ) );
96
+        $uniqueOperators = array_map('unserialize', array_unique(array_map('serialize', $this->operators)));
97
+        $uniqueOperands = array_map('unserialize', array_unique(array_map('serialize', $this->operands)));
98 98
 
99 99
         $n1 = sizeof($uniqueOperators, COUNT_NORMAL);
100 100
         $n2 = sizeof($uniqueOperands, COUNT_NORMAL);
101 101
         $N1 = sizeof($this->operators, COUNT_NORMAL);
102 102
         $N2 = sizeof($this->operands, COUNT_NORMAL);
103 103
 
104
-        if(($n2 == 0)||($N2 == 0)) {
104
+        if (($n2 == 0) || ($N2 == 0)) {
105 105
             // files without operators
106 106
             $V = $n1 = $n2 = $N1 = $N2 = $E = $D = $B = $T = $I = $L = 0;
107 107
         } else {
108 108
             $devAbility = 3000;
109 109
             $N = $N1 + $N2;
110 110
             $n = $n1 + $n2;
111
-            $V = $N * log($n ,2);
112
-            $L = (2 / max(1,$n1)) * ($n2 / $N2);
111
+            $V = $N * log($n, 2);
112
+            $L = (2 / max(1, $n1)) * ($n2 / $N2);
113 113
             $D = ($n1 / 2) * ($N2 / $n2);
114 114
             $E = $V * $D;
115 115
             $B = $V / $devAbility;
@@ -120,13 +120,13 @@  discard block
 block discarded – undo
120 120
         $result
121 121
             ->setLength($N1 + $N2)
122 122
             ->setVocabulary($n1 + $n2)
123
-            ->setVolume(round($V,2))
124
-            ->setDifficulty(round($D,2))
125
-            ->setEffort(round($E,2))
123
+            ->setVolume(round($V, 2))
124
+            ->setDifficulty(round($D, 2))
125
+            ->setEffort(round($E, 2))
126 126
             ->setLevel(round($L, 2))
127 127
             ->setBugs(round($B, 2))
128 128
             ->setTime(round($T))
129
-            ->setIntelligentContent(round($I,2))
129
+            ->setIntelligentContent(round($I, 2))
130 130
             ->setNumberOfOperators($N1)
131 131
             ->setNumberOfOperands($N2)
132 132
             ->setNumberOfUniqueOperators($n1)
Please login to merge, or discard this patch.
src/Hal/Component/Token/Tokenizer.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -9,7 +9,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
Please login to merge, or discard this patch.
src/Hal/Component/Token/TokenType.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -19,7 +19,7 @@
 block discarded – undo
19 19
      * @var array
20 20
      */
21 21
     private $operators = array(
22
-        ';', '*', '/', '%', '-','+',
22
+        ';', '*', '/', '%', '-', '+',
23 23
         '!', '!=', '%', '%=', '&', '&&', 'OR', 'AND', '||', '&=', '(', ')',
24 24
         '[', ']', '*', '*=', '+', '++', '+=', ',',
25 25
         '-', '--', '-=->', '.', '...', '/', '/=', ':', '::',
Please login to merge, or discard this patch.
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.