@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | $class->set('interface', true); |
38 | 38 | $class->set('abstract', true); |
39 | 39 | } else { |
40 | - $name = (string)(isset($node->namespacedName) ? $node->namespacedName : 'anonymous@' . spl_object_hash($node)); |
|
40 | + $name = (string) (isset($node->namespacedName) ? $node->namespacedName : 'anonymous@'.spl_object_hash($node)); |
|
41 | 41 | $class = new ClassMetric($name); |
42 | 42 | $class->set('interface', false); |
43 | 43 | $class->set('abstract', $node instanceof Stmt\Trait_ || $node->isAbstract()); |
@@ -50,7 +50,7 @@ discard block |
||
50 | 50 | $roleDetector = new RoleOfMethodDetector(); |
51 | 51 | foreach ($node->stmts as $stmt) { |
52 | 52 | if ($stmt instanceof Stmt\ClassMethod) { |
53 | - $function = new FunctionMetric((string)$stmt->name); |
|
53 | + $function = new FunctionMetric((string) $stmt->name); |
|
54 | 54 | |
55 | 55 | $role = $roleDetector->detects($stmt); |
56 | 56 | $function->set('role', $role); |
@@ -47,7 +47,7 @@ |
||
47 | 47 | public function leaveNode(Node $node) |
48 | 48 | { |
49 | 49 | if ($node instanceof Stmt\Class_ || $node instanceof Stmt\Trait_) { |
50 | - $name = (string)(isset($node->namespacedName) ? $node->namespacedName : 'anonymous@' . spl_object_hash($node)); |
|
50 | + $name = (string) (isset($node->namespacedName) ? $node->namespacedName : 'anonymous@'.spl_object_hash($node)); |
|
51 | 51 | $classOrFunction = $this->metrics->get($name); |
52 | 52 | |
53 | 53 | if (null === $lloc = $classOrFunction->get('lloc')) { |
@@ -58,20 +58,20 @@ discard block |
||
58 | 58 | // extends |
59 | 59 | if (isset($node->extends)) { |
60 | 60 | if (is_array($node->extends)) { |
61 | - foreach ((array)$node->extends as $interface) { |
|
62 | - $this->pushToDependencies($dependencies, (string)$interface); |
|
63 | - array_push($parents, (string)$interface); |
|
61 | + foreach ((array) $node->extends as $interface) { |
|
62 | + $this->pushToDependencies($dependencies, (string) $interface); |
|
63 | + array_push($parents, (string) $interface); |
|
64 | 64 | } |
65 | 65 | } else { |
66 | - $this->pushToDependencies($dependencies, (string)$node->extends); |
|
67 | - array_push($parents, (string)$node->extends); |
|
66 | + $this->pushToDependencies($dependencies, (string) $node->extends); |
|
67 | + array_push($parents, (string) $node->extends); |
|
68 | 68 | } |
69 | 69 | } |
70 | 70 | |
71 | 71 | // implements |
72 | 72 | if (isset($node->implements)) { |
73 | 73 | foreach ($node->implements as $interface) { |
74 | - $this->pushToDependencies($dependencies, (string)$interface); |
|
74 | + $this->pushToDependencies($dependencies, (string) $interface); |
|
75 | 75 | } |
76 | 76 | } |
77 | 77 | |
@@ -80,7 +80,7 @@ discard block |
||
80 | 80 | // return |
81 | 81 | if (isset($stmt->returnType)) { |
82 | 82 | if ($stmt->returnType instanceof Node\Name\FullyQualified) { |
83 | - $this->pushToDependencies($dependencies, (string)$stmt->returnType); |
|
83 | + $this->pushToDependencies($dependencies, (string) $stmt->returnType); |
|
84 | 84 | } |
85 | 85 | } |
86 | 86 | |
@@ -88,13 +88,13 @@ discard block |
||
88 | 88 | foreach ($stmt->params as $param) { |
89 | 89 | if ($param->type) { |
90 | 90 | if ($param->type instanceof Node\Name\FullyQualified) { |
91 | - $this->pushToDependencies($dependencies, (string)$param->type); |
|
91 | + $this->pushToDependencies($dependencies, (string) $param->type); |
|
92 | 92 | } |
93 | 93 | } |
94 | 94 | } |
95 | 95 | |
96 | 96 | // instantiations, static calls |
97 | - \iterate_over_node($stmt, function ($node) use (&$dependencies) { |
|
97 | + \iterate_over_node($stmt, function($node) use (&$dependencies) { |
|
98 | 98 | switch (true) { |
99 | 99 | case $node instanceof Node\Expr\New_: |
100 | 100 | // new MyClass |
@@ -113,13 +113,13 @@ discard block |
||
113 | 113 | foreach ($matches[1] as $check) { |
114 | 114 | foreach ($this->uses as $use) { |
115 | 115 | if (method_exists($use, 'getAlias')) { |
116 | - if (((string)$use->getAlias()) === $check) { |
|
117 | - $this->pushToDependencies($dependencies, (string)($use->name)); |
|
116 | + if (((string) $use->getAlias()) === $check) { |
|
117 | + $this->pushToDependencies($dependencies, (string) ($use->name)); |
|
118 | 118 | } |
119 | 119 | continue; |
120 | 120 | } |
121 | 121 | if ($use->alias === $check) { |
122 | - $this->pushToDependencies($dependencies, (string)($use->name)); |
|
122 | + $this->pushToDependencies($dependencies, (string) ($use->name)); |
|
123 | 123 | } |
124 | 124 | } |
125 | 125 | } |
@@ -138,6 +138,6 @@ discard block |
||
138 | 138 | if ('self' === $lowercase || 'parent' === $lowercase) { |
139 | 139 | return; |
140 | 140 | } |
141 | - array_push($dependencies, (string)$dependency); |
|
141 | + array_push($dependencies, (string) $dependency); |
|
142 | 142 | } |
143 | 143 | } |
@@ -44,10 +44,10 @@ discard block |
||
44 | 44 | { |
45 | 45 | if ($node instanceof Stmt\Class_ || $node instanceof Stmt\Function_ || $node instanceof Stmt\Trait_) { |
46 | 46 | if ($node instanceof Stmt\Class_ || $node instanceof Stmt\Trait_) { |
47 | - $name = (string)(isset($node->namespacedName) ? $node->namespacedName : 'anonymous@' . spl_object_hash($node)); |
|
47 | + $name = (string) (isset($node->namespacedName) ? $node->namespacedName : 'anonymous@'.spl_object_hash($node)); |
|
48 | 48 | $classOrFunction = $this->metrics->get($name); |
49 | 49 | } else { |
50 | - $classOrFunction = new FunctionMetric((string)$node->name); |
|
50 | + $classOrFunction = new FunctionMetric((string) $node->name); |
|
51 | 51 | $this->metrics->attach($classOrFunction); |
52 | 52 | } |
53 | 53 | |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | $operands = []; |
56 | 56 | $operators = []; |
57 | 57 | |
58 | - iterate_over_node($node, function ($node) use (&$operators, &$operands) { |
|
58 | + iterate_over_node($node, function($node) use (&$operators, &$operands) { |
|
59 | 59 | if ($node instanceof Node\Expr\BinaryOp |
60 | 60 | || $node instanceof Node\Expr\AssignOp |
61 | 61 | || $node instanceof Stmt\If_ |
@@ -34,10 +34,10 @@ discard block |
||
34 | 34 | { |
35 | 35 | if ($node instanceof Stmt\Class_ || $node instanceof Stmt\Function_ || $node instanceof Stmt\Trait_) { |
36 | 36 | if ($node instanceof Stmt\Class_ || $node instanceof Stmt\Trait_) { |
37 | - $name = (string)(isset($node->namespacedName) ? $node->namespacedName : 'anonymous@' . spl_object_hash($node)); |
|
37 | + $name = (string) (isset($node->namespacedName) ? $node->namespacedName : 'anonymous@'.spl_object_hash($node)); |
|
38 | 38 | $classOrFunction = $this->metrics->get($name); |
39 | 39 | } else { |
40 | - $classOrFunction = new FunctionMetric((string)$node->name); |
|
40 | + $classOrFunction = new FunctionMetric((string) $node->name); |
|
41 | 41 | $this->metrics->attach($classOrFunction); |
42 | 42 | } |
43 | 43 | |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | $code = preg_replace('!/\*.*?\*/!s', '', $code); |
58 | 58 | |
59 | 59 | // count and remove single line comments |
60 | - $code = preg_replace_callback('!(\'[^\']*\'|"[^"]*")|((?:#|\/\/).*$)!m', function (array $matches) use (&$cloc) { |
|
60 | + $code = preg_replace_callback('!(\'[^\']*\'|"[^"]*")|((?:#|\/\/).*$)!m', function(array $matches) use (&$cloc) { |
|
61 | 61 | if (isset($matches[2])) { |
62 | 62 | $cloc += 1; |
63 | 63 | } |
@@ -42,12 +42,12 @@ discard block |
||
42 | 42 | |
43 | 43 | foreach ($node->stmts as $stmt) { |
44 | 44 | if ($stmt instanceof Stmt\ClassMethod) { |
45 | - if (!$graph->has($stmt->name . '()')) { |
|
46 | - $graph->insert(new TreeNode($stmt->name . '()')); |
|
45 | + if (!$graph->has($stmt->name.'()')) { |
|
46 | + $graph->insert(new TreeNode($stmt->name.'()')); |
|
47 | 47 | } |
48 | - $from = $graph->get($stmt->name . '()'); |
|
48 | + $from = $graph->get($stmt->name.'()'); |
|
49 | 49 | |
50 | - \iterate_over_node($stmt, function ($node) use ($from, &$graph) { |
|
50 | + \iterate_over_node($stmt, function($node) use ($from, &$graph) { |
|
51 | 51 | if ($node instanceof Node\Expr\PropertyFetch && isset($node->var->name) && $node->var->name == 'this') { |
52 | 52 | $name = getNameOfNode($node); |
53 | 53 | // use of attribute $this->xxx; |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | if (!$node->var instanceof Node\Expr\New_ && isset($node->var->name) && getNameOfNode($node->var) === 'this') { |
64 | 64 | // use of method call $this->xxx(); |
65 | 65 | // use of attribute $this->xxx; |
66 | - $name = getNameOfNode($node->name) . '()'; |
|
66 | + $name = getNameOfNode($node->name).'()'; |
|
67 | 67 | if (!$graph->has($name)) { |
68 | 68 | $graph->insert(new TreeNode($name)); |
69 | 69 | } |
@@ -27,7 +27,7 @@ discard block |
||
27 | 27 | public function enterNode(Node $node) |
28 | 28 | { |
29 | 29 | if ($node instanceof Namespace_) { |
30 | - $this->namespace = (string)$node->name; |
|
30 | + $this->namespace = (string) $node->name; |
|
31 | 31 | } |
32 | 32 | } |
33 | 33 | |
@@ -42,17 +42,17 @@ discard block |
||
42 | 42 | $package = $matches[1]; |
43 | 43 | } |
44 | 44 | if (preg_match('/^\s*\* @subpackage (.*)/m', $docBlockText, $matches)) { |
45 | - $package = $package . '\\' . $matches[1]; |
|
45 | + $package = $package.'\\'.$matches[1]; |
|
46 | 46 | } |
47 | 47 | |
48 | - $packageName = $package . '\\'; |
|
49 | - if (! $packageMetric = $this->metrics->get($packageName)) { |
|
48 | + $packageName = $package.'\\'; |
|
49 | + if (!$packageMetric = $this->metrics->get($packageName)) { |
|
50 | 50 | $packageMetric = new PackageMetric($packageName); |
51 | 51 | $this->metrics->attach($packageMetric); |
52 | 52 | } |
53 | 53 | /* @var PackageMetric $packageMetric */ |
54 | - $elementName = isset($node->namespacedName) ? $node->namespacedName : 'anonymous@' . spl_object_hash($node); |
|
55 | - $elementName = (string)$elementName; |
|
54 | + $elementName = isset($node->namespacedName) ? $node->namespacedName : 'anonymous@'.spl_object_hash($node); |
|
55 | + $elementName = (string) $elementName; |
|
56 | 56 | $packageMetric->addClass($elementName); |
57 | 57 | |
58 | 58 | $this->metrics->get($elementName)->set('package', $packageName); |
@@ -18,7 +18,7 @@ discard block |
||
18 | 18 | public function addClass($name) |
19 | 19 | { |
20 | 20 | $elements = $this->get('classes'); |
21 | - $elements[] = (string)$name; |
|
21 | + $elements[] = (string) $name; |
|
22 | 22 | $this->set('classes', $elements); |
23 | 23 | } |
24 | 24 | |
@@ -26,7 +26,7 @@ discard block |
||
26 | 26 | public function setAbstraction($abstraction) |
27 | 27 | { |
28 | 28 | if ($abstraction !== null) { |
29 | - $abstraction = (float)$abstraction; |
|
29 | + $abstraction = (float) $abstraction; |
|
30 | 30 | } |
31 | 31 | $this->set('abstraction', $abstraction); |
32 | 32 | } |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | public function setInstability($instability) |
42 | 42 | { |
43 | 43 | if ($instability !== null) { |
44 | - $instability = (float)$instability; |
|
44 | + $instability = (float) $instability; |
|
45 | 45 | } |
46 | 46 | $this->set('instability', $instability); |
47 | 47 | } |
@@ -63,11 +63,11 @@ discard block |
||
63 | 63 | } |
64 | 64 | $classDependencies = $this->getOutgoingClassDependencies(); |
65 | 65 | $packageDependencies = $this->getOutgoingPackageDependencies(); |
66 | - if (! in_array($className, $classDependencies)) { |
|
66 | + if (!in_array($className, $classDependencies)) { |
|
67 | 67 | $classDependencies[] = $className; |
68 | 68 | $this->set('outgoing_class_dependencies', $classDependencies); |
69 | 69 | } |
70 | - if (! in_array($packageName, $packageDependencies)) { |
|
70 | + if (!in_array($packageName, $packageDependencies)) { |
|
71 | 71 | $packageDependencies[] = $packageName; |
72 | 72 | $this->set('outgoing_package_dependencies', $packageDependencies); |
73 | 73 | } |
@@ -96,11 +96,11 @@ discard block |
||
96 | 96 | } |
97 | 97 | $classDependencies = $this->getIncomingClassDependencies(); |
98 | 98 | $packageDependencies = $this->getIncomingPackageDependencies(); |
99 | - if (! in_array($className, $classDependencies)) { |
|
99 | + if (!in_array($className, $classDependencies)) { |
|
100 | 100 | $classDependencies[] = $className; |
101 | 101 | $this->set('incoming_class_dependencies', $classDependencies); |
102 | 102 | } |
103 | - if (! in_array($packageName, $packageDependencies)) { |
|
103 | + if (!in_array($packageName, $packageDependencies)) { |
|
104 | 104 | $packageDependencies[] = $packageName; |
105 | 105 | $this->set('incoming_package_dependencies', $packageDependencies); |
106 | 106 | } |
@@ -41,11 +41,11 @@ discard block |
||
41 | 41 | $consolidated = new Consolidated($metrics); |
42 | 42 | |
43 | 43 | // history of builds |
44 | - $today = (object)[ |
|
44 | + $today = (object) [ |
|
45 | 45 | 'avg' => $consolidated->getAvg(), |
46 | 46 | 'sum' => $consolidated->getSum() |
47 | 47 | ]; |
48 | - $files = glob($logDir . '/js/history-*.json'); |
|
48 | + $files = glob($logDir.'/js/history-*.json'); |
|
49 | 49 | $next = count($files) + 1; |
50 | 50 | $history = []; |
51 | 51 | natsort($files); |
@@ -54,39 +54,39 @@ discard block |
||
54 | 54 | } |
55 | 55 | |
56 | 56 | // copy sources |
57 | - if (!file_exists($logDir . '/js')) { |
|
58 | - mkdir($logDir . '/js', 0755, true); |
|
57 | + if (!file_exists($logDir.'/js')) { |
|
58 | + mkdir($logDir.'/js', 0755, true); |
|
59 | 59 | } |
60 | - if (!file_exists($logDir . '/css')) { |
|
61 | - mkdir($logDir . '/css', 0755, true); |
|
60 | + if (!file_exists($logDir.'/css')) { |
|
61 | + mkdir($logDir.'/css', 0755, true); |
|
62 | 62 | } |
63 | - if (!file_exists($logDir . '/images')) { |
|
64 | - mkdir($logDir . '/images', 0755, true); |
|
63 | + if (!file_exists($logDir.'/images')) { |
|
64 | + mkdir($logDir.'/images', 0755, true); |
|
65 | 65 | } |
66 | - if (!file_exists($logDir . '/fonts')) { |
|
67 | - mkdir($logDir . '/fonts', 0755, true); |
|
66 | + if (!file_exists($logDir.'/fonts')) { |
|
67 | + mkdir($logDir.'/fonts', 0755, true); |
|
68 | 68 | } |
69 | - recurse_copy(__DIR__ . '/template/js', $logDir . '/js'); |
|
70 | - recurse_copy(__DIR__ . '/template/css', $logDir . '/css'); |
|
71 | - recurse_copy(__DIR__ . '/template/images', $logDir . '/images'); |
|
72 | - recurse_copy(__DIR__ . '/template/fonts', $logDir . '/fonts'); |
|
69 | + recurse_copy(__DIR__.'/template/js', $logDir.'/js'); |
|
70 | + recurse_copy(__DIR__.'/template/css', $logDir.'/css'); |
|
71 | + recurse_copy(__DIR__.'/template/images', $logDir.'/images'); |
|
72 | + recurse_copy(__DIR__.'/template/fonts', $logDir.'/fonts'); |
|
73 | 73 | |
74 | 74 | // render dynamic pages |
75 | - $this->renderPage(__DIR__ . '/template/index.php', $logDir . '/index.html', $consolidated, $history); |
|
76 | - $this->renderPage(__DIR__ . '/template/loc.php', $logDir . '/loc.html', $consolidated, $history); |
|
77 | - $this->renderPage(__DIR__ . '/template/relations.php', $logDir . '/relations.html', $consolidated, $history); |
|
78 | - $this->renderPage(__DIR__ . '/template/coupling.php', $logDir . '/coupling.html', $consolidated, $history); |
|
79 | - $this->renderPage(__DIR__ . '/template/all.php', $logDir . '/all.html', $consolidated, $history); |
|
80 | - $this->renderPage(__DIR__ . '/template/oop.php', $logDir . '/oop.html', $consolidated, $history); |
|
81 | - $this->renderPage(__DIR__ . '/template/complexity.php', $logDir . '/complexity.html', $consolidated, $history); |
|
82 | - $this->renderPage(__DIR__ . '/template/panel.php', $logDir . '/panel.html', $consolidated, $history); |
|
83 | - $this->renderPage(__DIR__ . '/template/violations.php', $logDir . '/violations.html', $consolidated, $history); |
|
84 | - $this->renderPage(__DIR__ . '/template/packages.php', $logDir . '/packages.html', $consolidated, $history); |
|
85 | - $this->renderPage(__DIR__ . '/template/package_relations.php', $logDir . '/package_relations.html', $consolidated, $history); |
|
75 | + $this->renderPage(__DIR__.'/template/index.php', $logDir.'/index.html', $consolidated, $history); |
|
76 | + $this->renderPage(__DIR__.'/template/loc.php', $logDir.'/loc.html', $consolidated, $history); |
|
77 | + $this->renderPage(__DIR__.'/template/relations.php', $logDir.'/relations.html', $consolidated, $history); |
|
78 | + $this->renderPage(__DIR__.'/template/coupling.php', $logDir.'/coupling.html', $consolidated, $history); |
|
79 | + $this->renderPage(__DIR__.'/template/all.php', $logDir.'/all.html', $consolidated, $history); |
|
80 | + $this->renderPage(__DIR__.'/template/oop.php', $logDir.'/oop.html', $consolidated, $history); |
|
81 | + $this->renderPage(__DIR__.'/template/complexity.php', $logDir.'/complexity.html', $consolidated, $history); |
|
82 | + $this->renderPage(__DIR__.'/template/panel.php', $logDir.'/panel.html', $consolidated, $history); |
|
83 | + $this->renderPage(__DIR__.'/template/violations.php', $logDir.'/violations.html', $consolidated, $history); |
|
84 | + $this->renderPage(__DIR__.'/template/packages.php', $logDir.'/packages.html', $consolidated, $history); |
|
85 | + $this->renderPage(__DIR__.'/template/package_relations.php', $logDir.'/package_relations.html', $consolidated, $history); |
|
86 | 86 | if ($this->config->has('git')) { |
87 | - $this->renderPage(__DIR__ . '/template/git.php', $logDir . '/git.html', $consolidated, $history); |
|
87 | + $this->renderPage(__DIR__.'/template/git.php', $logDir.'/git.html', $consolidated, $history); |
|
88 | 88 | } |
89 | - $this->renderPage(__DIR__ . '/template/junit.php', $logDir . '/junit.html', $consolidated, $history); |
|
89 | + $this->renderPage(__DIR__.'/template/junit.php', $logDir.'/junit.html', $consolidated, $history); |
|
90 | 90 | |
91 | 91 | // js data |
92 | 92 | file_put_contents( |
@@ -100,8 +100,8 @@ discard block |
||
100 | 100 | |
101 | 101 | // json data |
102 | 102 | file_put_contents( |
103 | - $logDir . '/js/classes.js', |
|
104 | - 'var classes = ' . json_encode($consolidated->getClasses(), JSON_PRETTY_PRINT) |
|
103 | + $logDir.'/js/classes.js', |
|
104 | + 'var classes = '.json_encode($consolidated->getClasses(), JSON_PRETTY_PRINT) |
|
105 | 105 | ); |
106 | 106 | |
107 | 107 | $this->output->writeln(sprintf('HTML report generated in "%s" directory', $logDir)); |
@@ -168,7 +168,7 @@ discard block |
||
168 | 168 | |
169 | 169 | $diff = $newValue - $oldValue; |
170 | 170 | if ($diff > 0) { |
171 | - $diff = '+' . $diff; |
|
171 | + $diff = '+'.$diff; |
|
172 | 172 | } |
173 | 173 | |
174 | 174 | $goodOrBad = 'neutral'; |