These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | /** |
||
3 | * phpDocumentor |
||
4 | * |
||
5 | * PHP Version 5.3 |
||
6 | * |
||
7 | * @author Mike van Riel <[email protected]> |
||
8 | * @copyright 2010-2018 Mike van Riel / Naenius. (http://www.naenius.com) |
||
9 | * @license http://www.opensource.org/licenses/mit-license.php MIT |
||
10 | * @link http://phpdoc.org |
||
11 | */ |
||
12 | |||
13 | namespace phpDocumentor\Application\Console\Command; |
||
14 | |||
15 | use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand as BaseCommand; |
||
16 | use Symfony\Component\Console\Helper\HelperSet; |
||
17 | use Symfony\Component\Console\Helper\ProgressBar; |
||
18 | use Symfony\Component\Console\Input\InputInterface; |
||
19 | use Symfony\Component\Console\Output\OutputInterface; |
||
20 | |||
21 | /** |
||
22 | * Base command for phpDocumentor commands. |
||
23 | * |
||
24 | * Includes additional methods to forward the output to the logging events |
||
25 | * of phpDocumentor. |
||
26 | */ |
||
27 | abstract class Command extends BaseCommand |
||
28 | { |
||
29 | /** |
||
30 | * Registers the current command. |
||
31 | */ |
||
32 | 1 | public function setHelperSet(HelperSet $helperSet) |
|
33 | { |
||
34 | 1 | parent::setHelperSet($helperSet); |
|
35 | // |
||
0 ignored issues
–
show
|
|||
36 | // $this->getHelper('phpdocumentor_logger')->addOptions($this); |
||
37 | 1 | } |
|
38 | |||
39 | /** |
||
40 | * Executes a callable piece of code and writes an entry to the log detailing how long it took. |
||
41 | */ |
||
42 | protected function writeTimedLog(OutputInterface $output, $message, $operation, array $arguments = []) |
||
43 | { |
||
44 | $output->write(sprintf('%-66.66s .. ', $message)); |
||
45 | $timerStart = microtime(true); |
||
46 | |||
47 | call_user_func_array($operation, $arguments); |
||
48 | |||
49 | $output->writeln(sprintf('%8.3fs', microtime(true) - $timerStart)); |
||
50 | } |
||
51 | |||
52 | public function getService(string $name) |
||
53 | { |
||
54 | return $this->getContainer()->get($name); |
||
55 | } |
||
56 | |||
57 | /** |
||
58 | * Returns the Progress bar helper. |
||
59 | * |
||
60 | * With this helper it is possible to display a progress bar and make it fill. |
||
61 | * |
||
62 | * @return ProgressBar |
||
63 | */ |
||
64 | 2 | protected function getProgressBar(InputInterface $input) |
|
65 | { |
||
66 | 2 | if (!$input->getOption('progressbar')) { |
|
67 | 1 | return null; |
|
68 | } |
||
69 | |||
70 | 1 | return $this->getHelperSet()->get('progress'); |
|
71 | } |
||
72 | } |
||
73 |
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.
The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.
This check looks for comments that seem to be mostly valid code and reports them.