@@ -2,8 +2,8 @@ |
||
2 | 2 | chdir(__DIR__); |
3 | 3 | |
4 | 4 | if (!file_exists('vendor/autoload.php')) { |
5 | - echo '[ERROR] It\'s required to run "composer install" before building PhpMetrics!' . PHP_EOL; |
|
6 | - exit(1); |
|
5 | + echo '[ERROR] It\'s required to run "composer install" before building PhpMetrics!' . PHP_EOL; |
|
6 | + exit(1); |
|
7 | 7 | } |
8 | 8 | |
9 | 9 | $filename = 'build/phpmetrics.phar'; |
@@ -2,7 +2,7 @@ discard block |
||
2 | 2 | chdir(__DIR__); |
3 | 3 | |
4 | 4 | if (!file_exists('vendor/autoload.php')) { |
5 | - echo '[ERROR] It\'s required to run "composer install" before building PhpMetrics!' . PHP_EOL; |
|
5 | + echo '[ERROR] It\'s required to run "composer install" before building PhpMetrics!'.PHP_EOL; |
|
6 | 6 | exit(1); |
7 | 7 | } |
8 | 8 | |
@@ -18,8 +18,8 @@ discard block |
||
18 | 18 | |
19 | 19 | $files = array_merge(rglob('*.php'), rglob('*.twig'), rglob('*.json'), rglob('*.pp')); |
20 | 20 | $exclude = '!(.git)|(.svn)|(bin)|(tests)|(Tests)|(phpmetrics)!'; |
21 | -foreach($files as $file) { |
|
22 | - if(preg_match($exclude, $file)) continue; |
|
21 | +foreach ($files as $file) { |
|
22 | + if (preg_match($exclude, $file)) continue; |
|
23 | 23 | $path = str_replace(__DIR__.'/', '', $file); |
24 | 24 | $phar->addFromString($path, file_get_contents($file)); |
25 | 25 | } |
@@ -50,10 +50,10 @@ discard block |
||
50 | 50 | |
51 | 51 | chmod($filename, 0755); |
52 | 52 | |
53 | -function rglob($pattern='*', $flags = 0, $path='') |
|
53 | +function rglob($pattern = '*', $flags = 0, $path = '') |
|
54 | 54 | { |
55 | - $paths=glob($path.'*', GLOB_MARK|GLOB_ONLYDIR|GLOB_NOSORT); |
|
56 | - $files=glob($path.$pattern, $flags); |
|
57 | - foreach ($paths as $path) { $files=array_merge($files,rglob($pattern, $flags, $path)); } |
|
55 | + $paths = glob($path.'*', GLOB_MARK|GLOB_ONLYDIR|GLOB_NOSORT); |
|
56 | + $files = glob($path.$pattern, $flags); |
|
57 | + foreach ($paths as $path) { $files = array_merge($files, rglob($pattern, $flags, $path)); } |
|
58 | 58 | return $files; |
59 | 59 | } |
60 | 60 | \ No newline at end of file |
@@ -1,4 +1,4 @@ |
||
1 | 1 | <?php |
2 | 2 | // PHP 7 |
3 | -defined('T_SPACESHIP') ||define('T_SPACESHIP', '<=>'); // 289 |
|
4 | -defined('T_COALESCE') ||define('T_COALESCE', '??'); // 282 |
|
5 | 3 | \ No newline at end of file |
4 | +defined('T_SPACESHIP') || define('T_SPACESHIP', '<=>'); // 289 |
|
5 | +defined('T_COALESCE') || define('T_COALESCE', '??'); // 282 |
|
6 | 6 | \ No newline at end of file |
@@ -47,7 +47,7 @@ |
||
47 | 47 | |
48 | 48 | public function execute(array $files) { |
49 | 49 | $object = new FileSystemComplexity($this->classMap); |
50 | - foreach($files as $filename) { |
|
50 | + foreach ($files as $filename) { |
|
51 | 51 | $result = $object->calculate($filename); |
52 | 52 | $this->collection->get($filename)->setSystemComplexity($result); |
53 | 53 | } |
@@ -51,7 +51,7 @@ |
||
51 | 51 | |
52 | 52 | // link between coupling and files |
53 | 53 | $fileCoupling = new FileCoupling($this->classMap, $couplingMap); |
54 | - foreach($files as $filename) { |
|
54 | + foreach ($files as $filename) { |
|
55 | 55 | $rCoupling = $fileCoupling->calculate($filename); |
56 | 56 | $this->collection->get($filename)->setCoupling($rCoupling); |
57 | 57 | } |
@@ -134,7 +134,7 @@ |
||
134 | 134 | ->setHalstead($rHalstead) |
135 | 135 | ->setMaintainabilityIndex($rMaintainability); |
136 | 136 | |
137 | - if($this->withOOP) { |
|
137 | + if ($this->withOOP) { |
|
138 | 138 | $rOOP = $this->extractor->extract($filename); |
139 | 139 | $this->classMap->push($filename, $rOOP); |
140 | 140 | $resultSet->setOOP($rOOP); |
@@ -47,7 +47,7 @@ |
||
47 | 47 | |
48 | 48 | public function execute(array $files) { |
49 | 49 | $fileCoupling = new FileLackOfCohesionOfMethods($this->classMap); |
50 | - foreach($files as $filename) { |
|
50 | + foreach ($files as $filename) { |
|
51 | 51 | $result = $fileCoupling->calculate($filename); |
52 | 52 | $this->collection->get($filename)->setLcom($result); |
53 | 53 | } |
@@ -52,8 +52,8 @@ |
||
52 | 52 | |
53 | 53 | |
54 | 54 | /** |
55 | - * @inheritdoc |
|
56 | - */ |
|
55 | + * @inheritdoc |
|
56 | + */ |
|
57 | 57 | public function execute(ResultCollection $collection, ResultCollection $aggregatedResults) { |
58 | 58 | |
59 | 59 | $this->output->write(str_pad("\x0DGrouping results by package/directory. This will take few minutes...", 80, "\x20")); |
@@ -46,7 +46,7 @@ discard block |
||
46 | 46 | */ |
47 | 47 | public function __construct(OutputInterface $output, Aggregator $aggregator) |
48 | 48 | { |
49 | - $this->aggregator= $aggregator; |
|
49 | + $this->aggregator = $aggregator; |
|
50 | 50 | $this->output = $output; |
51 | 51 | } |
52 | 52 | |
@@ -66,12 +66,12 @@ discard block |
||
66 | 66 | $bounds = new Bounds(); |
67 | 67 | $instability = new Instability(); |
68 | 68 | |
69 | - foreach($groupedResults as $namespace => $results) { |
|
69 | + foreach ($groupedResults as $namespace => $results) { |
|
70 | 70 | |
71 | 71 | // we filter aggregates to conserve only direct results |
72 | 72 | $childs = new ResultCollection(); |
73 | - foreach($results as $r) { |
|
74 | - if($namespace === dirname($r->getName())) { |
|
73 | + foreach ($results as $r) { |
|
74 | + if ($namespace === dirname($r->getName())) { |
|
75 | 75 | $childs->push($r); |
76 | 76 | } |
77 | 77 | } |
@@ -92,7 +92,7 @@ discard block |
||
92 | 92 | |
93 | 93 | $files = $this->finder->find($this->path); |
94 | 94 | |
95 | - if(0 == sizeof($files, COUNT_NORMAL)) { |
|
95 | + if (0 == sizeof($files, COUNT_NORMAL)) { |
|
96 | 96 | throw new \LogicException('No file found'); |
97 | 97 | } |
98 | 98 | |
@@ -116,12 +116,12 @@ discard block |
||
116 | 116 | , $classMap |
117 | 117 | ); |
118 | 118 | |
119 | - foreach($files as $k => $filename) { |
|
119 | + foreach ($files as $k => $filename) { |
|
120 | 120 | |
121 | 121 | $progress->advance(); |
122 | 122 | |
123 | 123 | // Integrity |
124 | - if(!$this->ignoreErrors && !$syntaxChecker->isCorrect($filename)) { |
|
124 | + if (!$this->ignoreErrors && !$syntaxChecker->isCorrect($filename)) { |
|
125 | 125 | $this->output->writeln(sprintf('<error>file %s is not valid and has been skipped</error>', $filename)); |
126 | 126 | unset($files[$k]); |
127 | 127 | continue; |
@@ -130,7 +130,7 @@ discard block |
||
130 | 130 | // Analyze |
131 | 131 | try { |
132 | 132 | $resultSet = $fileAnalyzer->execute($filename); |
133 | - } catch(NoTokenizableException $e) { |
|
133 | + } catch (NoTokenizableException $e) { |
|
134 | 134 | $this->output->writeln(sprintf("<error>file %s has been skipped: \n%s</error>", $filename, $e->getMessage())); |
135 | 135 | unset($files[$k]); |
136 | 136 | continue; |
@@ -151,7 +151,7 @@ discard block |
||
151 | 151 | $progress->finish(); |
152 | 152 | |
153 | 153 | |
154 | - if($this->withOOP) { |
|
154 | + if ($this->withOOP) { |
|
155 | 155 | // COUPLING (should be done after parsing files) |
156 | 156 | $this->output->write(str_pad("\x0DAnalyzing coupling. This will take few minutes...", 80, "\x20")); |
157 | 157 | $couplingAnalyzer = new CouplingAnalyzer($classMap, $collection); |
@@ -47,7 +47,7 @@ |
||
47 | 47 | * @inheritdoc |
48 | 48 | */ |
49 | 49 | public function execute(ResultCollection $collection, ResultCollection $aggregatedResults) { |
50 | - foreach($this->jobs as $job) { |
|
50 | + foreach ($this->jobs as $job) { |
|
51 | 51 | $job->execute($collection, $aggregatedResults); |
52 | 52 | } |
53 | 53 | } |