| Conditions | 2 |
| Paths | 2 |
| Total Lines | 22 |
| Code Lines | 17 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 15 |
| CRAP Score | 2 |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 34 | 1 | protected function execute(InputInterface $input, OutputInterface $output) |
|
| 35 | { |
||
| 36 | 1 | $object = $input->getArgument('object'); |
|
| 37 | 1 | $classes = (array) ClassInfo::subclassesFor($object); |
|
| 38 | // Remove the class itself |
||
| 39 | 1 | array_shift($classes); |
|
| 40 | 1 | if (!$classes) { |
|
|
|
|||
| 41 | $output->writeln('There are no child classes for ' . $object); |
||
| 42 | return; |
||
| 43 | } |
||
| 44 | 1 | sort($classes); |
|
| 45 | 1 | $rows = array_map(function ($class) { |
|
| 46 | 1 | return [$class]; |
|
| 47 | 1 | }, $classes); |
|
| 48 | |||
| 49 | 1 | $output->writeln('<info>Child classes for ' . $object . ':</info>'); |
|
| 50 | 1 | $table = new Table($output); |
|
| 51 | $table |
||
| 52 | 1 | ->setHeaders(['Class name']) |
|
| 53 | 1 | ->setRows($rows) |
|
| 54 | 1 | ->render(); |
|
| 55 | 1 | } |
|
| 56 | } |
||
| 57 |
This check marks implicit conversions of arrays to boolean values in a comparison. While in PHP an empty array is considered to be equal (but not identical) to false, this is not always apparent.
Consider making the comparison explicit by using
empty(..)or! empty(...)instead.