@@ -30,9 +30,9 @@ discard block |
||
30 | 30 | { |
31 | 31 | $end = sizeof($tokens, COUNT_NORMAL); |
32 | 32 | $value = ''; |
33 | - while($startingToken < $end) { |
|
33 | + while ($startingToken < $end) { |
|
34 | 34 | $token = $tokens[$startingToken]; |
35 | - if(in_array($token->getValue(), $delimiters)) { |
|
35 | + if (in_array($token->getValue(), $delimiters)) { |
|
36 | 36 | return $value; |
37 | 37 | } |
38 | 38 | $value .= $token->getValue(); |
@@ -52,8 +52,8 @@ discard block |
||
52 | 52 | public function getPrevious(&$startingToken, TokenCollection $tokens) |
53 | 53 | { |
54 | 54 | $p = $startingToken - 1; |
55 | - for($i = $p ; $i > 0; $i--) { |
|
56 | - if(T_WHITESPACE !== $tokens[$i]->getType()) { |
|
55 | + for ($i = $p; $i > 0; $i--) { |
|
56 | + if (T_WHITESPACE !== $tokens[$i]->getType()) { |
|
57 | 57 | return $tokens[$i]; |
58 | 58 | } |
59 | 59 | } |
@@ -88,19 +88,19 @@ discard block |
||
88 | 88 | $openBrace = 0; |
89 | 89 | $start = null; |
90 | 90 | $len = sizeof($tokens); |
91 | - for($i = $startingToken; $i < $len; $i++) { |
|
91 | + for ($i = $startingToken; $i < $len; $i++) { |
|
92 | 92 | $token = $tokens[$i]; |
93 | - if(T_STRING == $token->getType()) { |
|
94 | - switch($token->getValue()) { |
|
93 | + if (T_STRING == $token->getType()) { |
|
94 | + switch ($token->getValue()) { |
|
95 | 95 | case '{': |
96 | 96 | $openBrace++; |
97 | - if(is_null($start)) { |
|
97 | + if (is_null($start)) { |
|
98 | 98 | $start = $startingToken = $i + 1; |
99 | 99 | } |
100 | 100 | break; |
101 | 101 | case '}': |
102 | 102 | $openBrace--; |
103 | - if($openBrace <= 0) { |
|
103 | + if ($openBrace <= 0) { |
|
104 | 104 | return $i; |
105 | 105 | } |
106 | 106 | break; |
@@ -119,7 +119,7 @@ discard block |
||
119 | 119 | */ |
120 | 120 | public function getExtendPosition(TokenCollection $tokens, $startingToken) |
121 | 121 | { |
122 | - for($i = $startingToken; $i > 0; $i--) { |
|
122 | + for ($i = $startingToken; $i > 0; $i--) { |
|
123 | 123 | $token = $tokens[$i]; |
124 | 124 | if ($token->getValue() === 'extends') { |
125 | 125 | return $i; |
@@ -136,7 +136,7 @@ discard block |
||
136 | 136 | public function getClassNamePosition(TokenCollection $tokens) |
137 | 137 | { |
138 | 138 | $len = sizeof($tokens); |
139 | - for($i = 0; $i < $len; $i++) { |
|
139 | + for ($i = 0; $i < $len; $i++) { |
|
140 | 140 | $token = $tokens[$i]; |
141 | 141 | if ($token->getValue() === 'class') { |
142 | 142 | return $i; |
@@ -155,8 +155,8 @@ discard block |
||
155 | 155 | */ |
156 | 156 | public function getPositionOfPrevious($tokenType, $startingToken, TokenCollection $tokens) |
157 | 157 | { |
158 | - for($i = $startingToken; $i > 0; $i--) { |
|
159 | - if($tokenType == $tokens->get($i)->getType()) { |
|
158 | + for ($i = $startingToken; $i > 0; $i--) { |
|
159 | + if ($tokenType == $tokens->get($i)->getType()) { |
|
160 | 160 | return $i; |
161 | 161 | } |
162 | 162 | } |
@@ -174,8 +174,8 @@ discard block |
||
174 | 174 | public function getPositionOfNext($tokenType, $startingToken, TokenCollection $tokens) |
175 | 175 | { |
176 | 176 | $len = sizeof($tokens); |
177 | - for($i = $startingToken; $i < $len; $i++) { |
|
178 | - if($tokenType == $tokens->get($i)->getType()) { |
|
177 | + for ($i = $startingToken; $i < $len; $i++) { |
|
178 | + if ($tokenType == $tokens->get($i)->getType()) { |
|
179 | 179 | return $i; |
180 | 180 | } |
181 | 181 | } |
@@ -26,13 +26,13 @@ |
||
26 | 26 | public function dump(TokenCollection $tokens, $start = 0, $len = 0) |
27 | 27 | { |
28 | 28 | $str = ''; |
29 | - if($len == 0) { |
|
29 | + if ($len == 0) { |
|
30 | 30 | $len = sizeof($tokens); |
31 | 31 | } |
32 | - if($start < 0) { |
|
32 | + if ($start < 0) { |
|
33 | 33 | $start = 0; |
34 | 34 | } |
35 | - for($i = $start; $i < $len; $i++) { |
|
35 | + for ($i = $start; $i < $len; $i++) { |
|
36 | 36 | $str .= sprintf("\n%s : %s", token_name($tokens[$i]->getType()), $tokens[$i]->getValue()); |
37 | 37 | } |
38 | 38 | return $str; |
@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | |
49 | 49 | $this->tokenizer = $tokenizer; |
50 | 50 | $this->searcher = new Searcher(); |
51 | - $this->result= new Result; |
|
51 | + $this->result = new Result; |
|
52 | 52 | |
53 | 53 | $this->extractors = (object) array( |
54 | 54 | 'class' => new ClassExtractor($this->searcher) |
@@ -80,9 +80,9 @@ discard block |
||
80 | 80 | $endAnonymous = 0; |
81 | 81 | $mainContextClass = null; // class containing a anonymous class |
82 | 82 | |
83 | - for($n = 0; $n < $len; $n++) { |
|
83 | + for ($n = 0; $n < $len; $n++) { |
|
84 | 84 | |
85 | - if($mainContextClass && $n > $endAnonymous) { |
|
85 | + if ($mainContextClass && $n > $endAnonymous) { |
|
86 | 86 | // anonymous class is finished. We back to parent class |
87 | 87 | // methods will be added to the main class now |
88 | 88 | $class = $mainContextClass; |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | |
92 | 92 | $token = $tokens[$n]; |
93 | 93 | |
94 | - switch($token->getType()) { |
|
94 | + switch ($token->getType()) { |
|
95 | 95 | |
96 | 96 | case T_USE: |
97 | 97 | $alias = $this->extractors->alias->extract($n, $tokens); |
@@ -131,7 +131,7 @@ discard block |
||
131 | 131 | case T_CLASS: |
132 | 132 | $i = $n; |
133 | 133 | // avoid MyClass::class syntax |
134 | - if($this->searcher->isPrecededBy(T_DOUBLE_COLON, $i, $tokens, 1)) { |
|
134 | + if ($this->searcher->isPrecededBy(T_DOUBLE_COLON, $i, $tokens, 1)) { |
|
135 | 135 | continue; |
136 | 136 | } |
137 | 137 | |
@@ -142,14 +142,14 @@ discard block |
||
142 | 142 | $result->pushClass($c); |
143 | 143 | |
144 | 144 | // PHP 7 and inner classes |
145 | - if($c instanceof ReflectedAnonymousClass) { |
|
145 | + if ($c instanceof ReflectedAnonymousClass) { |
|
146 | 146 | // avoid to consider anonymous class as main class |
147 | 147 | $p = $n; |
148 | 148 | $endAnonymous = $this->searcher->getPositionOfClosingBrace($p, $tokens); |
149 | 149 | $mainContextClass = $class; |
150 | 150 | |
151 | 151 | // add anonymous class in method |
152 | - if($method) { |
|
152 | + if ($method) { |
|
153 | 153 | $method->pushAnonymousClass($c); |
154 | 154 | } |
155 | 155 | } |
@@ -157,10 +157,10 @@ discard block |
||
157 | 157 | break; |
158 | 158 | |
159 | 159 | case T_FUNCTION: |
160 | - if($class) { |
|
160 | + if ($class) { |
|
161 | 161 | // avoid closure |
162 | 162 | $next = $tokens[$n + 1]; |
163 | - if(T_WHITESPACE != $next->getType()) { |
|
163 | + if (T_WHITESPACE != $next->getType()) { |
|
164 | 164 | continue; |
165 | 165 | } |
166 | 166 | $method = $this->extractors->method->extract($n, $tokens, $class); |
@@ -9,10 +9,6 @@ |
||
9 | 9 | |
10 | 10 | namespace Hal\Application\Command\Job; |
11 | 11 | use Hal\Application\Extension\ExtensionService; |
12 | -use Hal\Application\Formater\Chart; |
|
13 | -use Hal\Application\Formater\Details; |
|
14 | -use Hal\Application\Formater\Summary; |
|
15 | -use Hal\Application\Formater\Violations; |
|
16 | 12 | use Hal\Application\Score\Scoring; |
17 | 13 | use Hal\Component\Aggregator\DirectoryAggregatorFlat; |
18 | 14 | use Hal\Component\Bounds\BoundsInterface; |
@@ -10,13 +10,10 @@ |
||
10 | 10 | namespace Hal\Application\Command\Job; |
11 | 11 | use Hal\Application\Extension\ExtensionService; |
12 | 12 | use Hal\Application\Extension\extensionsService; |
13 | -use Hal\Application\Extension\Repository; |
|
14 | 13 | use Hal\Application\Formater\Chart; |
15 | 14 | use Hal\Application\Formater\Details; |
16 | 15 | use Hal\Application\Formater\Summary; |
17 | 16 | use Hal\Application\Formater\Violations; |
18 | -use Hal\Application\Score\Scoring; |
|
19 | -use Hal\Component\Aggregator\DirectoryAggregatorFlat; |
|
20 | 17 | use Hal\Component\Bounds\BoundsInterface; |
21 | 18 | use Hal\Component\Config\ConfigurationInterface; |
22 | 19 | use Hal\Component\File\Finder; |
@@ -9,7 +9,6 @@ |
||
9 | 9 | |
10 | 10 | namespace Hal\Application\Command; |
11 | 11 | use Hal\Application\Command\Job\QueueAnalyzeFactory; |
12 | -use Hal\Application\Command\Job\QueueFactory; |
|
13 | 12 | use Hal\Application\Command\Job\QueueReportFactory; |
14 | 13 | use Hal\Application\Config\ConfigFactory; |
15 | 14 | use Hal\Application\Extension\ExtensionService; |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | 'path', InputArgument::OPTIONAL, 'Path to explore' |
43 | 43 | ) |
44 | 44 | ->addOption( |
45 | - 'report-html',null, InputOption::VALUE_REQUIRED, 'Path to save report in HTML format. Example: /tmp/report.html' |
|
45 | + 'report-html', null, InputOption::VALUE_REQUIRED, 'Path to save report in HTML format. Example: /tmp/report.html' |
|
46 | 46 | ) |
47 | 47 | ->addOption( |
48 | 48 | 'report-xml', null, InputOption::VALUE_REQUIRED, 'Path to save summary report in XML format. Example: /tmp/report.xml' |
@@ -112,7 +112,7 @@ discard block |
||
112 | 112 | $config = $configFactory->factory($input); |
113 | 113 | |
114 | 114 | // files |
115 | - if(null === $config->getPath()->getBasePath()) { |
|
115 | + if (null === $config->getPath()->getBasePath()) { |
|
116 | 116 | throw new \LogicException('Please provide a path to analyze'); |
117 | 117 | } |
118 | 118 | |
@@ -125,8 +125,8 @@ discard block |
||
125 | 125 | |
126 | 126 | // prepare plugins |
127 | 127 | $repository = new Repository(); |
128 | - foreach($config->getExtensions()->getExtensions() as $filename) { |
|
129 | - if(!file_exists($filename) ||!is_readable($filename)) { |
|
128 | + foreach ($config->getExtensions()->getExtensions() as $filename) { |
|
129 | + if (!file_exists($filename) || !is_readable($filename)) { |
|
130 | 130 | $output->writeln(sprintf('<error>Plugin %s skipped: not found</error>', $filename)); |
131 | 131 | continue; |
132 | 132 | } |
@@ -150,8 +150,8 @@ discard block |
||
150 | 150 | $output->writeln(''); |
151 | 151 | |
152 | 152 | // provide data to extensions |
153 | - if(($n = sizeof($repository->all())) > 0) { |
|
154 | - $output->writeln(sprintf('%d %s. Executing analyzis', $n, ($n > 1 ? 'plugins are enabled' : 'plugin is enabled') )); |
|
153 | + if (($n = sizeof($repository->all())) > 0) { |
|
154 | + $output->writeln(sprintf('%d %s. Executing analyzis', $n, ($n > 1 ? 'plugins are enabled' : 'plugin is enabled'))); |
|
155 | 155 | $extensionService->receive($config, $collection, $aggregatedResults, $bounds); |
156 | 156 | } |
157 | 157 | |
@@ -165,7 +165,7 @@ discard block |
||
165 | 165 | |
166 | 166 | // evaluation of success |
167 | 167 | $rule = $config->getFailureCondition(); |
168 | - if(null !== $rule) { |
|
168 | + if (null !== $rule) { |
|
169 | 169 | $evaluator = new Evaluator($collection, $aggregatedResults, $bounds); |
170 | 170 | $result = $evaluator->evaluate($rule); |
171 | 171 | // fail if failure-condition is realized |
@@ -188,7 +188,7 @@ |
||
188 | 188 | } |
189 | 189 | |
190 | 190 | /** |
191 | - * @param array $extensions |
|
191 | + * @param ExtensionsConfiguration $extensions |
|
192 | 192 | * @return Configuration |
193 | 193 | */ |
194 | 194 | public function setExtensions($extensions) |
@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | $locator = new ConfigLocator(); |
38 | 38 | $filename = $locator->locate($input->getOption('config')); |
39 | 39 | |
40 | - if(null !== $filename) { |
|
40 | + if (null !== $filename) { |
|
41 | 41 | $loader = new Loader($hydrator); |
42 | 42 | $config = $loader->load($filename); |
43 | 43 | } else { |
@@ -46,21 +46,21 @@ discard block |
||
46 | 46 | |
47 | 47 | |
48 | 48 | // then, overwrite configuration by arguments provided in run |
49 | - strlen($input->getArgument('path')) > 0 && $config->getPath()->setBasePath($input->getArgument('path')); |
|
50 | - strlen($input->getOption('extensions')) > 0 && $config->getPath()->setExtensions($input->getOption('extensions')); |
|
51 | - strlen($input->getOption('excluded-dirs')) > 0 && $config->getPath()->setExcludedDirs($input->getOption('excluded-dirs')); |
|
52 | - strlen($input->getOption('symlinks')) > 0 && $config->getPath()->setFollowSymlinks(true); |
|
53 | - strlen($input->getOption('report-xml')) > 0 && $config->getLogging()->setReport('xml', $input->getOption('report-xml')); |
|
54 | - strlen($input->getOption('report-cli')) > 0 && $config->getLogging()->setReport('cli', $input->getOption('report-cli')); |
|
55 | - strlen($input->getOption('report-json')) > 0 && $config->getLogging()->setReport('json', $input->getOption('report-json')); |
|
56 | - strlen($input->getOption('report-html')) > 0 && $config->getLogging()->setReport('html', $input->getOption('report-html')); |
|
57 | - strlen($input->getOption('report-csv')) > 0 && $config->getLogging()->setReport('csv', $input->getOption('report-csv')); |
|
49 | + strlen($input->getArgument('path')) > 0 && $config->getPath()->setBasePath($input->getArgument('path')); |
|
50 | + strlen($input->getOption('extensions')) > 0 && $config->getPath()->setExtensions($input->getOption('extensions')); |
|
51 | + strlen($input->getOption('excluded-dirs')) > 0 && $config->getPath()->setExcludedDirs($input->getOption('excluded-dirs')); |
|
52 | + strlen($input->getOption('symlinks')) > 0 && $config->getPath()->setFollowSymlinks(true); |
|
53 | + strlen($input->getOption('report-xml')) > 0 && $config->getLogging()->setReport('xml', $input->getOption('report-xml')); |
|
54 | + strlen($input->getOption('report-cli')) > 0 && $config->getLogging()->setReport('cli', $input->getOption('report-cli')); |
|
55 | + strlen($input->getOption('report-json')) > 0 && $config->getLogging()->setReport('json', $input->getOption('report-json')); |
|
56 | + strlen($input->getOption('report-html')) > 0 && $config->getLogging()->setReport('html', $input->getOption('report-html')); |
|
57 | + strlen($input->getOption('report-csv')) > 0 && $config->getLogging()->setReport('csv', $input->getOption('report-csv')); |
|
58 | 58 | strlen($input->getOption('violations-xml')) > 0 && $config->getLogging()->setViolation('xml', $input->getOption('violations-xml')); |
59 | - strlen($input->getOption('chart-bubbles')) > 0 && $config->getLogging()->setChart('bubbles', $input->getOption('chart-bubbles')); |
|
60 | - strlen($input->getOption('failure-condition')) > 0 && $config->setFailureCondition($input->getOption('failure-condition')); |
|
59 | + strlen($input->getOption('chart-bubbles')) > 0 && $config->getLogging()->setChart('bubbles', $input->getOption('chart-bubbles')); |
|
60 | + strlen($input->getOption('failure-condition')) > 0 && $config->setFailureCondition($input->getOption('failure-condition')); |
|
61 | 61 | strlen($input->getOption('template-title')) > 0 && $config->getTemplate()->setTitle($input->getOption('template-title')); |
62 | 62 | strlen($input->getOption('offline')) > 0 && $config->getTemplate()->setOffline($input->getOption('offline')); |
63 | - strlen($input->getOption('plugins')) > 0 && $config->getExtensions()->setExtensions(explode(',', $input->getOption('plugins'))); |
|
63 | + strlen($input->getOption('plugins')) > 0 && $config->getExtensions()->setExtensions(explode(',', $input->getOption('plugins'))); |
|
64 | 64 | strlen($input->getOption('ignore-errors')) > 0 && $config->setIgnoreErrors(true); |
65 | 65 | |
66 | 66 | return $config; |
@@ -18,7 +18,7 @@ |
||
18 | 18 | /** |
19 | 19 | * @var Repository |
20 | 20 | */ |
21 | - private $repository; |
|
21 | + private $repository; |
|
22 | 22 | |
23 | 23 | /** |
24 | 24 | * ExtensionService constructor. |
@@ -47,7 +47,7 @@ |
||
47 | 47 | public function receive(Configuration $config, ResultCollection $collection, ResultCollection $aggregatedResults, Bounds $bounds) |
48 | 48 | { |
49 | 49 | // search controller |
50 | - foreach($this->repository->all() as $item) { |
|
50 | + foreach ($this->repository->all() as $item) { |
|
51 | 51 | $item->receive($config, $collection, $aggregatedResults, $bounds); |
52 | 52 | } |
53 | 53 | } |