@@ -45,7 +45,7 @@ discard block |
||
45 | 45 | |
46 | 46 | $package = $packagist->get($requirement); |
47 | 47 | |
48 | - $packages[$requirement] = (object)array( |
|
48 | + $packages[$requirement] = (object) array( |
|
49 | 49 | 'name' => $requirement, |
50 | 50 | 'required' => $version, |
51 | 51 | 'installed' => isset($rawInstalled[$requirement]) ? $rawInstalled[$requirement] : null, |
@@ -76,13 +76,13 @@ discard block |
||
76 | 76 | if (!\preg_match('/composer(-dist)?\.json/', $filename)) { |
77 | 77 | continue; |
78 | 78 | } |
79 | - $composerJson = (object)\json_decode(\file_get_contents($filename)); |
|
79 | + $composerJson = (object) \json_decode(\file_get_contents($filename)); |
|
80 | 80 | |
81 | 81 | if (!isset($composerJson->require)) { |
82 | 82 | continue; |
83 | 83 | } |
84 | 84 | |
85 | - $rawRequirements[] = (array)$composerJson->require; |
|
85 | + $rawRequirements[] = (array) $composerJson->require; |
|
86 | 86 | } |
87 | 87 | |
88 | 88 | return \call_user_func_array('array_merge', $rawRequirements); |
@@ -106,7 +106,7 @@ discard block |
||
106 | 106 | if (false === \strpos($filename, 'composer.lock')) { |
107 | 107 | continue; |
108 | 108 | } |
109 | - $composerLockJson = (object)\json_decode(\file_get_contents($filename)); |
|
109 | + $composerLockJson = (object) \json_decode(\file_get_contents($filename)); |
|
110 | 110 | |
111 | 111 | if (!isset($composerLockJson->packages)) { |
112 | 112 | continue; |
@@ -1,4 +1,4 @@ discard block |
||
1 | -<?php require __DIR__ . '/_header.php'; ?> |
|
1 | +<?php require __DIR__.'/_header.php'; ?> |
|
2 | 2 | <div class="row"> |
3 | 3 | <div class="column"> |
4 | 4 | <div class="bloc bloc-number"> |
@@ -95,7 +95,7 @@ discard block |
||
95 | 95 | <tbody id="contentClassRank" class="clusterize-content"> |
96 | 96 | <?php |
97 | 97 | $classesS = $classes; |
98 | - usort($classesS, function ($a, $b) { |
|
98 | + usort($classesS, function($a, $b) { |
|
99 | 99 | return strcmp($b['pageRank'], $a['pageRank']); |
100 | 100 | }); |
101 | 101 | //$classesS = array_slice($classesS, 0, 10); |
@@ -137,7 +137,7 @@ discard block |
||
137 | 137 | <tbody id="contentPackages" class="clusterize-content"> |
138 | 138 | <?php |
139 | 139 | $packages = isset($project['composer'], $project['composer']['packages']) ? $project['composer']['packages'] : []; |
140 | - usort($packages, function ($a, $b) { |
|
140 | + usort($packages, function($a, $b) { |
|
141 | 141 | return strcmp($a->name, $b->name); |
142 | 142 | }); |
143 | 143 | foreach ($packages as $package) { ?> |
@@ -146,18 +146,18 @@ discard block |
||
146 | 146 | <td><?php echo $package->required; ?></td> |
147 | 147 | <?php if (0 !== count($packagesInstalled)) {?><td><?php echo $package->installed; ?></td><?php } ?> |
148 | 148 | <td><?php echo $package->latest; ?></td> |
149 | - <td><?php foreach($package->license as $license) { ?> |
|
150 | - <a target="_blank" href="https://spdx.org/licenses/<?php echo $license;?>.html"><?php echo $license;?></a> |
|
149 | + <td><?php foreach ($package->license as $license) { ?> |
|
150 | + <a target="_blank" href="https://spdx.org/licenses/<?php echo $license; ?>.html"><?php echo $license; ?></a> |
|
151 | 151 | <?php } ?> |
152 | 152 | </td> |
153 | 153 | </tr> |
154 | 154 | <?php } ?> |
155 | 155 | </tbody> |
156 | 156 | </table> |
157 | - <?php if(0 === count($packages)) { ?> |
|
157 | + <?php if (0 === count($packages)) { ?> |
|
158 | 158 | <div>No composer.json file found</div> |
159 | 159 | <?php } ?> |
160 | - <?php if(0 === count($packagesInstalled)) { ?> |
|
160 | + <?php if (0 === count($packagesInstalled)) { ?> |
|
161 | 161 | <div>No composer.lock file found</div> |
162 | 162 | <?php } ?> |
163 | 163 | </div> |
@@ -168,7 +168,7 @@ discard block |
||
168 | 168 | <div class="column"> |
169 | 169 | <div class="bloc bloc-number"> |
170 | 170 | <div class="label">Licences of Composer dependencies</div> |
171 | - <?php if(0 === sizeof($packages)) { ?> |
|
171 | + <?php if (0 === sizeof($packages)) { ?> |
|
172 | 172 | <div>No composer.json file found</div> |
173 | 173 | <?php } ?> |
174 | 174 | <div id="svg-licenses"></div> |
@@ -207,9 +207,9 @@ discard block |
||
207 | 207 | } |
208 | 208 | } |
209 | 209 | ?> |
210 | - chartLicenses(<?php echo json_encode(array_values($json));?>); |
|
210 | + chartLicenses(<?php echo json_encode(array_values($json)); ?>); |
|
211 | 211 | } |
212 | 212 | }; |
213 | 213 | </script> |
214 | 214 | |
215 | -<?php require __DIR__ . '/_footer.php'; ?> |
|
215 | +<?php require __DIR__.'/_footer.php'; ?> |
@@ -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; |
@@ -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 | } |
@@ -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(sizeof($array) > 1) { |
|
22 | +if (sizeof($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> |
@@ -58,7 +58,7 @@ |
||
58 | 58 | if ($stmt instanceof Stmt\ClassMethod) { |
59 | 59 | |
60 | 60 | // iterate over children, recursively |
61 | - $cb = function ($node) use (&$cb) { |
|
61 | + $cb = function($node) use (&$cb) { |
|
62 | 62 | $ccn = 0; |
63 | 63 | |
64 | 64 | foreach (get_object_vars($node) as $name => $member) { |
@@ -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 | } |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | |
45 | 45 | /** |
46 | 46 | * @param array $nodes |
47 | - * @param array|NodeVisitor[] $visitors |
|
47 | + * @param NodeVisitor[] $visitors |
|
48 | 48 | * @return array |
49 | 49 | */ |
50 | 50 | public function traverseArray(array $nodes, array $visitors) { |
@@ -101,6 +101,9 @@ discard block |
||
101 | 101 | /** @var Traverser */ |
102 | 102 | private $traverser; |
103 | 103 | |
104 | + /** |
|
105 | + * @param \Closure $stopCondition |
|
106 | + */ |
|
104 | 107 | public function __construct($cloneNodes = false, $stopCondition = null) |
105 | 108 | { |
106 | 109 | parent::__construct(); |
@@ -123,6 +126,9 @@ discard block |
||
123 | 126 | /** @var Traverser */ |
124 | 127 | private $traverser; |
125 | 128 | |
129 | + /** |
|
130 | + * @param \Closure $stopCondition |
|
131 | + */ |
|
126 | 132 | public function __construct($cloneNodes = false, $stopCondition = null) |
127 | 133 | { |
128 | 134 | parent::__construct(); |
@@ -28,9 +28,9 @@ |
||
28 | 28 | |
29 | 29 | public function __construct(Mother $traverser, $stopCondition = null) |
30 | 30 | { |
31 | - if(null === $stopCondition) { |
|
31 | + if (null === $stopCondition) { |
|
32 | 32 | $stopCondition = function($node) { |
33 | - if($node instanceof Node\Stmt\Class_ || $node instanceof Node\Stmt\Interface_) { |
|
33 | + if ($node instanceof Node\Stmt\Class_ || $node instanceof Node\Stmt\Interface_) { |
|
34 | 34 | return false; |
35 | 35 | } |
36 | 36 |