@@ -18,10 +18,10 @@ |
||
18 | 18 | |
19 | 19 | public function apply(Metric $metric) |
20 | 20 | { |
21 | - if (! $metric instanceof PackageMetric) { |
|
21 | + if (!$metric instanceof PackageMetric) { |
|
22 | 22 | return; |
23 | 23 | } |
24 | - if (abs($metric->getDistance()) > sqrt(2)/4) { |
|
24 | + if (abs($metric->getDistance()) > sqrt(2) / 4) { |
|
25 | 25 | $this->metric = $metric; |
26 | 26 | $metric->get('violations')->add($this); |
27 | 27 | } |
@@ -25,7 +25,7 @@ |
||
25 | 25 | |
26 | 26 | public function apply(Metric $metric) |
27 | 27 | { |
28 | - if (! $metric instanceof ClassMetric) { |
|
28 | + if (!$metric instanceof ClassMetric) { |
|
29 | 29 | return; |
30 | 30 | } |
31 | 31 |
@@ -25,7 +25,7 @@ |
||
25 | 25 | |
26 | 26 | public function apply(Metric $metric) |
27 | 27 | { |
28 | - if (! $metric instanceof ClassMetric) { |
|
28 | + if (!$metric instanceof ClassMetric) { |
|
29 | 29 | return; |
30 | 30 | } |
31 | 31 |
@@ -136,6 +136,9 @@ |
||
136 | 136 | } |
137 | 137 | } |
138 | 138 | |
139 | + /** |
|
140 | + * @param string|null $dependency |
|
141 | + */ |
|
139 | 142 | private function pushToDependencies(array &$dependencies, $dependency) |
140 | 143 | { |
141 | 144 | $lowercase = strtolower($dependency); |
@@ -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 | } |
@@ -1,4 +1,4 @@ discard block |
||
1 | -<?php require __DIR__ . '/_header.php'; ?> |
|
1 | +<?php require __DIR__.'/_header.php'; ?> |
|
2 | 2 | |
3 | 3 | |
4 | 4 | <?php |
@@ -19,10 +19,10 @@ discard block |
||
19 | 19 | |
20 | 20 | // 2. percentile map |
21 | 21 | $json = []; |
22 | -if(count($array) > 1) { |
|
22 | +if (count($array) > 1) { |
|
23 | 23 | $range = range(0.5, 1, .05); |
24 | 24 | foreach ($range as $percentile) { |
25 | - $json[] = (object)[ |
|
25 | + $json[] = (object) [ |
|
26 | 26 | 'lloc' => percentile($array, $percentile), |
27 | 27 | 'percentile' => round($percentile * 100), |
28 | 28 | ]; |
@@ -74,7 +74,7 @@ discard block |
||
74 | 74 | </div> |
75 | 75 | |
76 | 76 | |
77 | -<?php require __DIR__ . '/_footer.php'; ?> |
|
77 | +<?php require __DIR__.'/_footer.php'; ?> |
|
78 | 78 | |
79 | 79 | |
80 | 80 | <script> |
@@ -1,4 +1,4 @@ discard block |
||
1 | -<?php require __DIR__ . '/_header.php'; ?> |
|
1 | +<?php require __DIR__.'/_header.php'; ?> |
|
2 | 2 | |
3 | 3 | <?php |
4 | 4 | $map = [ |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | <tbody> |
58 | 58 | <?php foreach ($classes as $class) { |
59 | 59 | if (count($class['violations']) > 0) { |
60 | - $currentId = 'bloc-' . uniqid('', true); |
|
60 | + $currentId = 'bloc-'.uniqid('', true); |
|
61 | 61 | ?> |
62 | 62 | |
63 | 63 | <tr> |
@@ -108,7 +108,7 @@ discard block |
||
108 | 108 | <tbody> |
109 | 109 | <?php foreach ($packages as $package) { |
110 | 110 | if (count($package['violations']) > 0) { |
111 | - $currentId = 'bloc-' . uniqid(); |
|
111 | + $currentId = 'bloc-'.uniqid(); |
|
112 | 112 | ?> |
113 | 113 | |
114 | 114 | <tr> |
@@ -158,4 +158,4 @@ discard block |
||
158 | 158 | } |
159 | 159 | } |
160 | 160 | </script> |
161 | -<?php require __DIR__ . '/_footer.php'; ?> |
|
161 | +<?php require __DIR__.'/_footer.php'; ?> |
@@ -72,7 +72,7 @@ discard block |
||
72 | 72 | |
73 | 73 | // JUNIT format |
74 | 74 | foreach ($xpath->query('//testsuite[@file]') as $suite) { |
75 | - array_push($testsuites, (object)[ |
|
75 | + array_push($testsuites, (object) [ |
|
76 | 76 | 'file' => $suite->getAttribute('file'), |
77 | 77 | 'name' => $suite->getAttribute('name'), |
78 | 78 | 'assertions' => $suite->getAttribute('assertions'), |
@@ -101,7 +101,7 @@ discard block |
||
101 | 101 | $assertions = $case === $suite->firstChild->nextSibling ? $suite->getAttribute('assertions') : 0; |
102 | 102 | } |
103 | 103 | |
104 | - $testsuites[$case->getAttribute('class')] = (object)[ |
|
104 | + $testsuites[$case->getAttribute('class')] = (object) [ |
|
105 | 105 | 'file' => $case->getAttribute('file'), |
106 | 106 | 'name' => $case->getAttribute('class'), |
107 | 107 | 'assertions' => $assertions, |
@@ -120,7 +120,7 @@ discard block |
||
120 | 120 | $traverser->addVisitor(new ExternalsVisitor($metricsOfUnitTest)); |
121 | 121 | |
122 | 122 | if (!file_exists($suite->file) || !is_readable($suite->file)) { |
123 | - throw new \LogicException('Cannot find source file referenced in testsuite: ' . $suite->file); |
|
123 | + throw new \LogicException('Cannot find source file referenced in testsuite: '.$suite->file); |
|
124 | 124 | } |
125 | 125 | |
126 | 126 | $code = file_get_contents($suite->file); |
@@ -133,10 +133,10 @@ discard block |
||
133 | 133 | |
134 | 134 | // list of externals sources of unit test |
135 | 135 | $metric = $metricsOfUnitTest->get($suite->name); |
136 | - $externals = (array)$metric->get('externals'); |
|
136 | + $externals = (array) $metric->get('externals'); |
|
137 | 137 | |
138 | 138 | // global stats for each test |
139 | - $infoAboutTests[$suite->name] = (object)[ |
|
139 | + $infoAboutTests[$suite->name] = (object) [ |
|
140 | 140 | 'nbExternals' => count(array_unique($externals)), |
141 | 141 | 'externals' => array_unique($externals), |
142 | 142 | 'filename' => $suite->file, |
@@ -71,15 +71,15 @@ |
||
71 | 71 | $files = []; |
72 | 72 | foreach ($paths as $path) { |
73 | 73 | if (is_dir($path)) { |
74 | - $path = rtrim($path, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR; |
|
74 | + $path = rtrim($path, DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR; |
|
75 | 75 | $directory = new RecursiveDirectoryIterator($path, $this->flags); |
76 | 76 | $iterator = new RecursiveIteratorIterator($directory); |
77 | 77 | |
78 | 78 | $filterRegex = sprintf( |
79 | 79 | '`^%s%s%s$`', |
80 | 80 | preg_quote($path, '`'), |
81 | - !empty($this->excludedDirs) ? '((?!' . implode('|', array_map('preg_quote', $this->excludedDirs)) . ').)+' : '.+', |
|
82 | - '\.(' . implode('|', $this->extensions) . ')' |
|
81 | + !empty($this->excludedDirs) ? '((?!'.implode('|', array_map('preg_quote', $this->excludedDirs)).').)+' : '.+', |
|
82 | + '\.('.implode('|', $this->extensions).')' |
|
83 | 83 | ); |
84 | 84 | |
85 | 85 | $filteredIterator = new RegexIterator( |
@@ -64,7 +64,7 @@ |
||
64 | 64 | foreach ($node->stmts as $stmt) { |
65 | 65 | if ($stmt instanceof Stmt\ClassMethod) { |
66 | 66 | // iterate over children, recursively |
67 | - $cb = function ($node) use (&$cb) { |
|
67 | + $cb = function($node) use (&$cb) { |
|
68 | 68 | $ccn = 0; |
69 | 69 | |
70 | 70 | foreach (get_object_vars($node) as $name => $member) { |