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-2012 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\Command; |
||
14 | |||
15 | use Cilex\Provider\Console\Command as BaseCommand; |
||
16 | use Symfony\Component\Console\Helper\HelperSet; |
||
17 | use Symfony\Component\Console\Helper\ProgressHelper; |
||
18 | use Symfony\Component\Console\Input\InputInterface; |
||
19 | |||
20 | /** |
||
21 | * Base command for phpDocumentor commands. |
||
22 | * |
||
23 | * Includes additional methods to forward the output to the logging events |
||
24 | * of phpDocumentor. |
||
25 | */ |
||
26 | class Command extends BaseCommand |
||
27 | { |
||
28 | /** |
||
29 | * Registers the current command. |
||
30 | * |
||
31 | * @param HelperSet $helperSet |
||
32 | */ |
||
33 | 1 | public function setHelperSet(HelperSet $helperSet) |
|
34 | { |
||
35 | 1 | parent::setHelperSet($helperSet); |
|
36 | |||
37 | 1 | $this->getHelper('phpdocumentor_logger')->addOptions($this); |
|
0 ignored issues
–
show
|
|||
38 | 1 | } |
|
39 | |||
40 | /** |
||
41 | * Returns the Progress bar helper. |
||
42 | * |
||
43 | * With this helper it is possible to display a progress bar and make it fill. |
||
44 | * |
||
45 | * @param InputInterface $input |
||
46 | * |
||
47 | * @return ProgressHelper |
||
48 | */ |
||
49 | 2 | protected function getProgressBar(InputInterface $input) |
|
50 | { |
||
51 | 2 | if (!$input->getOption('progressbar')) { |
|
52 | 1 | return null; |
|
53 | } |
||
54 | |||
55 | 1 | return $this->getHelperSet()->get('progress'); |
|
56 | } |
||
57 | } |
||
58 |
Let’s take a look at an example:
In the above example, the authenticate() method works fine as long as you just pass instances of MyUser. However, if you now also want to pass a different implementation of User which does not have a getDisplayName() method, the code will break.
Available Fixes
Change the type-hint for the parameter:
Add an additional type-check:
Add the method to the interface: