@@ -60,13 +60,13 @@ |
||
60 | 60 | { |
61 | 61 | $graph = new GraphDeduplicated(); |
62 | 62 | |
63 | - array_map(static function (ClassMetric $metric) use ($graph): void { |
|
63 | + array_map(static function(ClassMetric $metric) use ($graph): void { |
|
64 | 64 | /** @var string $name */ |
65 | 65 | $name = $metric->get('name'); |
66 | 66 | $from = $graph->gather($name); |
67 | 67 | /** @var array<string> $externals */ |
68 | 68 | $externals = $metric->get('externals'); |
69 | - array_map(static function (string $external) use ($graph, $from): void { |
|
69 | + array_map(static function(string $external) use ($graph, $from): void { |
|
70 | 70 | $graph->addEdge($from, $graph->gather($external)); |
71 | 71 | }, $externals); |
72 | 72 | }, $this->metrics->getClassMetrics()); |
@@ -41,13 +41,13 @@ |
||
41 | 41 | { |
42 | 42 | $graph = new GraphDeduplicated(); |
43 | 43 | |
44 | - array_map(static function (ClassMetric $metric) use ($graph): void { |
|
44 | + array_map(static function(ClassMetric $metric) use ($graph): void { |
|
45 | 45 | /** @var string $name */ |
46 | 46 | $name = $metric->get('name'); |
47 | 47 | $to = $graph->gather($name); |
48 | 48 | /** @var array<string> $parents */ |
49 | 49 | $parents = $metric->get('parents'); |
50 | - array_map(static function (string $parent) use ($graph, $to): void { |
|
50 | + array_map(static function(string $parent) use ($graph, $to): void { |
|
51 | 51 | $graph->addEdge($graph->gather($parent), $to); |
52 | 52 | }, $parents); |
53 | 53 | }, $this->metrics->getClassMetrics()); |
@@ -21,10 +21,10 @@ discard block |
||
21 | 21 | public static function getClassName(Node $node): string |
22 | 22 | { |
23 | 23 | return match (true) { |
24 | - $node instanceof Node\Stmt\Class_ && $node->isAnonymous() => 'anonymous@' . spl_object_hash($node), |
|
24 | + $node instanceof Node\Stmt\Class_ && $node->isAnonymous() => 'anonymous@'.spl_object_hash($node), |
|
25 | 25 | property_exists($node, 'namespacedName') => $node->namespacedName->toString(), |
26 | 26 | property_exists($node, 'name') => $node->name->toString(), |
27 | - default => 'unknown@' . spl_object_hash($node) |
|
27 | + default => 'unknown@'.spl_object_hash($node) |
|
28 | 28 | }; |
29 | 29 | } |
30 | 30 | |
@@ -38,7 +38,7 @@ discard block |
||
38 | 38 | { |
39 | 39 | return match (true) { |
40 | 40 | property_exists($node, 'name') => $node->name->toString(), |
41 | - default => 'unknown@' . spl_object_hash($node) |
|
41 | + default => 'unknown@'.spl_object_hash($node) |
|
42 | 42 | }; |
43 | 43 | } |
44 | 44 | } |
@@ -56,8 +56,8 @@ |
||
56 | 56 | |
57 | 57 | // Attach ClassMethods to metrics. |
58 | 58 | if ($node instanceof Stmt\ClassLike) { |
59 | - array_map(function (Stmt\ClassMethod $stmt): void { |
|
60 | - $this->metrics->attach(new FunctionMetric((string)$stmt->name)); |
|
59 | + array_map(function(Stmt\ClassMethod $stmt): void { |
|
60 | + $this->metrics->attach(new FunctionMetric((string) $stmt->name)); |
|
61 | 61 | }, $node->getMethods()); |
62 | 62 | } |
63 | 63 |
@@ -98,13 +98,13 @@ |
||
98 | 98 | */ |
99 | 99 | public function detects(Node $node): null|string |
100 | 100 | { |
101 | - if (! $node instanceof Stmt\ClassMethod) { |
|
101 | + if (!$node instanceof Stmt\ClassMethod) { |
|
102 | 102 | return null; |
103 | 103 | } |
104 | 104 | |
105 | 105 | // Build a fingerprint of the given method |
106 | 106 | $fingerprintOfMethod = []; |
107 | - $this->nodeIterator->iterateOver($node, static function (Node $node) use (&$fingerprintOfMethod): void { |
|
107 | + $this->nodeIterator->iterateOver($node, static function(Node $node) use (&$fingerprintOfMethod): void { |
|
108 | 108 | // Ignore identifier, cast, type hint, nullable type, and PHP Attributes. |
109 | 109 | if ( |
110 | 110 | $node instanceof Node\Identifier |
@@ -32,7 +32,7 @@ discard block |
||
32 | 32 | public function enterNode(Node $node): null|int|Node // TODO PHP 8.2: only return null here. |
33 | 33 | { |
34 | 34 | if ($node instanceof Stmt\Namespace_) { |
35 | - $this->namespace = (string)$node->name; |
|
35 | + $this->namespace = (string) $node->name; |
|
36 | 36 | } |
37 | 37 | |
38 | 38 | return null; |
@@ -55,15 +55,15 @@ discard block |
||
55 | 55 | |
56 | 56 | $package = $this->namespace; |
57 | 57 | |
58 | - $docBlockText = (string)$node->getDocComment()?->getText(); |
|
58 | + $docBlockText = (string) $node->getDocComment()?->getText(); |
|
59 | 59 | if (1 === preg_match('/^\s*\*\s*@package\s+(.*)/m', $docBlockText, $matches)) { |
60 | 60 | $package = $matches[1]; |
61 | 61 | } |
62 | 62 | if (1 === preg_match('/^\s*\*\s*@subpackage\s+(.*)/m', $docBlockText, $matches)) { |
63 | - $package .= '\\' . $matches[1]; |
|
63 | + $package .= '\\'.$matches[1]; |
|
64 | 64 | } |
65 | 65 | |
66 | - $packageName = $package . '\\'; |
|
66 | + $packageName = $package.'\\'; |
|
67 | 67 | if (!$this->metrics->has($packageName)) { |
68 | 68 | $this->metrics->attach(new PackageMetric($packageName)); |
69 | 69 | } |
@@ -24,7 +24,7 @@ |
||
24 | 24 | */ |
25 | 25 | public function calculate(): void |
26 | 26 | { |
27 | - array_map(static function (PackageMetric $package): void { |
|
27 | + array_map(static function(PackageMetric $package): void { |
|
28 | 28 | if (null === $package->getAbstraction() || null === $package->getInstability()) { |
29 | 29 | return; |
30 | 30 | } |
@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | */ |
24 | 24 | public function calculate(): void |
25 | 25 | { |
26 | - array_map(function (PackageMetric $package): void { |
|
26 | + array_map(function(PackageMetric $package): void { |
|
27 | 27 | $classesInPackage = $package->getClasses(); |
28 | 28 | if ([] === $classesInPackage) { |
29 | 29 | return; |
@@ -41,6 +41,6 @@ discard block |
||
41 | 41 | */ |
42 | 42 | private function isAbstract(string $classname): bool |
43 | 43 | { |
44 | - return (bool)$this->metrics->get($classname)?->get('abstract'); |
|
44 | + return (bool) $this->metrics->get($classname)?->get('abstract'); |
|
45 | 45 | } |
46 | 46 | } |
@@ -59,13 +59,13 @@ discard block |
||
59 | 59 | } |
60 | 60 | |
61 | 61 | // sums |
62 | - $sum = (object)[ |
|
62 | + $sum = (object) [ |
|
63 | 63 | 'loc' => 0, |
64 | 64 | 'cloc' => 0, |
65 | 65 | 'lloc' => 0, |
66 | 66 | 'nbMethods' => 0, |
67 | 67 | ]; |
68 | - $avg = (object)[ |
|
68 | + $avg = (object) [ |
|
69 | 69 | 'wmc' => [], |
70 | 70 | 'ccn' => [], |
71 | 71 | 'bugs' => [], |
@@ -136,8 +136,8 @@ discard block |
||
136 | 136 | 'error' => 0, |
137 | 137 | 'critical' => 0, |
138 | 138 | ]; |
139 | - $violationCounter = static function (array $elementViolations) use (&$violations): void { |
|
140 | - array_map(static function (Violation $violation) use (&$violations): void { |
|
139 | + $violationCounter = static function(array $elementViolations) use (&$violations): void { |
|
140 | + array_map(static function(Violation $violation) use (&$violations): void { |
|
141 | 141 | $violations['total']++; |
142 | 142 | $name = [ |
143 | 143 | Violation::INFO => 'information', |
@@ -154,7 +154,7 @@ discard block |
||
154 | 154 | $violationHandler = $element['violations']; |
155 | 155 | $violationCounter($violationHandler->getAll()); |
156 | 156 | } |
157 | - $sum->violations = (object)$violations; |
|
157 | + $sum->violations = (object) $violations; |
|
158 | 158 | |
159 | 159 | $this->avg = $avg; |
160 | 160 | $this->sum = $sum; |