@@ -17,7 +17,6 @@ |
||
17 | 17 | public static function getName(Node $node) |
18 | 18 | { |
19 | 19 | return ($node instanceof Node\Stmt\Class_ && $node->isAnonymous()) ? |
20 | - 'anonymous@' . spl_object_hash($node) : |
|
21 | - $node->namespacedName->toString(); |
|
20 | + 'anonymous@'.spl_object_hash($node) : $node->namespacedName->toString(); |
|
22 | 21 | } |
23 | 22 | } |
@@ -22,7 +22,7 @@ |
||
22 | 22 | /** |
23 | 23 | * Reporter constructor. |
24 | 24 | * @param Config $config |
25 | - * @param OutputInterface $output |
|
25 | + * @param Output $output |
|
26 | 26 | */ |
27 | 27 | public function __construct(Config $config, Output $output) |
28 | 28 | { |
@@ -44,7 +44,7 @@ |
||
44 | 44 | return; |
45 | 45 | } |
46 | 46 | if (!file_exists(dirname($logFile)) || !is_writable(dirname($logFile))) { |
47 | - throw new \RuntimeException('You don\'t have permissions to write CSV report in ' . $logFile); |
|
47 | + throw new \RuntimeException('You don\'t have permissions to write CSV report in '.$logFile); |
|
48 | 48 | } |
49 | 49 | |
50 | 50 | $availables = (new Registry())->allForStructures(); |
@@ -42,7 +42,7 @@ |
||
42 | 42 | return; |
43 | 43 | } |
44 | 44 | if (!file_exists(dirname($logFile)) || !is_writable(dirname($logFile))) { |
45 | - throw new \RuntimeException('You don\'t have permissions to write JSON report in ' . $logFile); |
|
45 | + throw new \RuntimeException('You don\'t have permissions to write JSON report in '.$logFile); |
|
46 | 46 | } |
47 | 47 | |
48 | 48 | file_put_contents($logFile, json_encode($metrics, JSON_PRETTY_PRINT)); |
@@ -1,9 +1,7 @@ |
||
1 | 1 | <?php |
2 | 2 | namespace Hal\Metric\Class_\Component; |
3 | 3 | |
4 | -use Hal\Metric\FunctionMetric; |
|
5 | 4 | use Hal\Metric\Metrics; |
6 | -use Hoa\Ruler\Model\Bag\Scalar; |
|
7 | 5 | use PhpParser\Node; |
8 | 6 | use PhpParser\Node\Stmt; |
9 | 7 | use PhpParser\NodeVisitorAbstract; |
@@ -78,7 +78,7 @@ |
||
78 | 78 | $metrics = new Metrics(); |
79 | 79 | |
80 | 80 | // traverse all |
81 | - $whenToStop = function () { |
|
81 | + $whenToStop = function() { |
|
82 | 82 | return true; |
83 | 83 | }; |
84 | 84 |
@@ -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 | } |
@@ -36,7 +36,7 @@ |
||
36 | 36 | |
37 | 37 | // get latest version |
38 | 38 | $latest = '0.0.0'; |
39 | - foreach ((array)$json->package->versions as $version => $datas) { |
|
39 | + foreach ((array) $json->package->versions as $version => $datas) { |
|
40 | 40 | if ($version[0] === 'v') { |
41 | 41 | $version = substr($version, 1); |
42 | 42 | } |
@@ -63,20 +63,20 @@ discard block |
||
63 | 63 | // extends |
64 | 64 | if (isset($node->extends)) { |
65 | 65 | if (is_array($node->extends)) { |
66 | - foreach ((array)$node->extends as $interface) { |
|
67 | - array_push($dependencies, (string)$interface); |
|
68 | - array_push($parents, (string)$interface); |
|
66 | + foreach ((array) $node->extends as $interface) { |
|
67 | + array_push($dependencies, (string) $interface); |
|
68 | + array_push($parents, (string) $interface); |
|
69 | 69 | } |
70 | 70 | } else { |
71 | - array_push($dependencies, (string)$node->extends); |
|
72 | - array_push($parents, (string)$node->extends); |
|
71 | + array_push($dependencies, (string) $node->extends); |
|
72 | + array_push($parents, (string) $node->extends); |
|
73 | 73 | } |
74 | 74 | } |
75 | 75 | |
76 | 76 | // implements |
77 | 77 | if (isset($node->implements)) { |
78 | 78 | foreach ($node->implements as $interface) { |
79 | - array_push($dependencies, (string)$interface); |
|
79 | + array_push($dependencies, (string) $interface); |
|
80 | 80 | } |
81 | 81 | } |
82 | 82 | |
@@ -85,7 +85,7 @@ discard block |
||
85 | 85 | // return |
86 | 86 | if (isset($stmt->returnType)) { |
87 | 87 | if ($stmt->returnType instanceof Node\Name\FullyQualified) { |
88 | - array_push($dependencies, (string)$stmt->returnType); |
|
88 | + array_push($dependencies, (string) $stmt->returnType); |
|
89 | 89 | } |
90 | 90 | } |
91 | 91 | |
@@ -93,13 +93,13 @@ discard block |
||
93 | 93 | foreach ($stmt->params as $param) { |
94 | 94 | if ($param->type) { |
95 | 95 | if ($param->type instanceof Node\Name\FullyQualified) { |
96 | - array_push($dependencies, (string)$param->type); |
|
96 | + array_push($dependencies, (string) $param->type); |
|
97 | 97 | } |
98 | 98 | } |
99 | 99 | } |
100 | 100 | |
101 | 101 | // instantiations, static calls |
102 | - \iterate_over_node($stmt, function ($node) use (&$dependencies) { |
|
102 | + \iterate_over_node($stmt, function($node) use (&$dependencies) { |
|
103 | 103 | switch (true) { |
104 | 104 | case $node instanceof Node\Expr\New_: |
105 | 105 | // new MyClass |
@@ -119,12 +119,12 @@ discard block |
||
119 | 119 | foreach ($this->uses as $use) { |
120 | 120 | if (method_exists($use, 'getAlias')) { |
121 | 121 | if (((string) $use->getAlias()) === $check) { |
122 | - array_push($dependencies, (string)($use->name)); |
|
122 | + array_push($dependencies, (string) ($use->name)); |
|
123 | 123 | } |
124 | 124 | continue; |
125 | 125 | } |
126 | 126 | if ($use->alias === $check) { |
127 | - array_push($dependencies, (string)($use->name)); |
|
127 | + array_push($dependencies, (string) ($use->name)); |
|
128 | 128 | } |
129 | 129 | } |
130 | 130 | } |
@@ -81,13 +81,13 @@ |
||
81 | 81 | */ |
82 | 82 | public function detects($node) |
83 | 83 | { |
84 | - if (! $node instanceof ClassMethod) { |
|
84 | + if (!$node instanceof ClassMethod) { |
|
85 | 85 | return null; |
86 | 86 | } |
87 | 87 | |
88 | 88 | // build a fingerprint of the given method |
89 | 89 | $fingerprintOfMethod = []; |
90 | - iterate_over_node($node, function ($node) use (&$fingerprintOfMethod) { |
|
90 | + iterate_over_node($node, function($node) use (&$fingerprintOfMethod) { |
|
91 | 91 | |
92 | 92 | // avoid identifier (php-parser:^4) |
93 | 93 | if ($node instanceof Identifier) { |