Completed
Pull Request — master (#448)
by
unknown
08:31
created
phpmetrics/src/Hal/Metric/Class_/Text/HalsteadVisitor.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -45,10 +45,10 @@  discard block
 block discarded – undo
45 45
     {
46 46
         if ($node instanceof Stmt\Class_ || $node instanceof Stmt\Function_ || $node instanceof Stmt\Trait_) {
47 47
             if ($node instanceof Stmt\Class_ || $node instanceof Stmt\Trait_) {
48
-                $name = (string)(isset($node->namespacedName) ? $node->namespacedName : 'anonymous@' . spl_object_hash($node));
48
+                $name = (string) (isset($node->namespacedName) ? $node->namespacedName : 'anonymous@'.spl_object_hash($node));
49 49
                 $classOrFunction = $this->metrics->get($name);
50 50
             } else {
51
-                $name = (string)$node->name;
51
+                $name = (string) $node->name;
52 52
                 $classOrFunction = new FunctionMetric($name);
53 53
                 $this->metrics->attach($classOrFunction);
54 54
             }
@@ -61,7 +61,7 @@  discard block
 block discarded – undo
61 61
             $operands = [];
62 62
             $operators = [];
63 63
 
64
-            iterate_over_node($node, function ($node) use (&$operators, &$operands) {
64
+            iterate_over_node($node, function($node) use (&$operators, &$operands) {
65 65
                 if ($node instanceof Node\Expr\BinaryOp
66 66
                     || $node instanceof Node\Expr\AssignOp
67 67
                     || $node instanceof Stmt\If_
Please login to merge, or discard this patch.
phpmetrics/src/Hal/Metric/Class_/Structural/LcomVisitor.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -49,17 +49,17 @@  discard block
 block discarded – undo
49 49
 
50 50
             foreach ($node->stmts as $stmt) {
51 51
                 if ($stmt instanceof Stmt\ClassMethod) {
52
-                    if (!$graph->has($stmt->name . '()')) {
53
-                        $graph->insert(new TreeNode($stmt->name . '()'));
52
+                    if (!$graph->has($stmt->name.'()')) {
53
+                        $graph->insert(new TreeNode($stmt->name.'()'));
54 54
                     }
55
-                    $from = $graph->get($stmt->name . '()');
55
+                    $from = $graph->get($stmt->name.'()');
56 56
                     if ($from === null) {
57 57
                         throw new ShouldNotHappenException('Graph $from is null');
58 58
                     }
59 59
 
60
-                    \iterate_over_node($stmt, function ($node) use ($from, &$graph) {
60
+                    \iterate_over_node($stmt, function($node) use ($from, &$graph) {
61 61
                         if ($node instanceof Node\Expr\PropertyFetch && isset($node->var->name) && $node->var->name == 'this') {
62
-                            $name = (string)getNameOfNode($node);
62
+                            $name = (string) getNameOfNode($node);
63 63
                             // use of attribute $this->xxx;
64 64
                             if (!$graph->has($name)) {
65 65
                                 $graph->insert(new TreeNode($name));
@@ -76,7 +76,7 @@  discard block
 block discarded – undo
76 76
                             if (!$node->var instanceof Node\Expr\New_ && isset($node->var->name) && getNameOfNode($node->var) === 'this') {
77 77
                                 // use of method call $this->xxx();
78 78
                                 // use of attribute $this->xxx;
79
-                                $name = getNameOfNode($node->name) . '()';
79
+                                $name = getNameOfNode($node->name).'()';
80 80
                                 if (!$graph->has($name)) {
81 81
                                     $graph->insert(new TreeNode($name));
82 82
                                 }
Please login to merge, or discard this patch.
phpmetrics/src/Hal/Metric/Class_/Coupling/ExternalsVisitor.php 1 patch
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -64,20 +64,20 @@  discard block
 block discarded – undo
64 64
             // extends
65 65
             if (isset($node->extends)) {
66 66
                 if (is_array($node->extends)) {
67
-                    foreach ((array)$node->extends as $interface) {
68
-                        $this->pushToDependencies($dependencies, (string)$interface);
69
-                        array_push($parents, (string)$interface);
67
+                    foreach ((array) $node->extends as $interface) {
68
+                        $this->pushToDependencies($dependencies, (string) $interface);
69
+                        array_push($parents, (string) $interface);
70 70
                     }
71 71
                 } else {
72
-                    $this->pushToDependencies($dependencies, (string)$node->extends);
73
-                    array_push($parents, (string)$node->extends);
72
+                    $this->pushToDependencies($dependencies, (string) $node->extends);
73
+                    array_push($parents, (string) $node->extends);
74 74
                 }
75 75
             }
76 76
 
77 77
             // implements
78 78
             if (isset($node->implements)) {
79 79
                 foreach ($node->implements as $interface) {
80
-                    $this->pushToDependencies($dependencies, (string)$interface);
80
+                    $this->pushToDependencies($dependencies, (string) $interface);
81 81
                 }
82 82
             }
83 83
 
@@ -86,7 +86,7 @@  discard block
 block discarded – undo
86 86
                     // return
87 87
                     if (isset($stmt->returnType)) {
88 88
                         if ($stmt->returnType instanceof Node\Name\FullyQualified) {
89
-                            $this->pushToDependencies($dependencies, (string)$stmt->returnType);
89
+                            $this->pushToDependencies($dependencies, (string) $stmt->returnType);
90 90
                         }
91 91
                     }
92 92
 
@@ -94,21 +94,21 @@  discard block
 block discarded – undo
94 94
                     foreach ($stmt->params as $param) {
95 95
                         if ($param->type) {
96 96
                             if ($param->type instanceof Node\Name\FullyQualified) {
97
-                                $this->pushToDependencies($dependencies, (string)$param->type);
97
+                                $this->pushToDependencies($dependencies, (string) $param->type);
98 98
                             }
99 99
                         }
100 100
                     }
101 101
 
102 102
                     // instantiations, static calls
103
-                    \iterate_over_node($stmt, function ($node) use (&$dependencies) {
103
+                    \iterate_over_node($stmt, function($node) use (&$dependencies) {
104 104
                         switch (true) {
105 105
                             case $node instanceof Node\Expr\New_:
106 106
                                 // new MyClass
107
-                                $this->pushToDependencies($dependencies, (string)getNameOfNode($node));
107
+                                $this->pushToDependencies($dependencies, (string) getNameOfNode($node));
108 108
                                 break;
109 109
                             case $node instanceof Node\Expr\StaticCall:
110 110
                                 // MyClass::Call
111
-                                $this->pushToDependencies($dependencies, (string)getNameOfNode($node));
111
+                                $this->pushToDependencies($dependencies, (string) getNameOfNode($node));
112 112
                                 break;
113 113
                         }
114 114
                     });
@@ -119,13 +119,13 @@  discard block
 block discarded – undo
119 119
                         foreach ($matches[1] as $check) {
120 120
                             foreach ($this->uses as $use) {
121 121
                                 if (method_exists($use, 'getAlias')) {
122
-                                    if (((string)$use->getAlias()) === $check) {
123
-                                        $this->pushToDependencies($dependencies, (string)($use->name));
122
+                                    if (((string) $use->getAlias()) === $check) {
123
+                                        $this->pushToDependencies($dependencies, (string) ($use->name));
124 124
                                     }
125 125
                                     continue;
126 126
                                 }
127 127
                                 if ($use->alias === $check) {
128
-                                    $this->pushToDependencies($dependencies, (string)($use->name));
128
+                                    $this->pushToDependencies($dependencies, (string) ($use->name));
129 129
                                 }
130 130
                             }
131 131
                         }
@@ -152,6 +152,6 @@  discard block
 block discarded – undo
152 152
         if ('self' === $lowercase || 'parent' === $lowercase) {
153 153
             return;
154 154
         }
155
-        array_push($dependencies, (string)$dependency);
155
+        array_push($dependencies, (string) $dependency);
156 156
     }
157 157
 }
Please login to merge, or discard this patch.
phpmetrics/src/Hal/Metric/Class_/Complexity/KanDefectVisitor.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -46,7 +46,7 @@  discard block
 block discarded – undo
46 46
 
47 47
             $select = $while = $if = 0;
48 48
 
49
-            iterate_over_node($node, function ($node) use (&$while, &$select, &$if) {
49
+            iterate_over_node($node, function($node) use (&$while, &$select, &$if) {
50 50
                 switch (true) {
51 51
                     case $node instanceof Stmt\Do_:
52 52
                     case $node instanceof Stmt\Foreach_:
@@ -62,7 +62,7 @@  discard block
 block discarded – undo
62 62
                 }
63 63
             });
64 64
 
65
-            $defect = 0.15 + 0.23 *  $while + 0.22 *  $select + 0.07 * $if;
65
+            $defect = 0.15 + 0.23 * $while + 0.22 * $select + 0.07 * $if;
66 66
             $class->set('kanDefect', round($defect, 2));
67 67
         }
68 68
 
Please login to merge, or discard this patch.
phpmetrics/src/Hal/Metric/Package/PackageDependencies.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -13,7 +13,7 @@  discard block
 block discarded – undo
13 13
     /** @return void */
14 14
     public function calculate(Metrics $metrics)
15 15
     {
16
-        $classes = array_filter($metrics->all(), function (Metric $metric) {
16
+        $classes = array_filter($metrics->all(), function(Metric $metric) {
17 17
             return $metric instanceof ClassMetric || $metric instanceof InterfaceMetric;
18 18
         });
19 19
 
@@ -30,7 +30,7 @@  discard block
 block discarded – undo
30 30
      */
31 31
     private function increaseDependencies(Metric $class, Metrics $metrics)
32 32
     {
33
-        if (! $class->has('package') || ! $class->has('externals')) {
33
+        if (!$class->has('package') || !$class->has('externals')) {
34 34
             return;
35 35
         }
36 36
         /** @var PackageMetric $incomingPackage */
@@ -66,6 +66,6 @@  discard block
 block discarded – undo
66 66
         }
67 67
         $parts = explode('\\', $className);
68 68
         array_pop($parts);
69
-        return implode('\\', $parts) . '\\';
69
+        return implode('\\', $parts).'\\';
70 70
     }
71 71
 }
Please login to merge, or discard this patch.
phpmetrics/src/Hal/Metric/Package/PackageAbstraction.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@
 block discarded – undo
12 12
     public function calculate(Metrics $metrics)
13 13
     {
14 14
         foreach ($metrics->all() as $eachPackage) {
15
-            if (! $eachPackage instanceof PackageMetric) {
15
+            if (!$eachPackage instanceof PackageMetric) {
16 16
                 continue;
17 17
             }
18 18
             $abstractClassCount = 0;
Please login to merge, or discard this patch.
phpmetrics/src/Hal/Metric/Package/PackageCollectingVisitor.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -28,7 +28,7 @@  discard block
 block discarded – undo
28 28
     public function enterNode(Node $node)
29 29
     {
30 30
         if ($node instanceof Namespace_) {
31
-            $this->namespace = (string)$node->name;
31
+            $this->namespace = (string) $node->name;
32 32
         }
33 33
 
34 34
         return null;
@@ -45,17 +45,17 @@  discard block
 block discarded – undo
45 45
                 $package = $matches[1];
46 46
             }
47 47
             if (preg_match('/^\s*\* @subpackage (.*)/m', $docBlockText, $matches)) {
48
-                $package = $package . '\\' . $matches[1];
48
+                $package = $package.'\\'.$matches[1];
49 49
             }
50 50
 
51
-            $packageName = $package . '\\';
52
-            if (! $packageMetric = $this->metrics->get($packageName)) {
51
+            $packageName = $package.'\\';
52
+            if (!$packageMetric = $this->metrics->get($packageName)) {
53 53
                 $packageMetric = new PackageMetric($packageName);
54 54
                 $this->metrics->attach($packageMetric);
55 55
             }
56 56
             /** @var PackageMetric $packageMetric */
57
-            $elementName = isset($node->namespacedName) ? $node->namespacedName : 'anonymous@' . spl_object_hash($node);
58
-            $elementName = (string)$elementName;
57
+            $elementName = isset($node->namespacedName) ? $node->namespacedName : 'anonymous@'.spl_object_hash($node);
58
+            $elementName = (string) $elementName;
59 59
             $packageMetric->addClass($elementName);
60 60
 
61 61
             $metric = $this->metrics->get($elementName);
Please login to merge, or discard this patch.
phpmetrics/src/Hal/Metric/Package/PackageInstability.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@  discard block
 block discarded – undo
12 12
     public function calculate(Metrics $metrics)
13 13
     {
14 14
         /* @var $packages PackageMetric[] */
15
-        $packages = array_filter($metrics->all(), function ($metric) {
15
+        $packages = array_filter($metrics->all(), function($metric) {
16 16
             return $metric instanceof PackageMetric;
17 17
         });
18 18
 
@@ -30,7 +30,7 @@  discard block
 block discarded – undo
30 30
         }
31 31
         // Set depending instabilities
32 32
         foreach ($packages as $eachPackage) {
33
-            $dependentInstabilities = array_map(function ($packageName) use ($instabilitiesByPackage) {
33
+            $dependentInstabilities = array_map(function($packageName) use ($instabilitiesByPackage) {
34 34
                 return isset($instabilitiesByPackage[$packageName]) ? $instabilitiesByPackage[$packageName] : null;
35 35
             }, $eachPackage->getOutgoingPackageDependencies());
36 36
 
Please login to merge, or discard this patch.
phpmetrics/src/Hal/Component/File/Finder.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -57,7 +57,7 @@  discard block
 block discarded – undo
57 57
         $this->excludedDirs = $excludedDirs;
58 58
         $this->flags = $flags;
59 59
         if ($flags === -1) {
60
-            $this->flags = FilesystemIterator::KEY_AS_PATHNAME | FilesystemIterator::CURRENT_AS_FILEINFO;
60
+            $this->flags = FilesystemIterator::KEY_AS_PATHNAME|FilesystemIterator::CURRENT_AS_FILEINFO;
61 61
         }
62 62
     }
63 63
 
@@ -72,15 +72,15 @@  discard block
 block discarded – undo
72 72
         $files = [];
73 73
         foreach ($paths as $path) {
74 74
             if (is_dir($path)) {
75
-                $path = rtrim($path, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR;
75
+                $path = rtrim($path, DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR;
76 76
                 $directory = new RecursiveDirectoryIterator($path, $this->flags);
77 77
                 $iterator = new RecursiveIteratorIterator($directory);
78 78
 
79 79
                 $filterRegex = sprintf(
80 80
                     '`^%s%s%s$`',
81 81
                     preg_quote($path, '`'),
82
-                    !empty($this->excludedDirs) ? '((?!' . implode('|', array_map('preg_quote', $this->excludedDirs)) . ').)+' : '.+',
83
-                    '\.(' . implode('|', $this->extensions) . ')'
82
+                    !empty($this->excludedDirs) ? '((?!'.implode('|', array_map('preg_quote', $this->excludedDirs)).').)+' : '.+',
83
+                    '\.('.implode('|', $this->extensions).')'
84 84
                 );
85 85
 
86 86
                 $filteredIterator = new RegexIterator(
Please login to merge, or discard this patch.