@@ -25,7 +25,7 @@ |
||
25 | 25 | |
26 | 26 | public function apply(Metric $metric) |
27 | 27 | { |
28 | - if (! $metric instanceof ClassMetric) { |
|
28 | + if (!$metric instanceof ClassMetric) { |
|
29 | 29 | return; |
30 | 30 | } |
31 | 31 |
@@ -136,6 +136,9 @@ |
||
136 | 136 | } |
137 | 137 | } |
138 | 138 | |
139 | + /** |
|
140 | + * @param string|null $dependency |
|
141 | + */ |
|
139 | 142 | private function pushToDependencies(array &$dependencies, $dependency) |
140 | 143 | { |
141 | 144 | $lowercase = strtolower($dependency); |
@@ -58,20 +58,20 @@ discard block |
||
58 | 58 | // extends |
59 | 59 | if (isset($node->extends)) { |
60 | 60 | if (is_array($node->extends)) { |
61 | - foreach ((array)$node->extends as $interface) { |
|
62 | - $this->pushToDependencies($dependencies, (string)$interface); |
|
63 | - array_push($parents, (string)$interface); |
|
61 | + foreach ((array) $node->extends as $interface) { |
|
62 | + $this->pushToDependencies($dependencies, (string) $interface); |
|
63 | + array_push($parents, (string) $interface); |
|
64 | 64 | } |
65 | 65 | } else { |
66 | - $this->pushToDependencies($dependencies, (string)$node->extends); |
|
67 | - array_push($parents, (string)$node->extends); |
|
66 | + $this->pushToDependencies($dependencies, (string) $node->extends); |
|
67 | + array_push($parents, (string) $node->extends); |
|
68 | 68 | } |
69 | 69 | } |
70 | 70 | |
71 | 71 | // implements |
72 | 72 | if (isset($node->implements)) { |
73 | 73 | foreach ($node->implements as $interface) { |
74 | - $this->pushToDependencies($dependencies, (string)$interface); |
|
74 | + $this->pushToDependencies($dependencies, (string) $interface); |
|
75 | 75 | } |
76 | 76 | } |
77 | 77 | |
@@ -80,7 +80,7 @@ discard block |
||
80 | 80 | // return |
81 | 81 | if (isset($stmt->returnType)) { |
82 | 82 | if ($stmt->returnType instanceof Node\Name\FullyQualified) { |
83 | - $this->pushToDependencies($dependencies, (string)$stmt->returnType); |
|
83 | + $this->pushToDependencies($dependencies, (string) $stmt->returnType); |
|
84 | 84 | } |
85 | 85 | } |
86 | 86 | |
@@ -88,13 +88,13 @@ discard block |
||
88 | 88 | foreach ($stmt->params as $param) { |
89 | 89 | if ($param->type) { |
90 | 90 | if ($param->type instanceof Node\Name\FullyQualified) { |
91 | - $this->pushToDependencies($dependencies, (string)$param->type); |
|
91 | + $this->pushToDependencies($dependencies, (string) $param->type); |
|
92 | 92 | } |
93 | 93 | } |
94 | 94 | } |
95 | 95 | |
96 | 96 | // instantiations, static calls |
97 | - \iterate_over_node($stmt, function ($node) use (&$dependencies) { |
|
97 | + \iterate_over_node($stmt, function($node) use (&$dependencies) { |
|
98 | 98 | switch (true) { |
99 | 99 | case $node instanceof Node\Expr\New_: |
100 | 100 | // new MyClass |
@@ -113,13 +113,13 @@ discard block |
||
113 | 113 | foreach ($matches[1] as $check) { |
114 | 114 | foreach ($this->uses as $use) { |
115 | 115 | if (method_exists($use, 'getAlias')) { |
116 | - if (((string)$use->getAlias()) === $check) { |
|
117 | - $this->pushToDependencies($dependencies, (string)($use->name)); |
|
116 | + if (((string) $use->getAlias()) === $check) { |
|
117 | + $this->pushToDependencies($dependencies, (string) ($use->name)); |
|
118 | 118 | } |
119 | 119 | continue; |
120 | 120 | } |
121 | 121 | if ($use->alias === $check) { |
122 | - $this->pushToDependencies($dependencies, (string)($use->name)); |
|
122 | + $this->pushToDependencies($dependencies, (string) ($use->name)); |
|
123 | 123 | } |
124 | 124 | } |
125 | 125 | } |
@@ -138,6 +138,6 @@ discard block |
||
138 | 138 | if ('self' === $lowercase || 'parent' === $lowercase) { |
139 | 139 | return; |
140 | 140 | } |
141 | - array_push($dependencies, (string)$dependency); |
|
141 | + array_push($dependencies, (string) $dependency); |
|
142 | 142 | } |
143 | 143 | } |
@@ -72,7 +72,7 @@ discard block |
||
72 | 72 | |
73 | 73 | // JUNIT format |
74 | 74 | foreach ($xpath->query('//testsuite[@file]') as $suite) { |
75 | - array_push($testsuites, (object)[ |
|
75 | + array_push($testsuites, (object) [ |
|
76 | 76 | 'file' => $suite->getAttribute('file'), |
77 | 77 | 'name' => $suite->getAttribute('name'), |
78 | 78 | 'assertions' => $suite->getAttribute('assertions'), |
@@ -101,7 +101,7 @@ discard block |
||
101 | 101 | $assertions = $case === $suite->firstChild->nextSibling ? $suite->getAttribute('assertions') : 0; |
102 | 102 | } |
103 | 103 | |
104 | - $testsuites[$case->getAttribute('class')] = (object)[ |
|
104 | + $testsuites[$case->getAttribute('class')] = (object) [ |
|
105 | 105 | 'file' => $case->getAttribute('file'), |
106 | 106 | 'name' => $case->getAttribute('class'), |
107 | 107 | 'assertions' => $assertions, |
@@ -120,7 +120,7 @@ discard block |
||
120 | 120 | $traverser->addVisitor(new ExternalsVisitor($metricsOfUnitTest)); |
121 | 121 | |
122 | 122 | if (!file_exists($suite->file) || !is_readable($suite->file)) { |
123 | - throw new \LogicException('Cannot find source file referenced in testsuite: ' . $suite->file); |
|
123 | + throw new \LogicException('Cannot find source file referenced in testsuite: '.$suite->file); |
|
124 | 124 | } |
125 | 125 | |
126 | 126 | $code = file_get_contents($suite->file); |
@@ -133,10 +133,10 @@ discard block |
||
133 | 133 | |
134 | 134 | // list of externals sources of unit test |
135 | 135 | $metric = $metricsOfUnitTest->get($suite->name); |
136 | - $externals = (array)$metric->get('externals'); |
|
136 | + $externals = (array) $metric->get('externals'); |
|
137 | 137 | |
138 | 138 | // global stats for each test |
139 | - $infoAboutTests[$suite->name] = (object)[ |
|
139 | + $infoAboutTests[$suite->name] = (object) [ |
|
140 | 140 | 'nbExternals' => count(array_unique($externals)), |
141 | 141 | 'externals' => array_unique($externals), |
142 | 142 | 'filename' => $suite->file, |
@@ -71,15 +71,15 @@ |
||
71 | 71 | $files = []; |
72 | 72 | foreach ($paths as $path) { |
73 | 73 | if (is_dir($path)) { |
74 | - $path = rtrim($path, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR; |
|
74 | + $path = rtrim($path, DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR; |
|
75 | 75 | $directory = new RecursiveDirectoryIterator($path, $this->flags); |
76 | 76 | $iterator = new RecursiveIteratorIterator($directory); |
77 | 77 | |
78 | 78 | $filterRegex = sprintf( |
79 | 79 | '`^%s%s%s$`', |
80 | 80 | preg_quote($path, '`'), |
81 | - !empty($this->excludedDirs) ? '((?!' . implode('|', array_map('preg_quote', $this->excludedDirs)) . ').)+' : '.+', |
|
82 | - '\.(' . implode('|', $this->extensions) . ')' |
|
81 | + !empty($this->excludedDirs) ? '((?!'.implode('|', array_map('preg_quote', $this->excludedDirs)).').)+' : '.+', |
|
82 | + '\.('.implode('|', $this->extensions).')' |
|
83 | 83 | ); |
84 | 84 | |
85 | 85 | $filteredIterator = new RegexIterator( |
@@ -64,7 +64,7 @@ |
||
64 | 64 | foreach ($node->stmts as $stmt) { |
65 | 65 | if ($stmt instanceof Stmt\ClassMethod) { |
66 | 66 | // iterate over children, recursively |
67 | - $cb = function ($node) use (&$cb) { |
|
67 | + $cb = function($node) use (&$cb) { |
|
68 | 68 | $ccn = 0; |
69 | 69 | |
70 | 70 | foreach (get_object_vars($node) as $name => $member) { |
@@ -22,7 +22,7 @@ |
||
22 | 22 | $output = new CliOutput(); |
23 | 23 | |
24 | 24 | // issues and debug |
25 | - $issuer = (new Issuer($output));//->enable(); |
|
25 | + $issuer = (new Issuer($output)); //->enable(); |
|
26 | 26 | |
27 | 27 | // config |
28 | 28 | $config = (new Parser())->parse($argv); |
@@ -98,7 +98,7 @@ |
||
98 | 98 | return |
99 | 99 | 0 >= version_compare( |
100 | 100 | '10.0.10586', |
101 | - PHP_WINDOWS_VERSION_MAJOR . '.' . PHP_WINDOWS_VERSION_MINOR . '.' . PHP_WINDOWS_VERSION_BUILD |
|
101 | + PHP_WINDOWS_VERSION_MAJOR.'.'.PHP_WINDOWS_VERSION_MINOR.'.'.PHP_WINDOWS_VERSION_BUILD |
|
102 | 102 | ) |
103 | 103 | || false !== getenv('ANSICON') |
104 | 104 | || 'ON' === getenv('ConEmuANSI') |
@@ -27,7 +27,7 @@ |
||
27 | 27 | public function __construct(Mother $traverser, $stopCondition = null) |
28 | 28 | { |
29 | 29 | if (null === $stopCondition) { |
30 | - $stopCondition = function ($node) { |
|
30 | + $stopCondition = function($node) { |
|
31 | 31 | if ($node instanceof Node\Stmt\Class_ || $node instanceof Node\Stmt\Interface_) { |
32 | 32 | return false; |
33 | 33 | } |
@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | $class->set('interface', true); |
38 | 38 | $class->set('abstract', true); |
39 | 39 | } else { |
40 | - $name = (string)(isset($node->namespacedName) ? $node->namespacedName : 'anonymous@' . spl_object_hash($node)); |
|
40 | + $name = (string) (isset($node->namespacedName) ? $node->namespacedName : 'anonymous@'.spl_object_hash($node)); |
|
41 | 41 | $class = new ClassMetric($name); |
42 | 42 | $class->set('interface', false); |
43 | 43 | $class->set('abstract', $node instanceof Stmt\Trait_ || $node->isAbstract()); |
@@ -50,7 +50,7 @@ discard block |
||
50 | 50 | $roleDetector = new RoleOfMethodDetector(); |
51 | 51 | foreach ($node->stmts as $stmt) { |
52 | 52 | if ($stmt instanceof Stmt\ClassMethod) { |
53 | - $function = new FunctionMetric((string)$stmt->name); |
|
53 | + $function = new FunctionMetric((string) $stmt->name); |
|
54 | 54 | |
55 | 55 | $role = $roleDetector->detects($stmt); |
56 | 56 | $function->set('role', $role); |