@@ -62,7 +62,7 @@ discard block |
||
62 | 62 | |
63 | 63 | $rawRequirements = $this->getComposerJsonRequirements(); |
64 | 64 | // Exclude PHP itself and extensions. |
65 | - $rawRequirements = array_filter($rawRequirements, static function (string $package): bool { |
|
65 | + $rawRequirements = array_filter($rawRequirements, static function(string $package): bool { |
|
66 | 66 | return 'php' !== strtolower($package) && !str_starts_with($package, 'ext-'); |
67 | 67 | }, ARRAY_FILTER_USE_KEY); |
68 | 68 | $rawInstalled = $this->getComposerLockInstalled(array_keys($rawRequirements)); |
@@ -95,7 +95,7 @@ discard block |
||
95 | 95 | */ |
96 | 96 | private function getComposerJsonRequirements(): array |
97 | 97 | { |
98 | - $rawRequirements = array_map(function (string $filename): array { |
|
98 | + $rawRequirements = array_map(function(string $filename): array { |
|
99 | 99 | if (!str_contains($filename, 'composer.json') && !str_contains($filename, 'composer-dist.json')) { |
100 | 100 | return []; |
101 | 101 | } |
@@ -115,7 +115,7 @@ discard block |
||
115 | 115 | */ |
116 | 116 | private function getComposerLockInstalled(array $rootPackageRequired): array |
117 | 117 | { |
118 | - $rawInstalled = array_map(function (string $filename) use ($rootPackageRequired): array { |
|
118 | + $rawInstalled = array_map(function(string $filename) use ($rootPackageRequired): array { |
|
119 | 119 | if (!str_contains($filename, 'composer.lock')) { |
120 | 120 | return []; |
121 | 121 | } |
@@ -127,7 +127,7 @@ discard block |
||
127 | 127 | // Then normalize the version format. |
128 | 128 | $installed = array_column($composerLock['packages'], 'version', 'name'); |
129 | 129 | $installed = array_intersect_key($installed, array_flip($rootPackageRequired)); |
130 | - array_walk($installed, static function (string &$packageVersion): void { |
|
130 | + array_walk($installed, static function(string &$packageVersion): void { |
|
131 | 131 | $packageVersion = preg_replace('#[^.\d]#', '', $packageVersion); |
132 | 132 | }); |
133 | 133 | return $installed; |
@@ -44,12 +44,12 @@ discard block |
||
44 | 44 | ]; |
45 | 45 | |
46 | 46 | if (0 === preg_match('/\w+\/\w+/', $package)) { |
47 | - return (object)$response; |
|
47 | + return (object) $response; |
|
48 | 48 | } |
49 | 49 | $json = $this->fileReader->httpReadJson(sprintf('https://packagist.org/packages/%s.json', $package)); |
50 | 50 | |
51 | 51 | if (!isset($json->package)) { |
52 | - return (object)$response; |
|
52 | + return (object) $response; |
|
53 | 53 | } |
54 | 54 | |
55 | 55 | $response['type'] = $json->package->type; |
@@ -66,7 +66,7 @@ discard block |
||
66 | 66 | // get latest version |
67 | 67 | $latest = '0.0.0'; |
68 | 68 | |
69 | - foreach ((array)$json->package->versions as $version => $packageDataAtSpecificVersion) { |
|
69 | + foreach ((array) $json->package->versions as $version => $packageDataAtSpecificVersion) { |
|
70 | 70 | $version = ltrim($version, 'v'); |
71 | 71 | if (0 === preg_match('#^(\d|\.)+$#', $version) || version_compare($version, $latest, '<')) { |
72 | 72 | continue; |
@@ -75,12 +75,12 @@ discard block |
||
75 | 75 | $latest = $version; |
76 | 76 | $response['name'] = $package; |
77 | 77 | $response['latest'] = $version; |
78 | - $response['license'] = (array)$packageDataAtSpecificVersion->license; |
|
78 | + $response['license'] = (array) $packageDataAtSpecificVersion->license; |
|
79 | 79 | $response['homepage'] = $packageDataAtSpecificVersion->homepage; |
80 | 80 | $response['time'] = $packageDataAtSpecificVersion->time; |
81 | 81 | $response['zip'] = $packageDataAtSpecificVersion->dist->url; |
82 | 82 | } |
83 | 83 | |
84 | - return (object)$response; |
|
84 | + return (object) $response; |
|
85 | 85 | } |
86 | 86 | } |
@@ -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 | } |