@@ -45,7 +45,7 @@ discard block |
||
45 | 45 | { |
46 | 46 | if ($node instanceof Stmt\Class_ || $node instanceof Stmt\Function_ || $node instanceof Stmt\Trait_) { |
47 | 47 | if ($node instanceof Stmt\Class_ || $node instanceof Stmt\Trait_) { |
48 | - $name = (string) (isset($node->namespacedName) ? $node->namespacedName : 'anonymous@'. \spl_object_hash($node)); |
|
48 | + $name = (string) (isset($node->namespacedName) ? $node->namespacedName : 'anonymous@'.\spl_object_hash($node)); |
|
49 | 49 | $classOrFunction = $this->metrics->get($name); |
50 | 50 | } else { |
51 | 51 | $classOrFunction = new FunctionMetric($node->name); |
@@ -56,7 +56,7 @@ discard block |
||
56 | 56 | $operands = []; |
57 | 57 | $operators = []; |
58 | 58 | |
59 | - \iterate_over_node($node, function ($node) use (&$operators, &$operands) { |
|
59 | + \iterate_over_node($node, function($node) use (&$operators, &$operands) { |
|
60 | 60 | |
61 | 61 | if ($node instanceof Node\Expr\BinaryOp |
62 | 62 | || $node instanceof Node\Expr\AssignOp |
@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | { |
37 | 37 | if ($node instanceof Stmt\Class_ || $node instanceof Stmt\Function_ || $node instanceof Stmt\Trait_) { |
38 | 38 | if ($node instanceof Stmt\Class_ || $node instanceof Stmt\Trait_) { |
39 | - $name = (string) (isset($node->namespacedName) ? $node->namespacedName : 'anonymous@'. \spl_object_hash($node)); |
|
39 | + $name = (string) (isset($node->namespacedName) ? $node->namespacedName : 'anonymous@'.\spl_object_hash($node)); |
|
40 | 40 | $classOrFunction = $this->metrics->get($name); |
41 | 41 | } else { |
42 | 42 | $classOrFunction = new FunctionMetric($node->name); |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | $code = \preg_replace('!/\*.*?\*/!s', '', $code); |
61 | 61 | |
62 | 62 | // count and remove single line comments |
63 | - $code = \preg_replace_callback('!(\'[^\']*\'|"[^"]*")|((?:#|\/\/).*$)!m', function (array $matches) use (&$cloc) { |
|
63 | + $code = \preg_replace_callback('!(\'[^\']*\'|"[^"]*")|((?:#|\/\/).*$)!m', function(array $matches) use (&$cloc) { |
|
64 | 64 | if (isset($matches[2])) { |
65 | 65 | ++$cloc; |
66 | 66 | } |
@@ -56,7 +56,7 @@ |
||
56 | 56 | foreach ($node->stmts as $stmt) { |
57 | 57 | if ($stmt instanceof Stmt\ClassMethod) { |
58 | 58 | // iterate over children, recursively |
59 | - $cb = function ($node) use (&$cb) { |
|
59 | + $cb = function($node) use (&$cb) { |
|
60 | 60 | $ccn = 0; |
61 | 61 | if (isset($node->stmts) && $node->stmts) { |
62 | 62 | foreach ($node->stmts as $child) { |
@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | |
44 | 44 | $select = $while = $if = 0; |
45 | 45 | |
46 | - \iterate_over_node($node, function ($node) use (&$while, &$select, &$if) { |
|
46 | + \iterate_over_node($node, function($node) use (&$while, &$select, &$if) { |
|
47 | 47 | switch (true) { |
48 | 48 | case $node instanceof Stmt\Do_: |
49 | 49 | case $node instanceof Stmt\Foreach_: |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | } |
60 | 60 | }); |
61 | 61 | |
62 | - $defect = 0.15 + 0.23 * $while + 0.22 * $select + 0.07 * $if; |
|
62 | + $defect = 0.15 + 0.23 * $while + 0.22 * $select + 0.07 * $if; |
|
63 | 63 | $class->set('kanDefect', \round($defect, 2)); |
64 | 64 | } |
65 | 65 | } |
@@ -47,7 +47,7 @@ |
||
47 | 47 | $class = new InterfaceMetric($node->namespacedName->toString()); |
48 | 48 | $class->set('interface', true); |
49 | 49 | } else { |
50 | - $name = (string) (isset($node->namespacedName) ? $node->namespacedName : 'anonymous@'. \spl_object_hash($node)); |
|
50 | + $name = (string) (isset($node->namespacedName) ? $node->namespacedName : 'anonymous@'.\spl_object_hash($node)); |
|
51 | 51 | $class = new ClassMetric($name); |
52 | 52 | $class->set('interface', false); |
53 | 53 | } |
@@ -61,20 +61,20 @@ discard block |
||
61 | 61 | // extends |
62 | 62 | if (isset($node->extends)) { |
63 | 63 | if (\is_array($node->extends)) { |
64 | - foreach ((array)$node->extends as $interface) { |
|
65 | - $dependencies[] = (string)$interface; |
|
66 | - $parents[] = (string)$interface; |
|
64 | + foreach ((array) $node->extends as $interface) { |
|
65 | + $dependencies[] = (string) $interface; |
|
66 | + $parents[] = (string) $interface; |
|
67 | 67 | } |
68 | 68 | } else { |
69 | - $dependencies[] = (string)$node->extends; |
|
70 | - $parents[] = (string)$node->extends; |
|
69 | + $dependencies[] = (string) $node->extends; |
|
70 | + $parents[] = (string) $node->extends; |
|
71 | 71 | } |
72 | 72 | } |
73 | 73 | |
74 | 74 | // implements |
75 | 75 | if (isset($node->implements)) { |
76 | 76 | foreach ($node->implements as $interface) { |
77 | - $dependencies[] = (string)$interface; |
|
77 | + $dependencies[] = (string) $interface; |
|
78 | 78 | } |
79 | 79 | } |
80 | 80 | |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | // return |
84 | 84 | if (isset($stmt->returnType)) { |
85 | 85 | if ($stmt->returnType instanceof Node\Name\FullyQualified) { |
86 | - $dependencies[] = (string)$stmt->returnType; |
|
86 | + $dependencies[] = (string) $stmt->returnType; |
|
87 | 87 | } |
88 | 88 | } |
89 | 89 | |
@@ -91,13 +91,13 @@ discard block |
||
91 | 91 | foreach ($stmt->params as $param) { |
92 | 92 | if ($param->type) { |
93 | 93 | if ($param->type instanceof Node\Name\FullyQualified) { |
94 | - $dependencies[] = (string)$param->type; |
|
94 | + $dependencies[] = (string) $param->type; |
|
95 | 95 | } |
96 | 96 | } |
97 | 97 | } |
98 | 98 | |
99 | 99 | // instantiations, static calls |
100 | - \iterate_over_node($stmt, function ($node) use (&$dependencies) { |
|
100 | + \iterate_over_node($stmt, function($node) use (&$dependencies) { |
|
101 | 101 | switch (true) { |
102 | 102 | case $node instanceof Node\Expr\New_: |
103 | 103 | // new MyClass |
@@ -116,7 +116,7 @@ discard block |
||
116 | 116 | foreach ($matches[1] as $check) { |
117 | 117 | foreach ($this->uses as $use) { |
118 | 118 | if ($use->alias === $check) { |
119 | - $dependencies[] = (string)$use->name; |
|
119 | + $dependencies[] = (string) $use->name; |
|
120 | 120 | } |
121 | 121 | } |
122 | 122 | } |
@@ -80,7 +80,7 @@ discard block |
||
80 | 80 | |
81 | 81 | // JUNIT format |
82 | 82 | foreach ($xpath->query('//testsuite[@file]') as $suite) { |
83 | - $testsuites[] = (object)[ |
|
83 | + $testsuites[] = (object) [ |
|
84 | 84 | 'file' => $suite->getAttribute('file'), |
85 | 85 | 'name' => $suite->getAttribute('name'), |
86 | 86 | 'assertions' => $suite->getAttribute('assertions'), |
@@ -110,7 +110,7 @@ discard block |
||
110 | 110 | } |
111 | 111 | |
112 | 112 | $attributeClass = $case->getAttribute('class'); |
113 | - $testsuites[$attributeClass] = (object)[ |
|
113 | + $testsuites[$attributeClass] = (object) [ |
|
114 | 114 | 'file' => $case->getAttribute('file'), |
115 | 115 | 'name' => $attributeClass, |
116 | 116 | 'assertions' => $assertions, |
@@ -129,7 +129,7 @@ discard block |
||
129 | 129 | $traverser->addVisitor(new ExternalsVisitor($metricsOfUnitTest)); |
130 | 130 | |
131 | 131 | if (!\file_exists($suite->file) || !\is_readable($suite->file)) { |
132 | - throw new \LogicException('Cannot find source file referenced in testsuite: ' . $suite->file); |
|
132 | + throw new \LogicException('Cannot find source file referenced in testsuite: '.$suite->file); |
|
133 | 133 | } |
134 | 134 | |
135 | 135 | $code = \file_get_contents($suite->file); |
@@ -142,10 +142,10 @@ discard block |
||
142 | 142 | |
143 | 143 | // list of externals sources of unit test |
144 | 144 | $metric = $metricsOfUnitTest->get($suite->name); |
145 | - $externals = (array)$metric->get('externals'); |
|
145 | + $externals = (array) $metric->get('externals'); |
|
146 | 146 | |
147 | 147 | // global stats for each test |
148 | - $infoAboutTests[$suite->name] = (object)[ |
|
148 | + $infoAboutTests[$suite->name] = (object) [ |
|
149 | 149 | 'nbExternals' => \count(\array_unique($externals)), |
150 | 150 | 'externals' => \array_unique($externals), |
151 | 151 | 'filename' => $suite->file, |
@@ -46,7 +46,7 @@ discard block |
||
46 | 46 | foreach ($rawRequirements as $requirement => $version) { |
47 | 47 | $package = $packagist->get($requirement); |
48 | 48 | |
49 | - $packages[$requirement] = (object)[ |
|
49 | + $packages[$requirement] = (object) [ |
|
50 | 50 | 'name' => $requirement, |
51 | 51 | 'required' => $version, |
52 | 52 | 'installed' => isset($rawInstalled[$requirement]) ? $rawInstalled[$requirement] : null, |
@@ -77,13 +77,13 @@ discard block |
||
77 | 77 | if (!\preg_match('/composer(-dist)?\.json/', $filename)) { |
78 | 78 | continue; |
79 | 79 | } |
80 | - $composerJson = (object)\json_decode(\file_get_contents($filename)); |
|
80 | + $composerJson = (object) \json_decode(\file_get_contents($filename)); |
|
81 | 81 | |
82 | 82 | if (!isset($composerJson->require)) { |
83 | 83 | continue; |
84 | 84 | } |
85 | 85 | |
86 | - $rawRequirements[] = (array)$composerJson->require; |
|
86 | + $rawRequirements[] = (array) $composerJson->require; |
|
87 | 87 | } |
88 | 88 | |
89 | 89 | return \call_user_func_array('\array_merge', $rawRequirements); |
@@ -107,7 +107,7 @@ discard block |
||
107 | 107 | if (false === \strpos($filename, 'composer.lock')) { |
108 | 108 | continue; |
109 | 109 | } |
110 | - $composerLockJson = (object)\json_decode(\file_get_contents($filename)); |
|
110 | + $composerLockJson = (object) \json_decode(\file_get_contents($filename)); |
|
111 | 111 | |
112 | 112 | if (!isset($composerLockJson->packages)) { |
113 | 113 | continue; |
@@ -35,7 +35,7 @@ |
||
35 | 35 | |
36 | 36 | // get latest version |
37 | 37 | $latest = '0.0.0'; |
38 | - foreach ((array)$json->package->versions as $version => $datas) { |
|
38 | + foreach ((array) $json->package->versions as $version => $datas) { |
|
39 | 39 | $version = \preg_replace('([^\.\d])', '', $version); |
40 | 40 | if (!\preg_match('!\d+\.\d+\.\d+!', $version)) { |
41 | 41 | continue; |