emlynwest /
changelog
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
| 1 | <?php |
||
| 2 | /** |
||
| 3 | * PHP Version 5.6 |
||
| 4 | * @category Library |
||
| 5 | * @package ChangeLog |
||
| 6 | * @author Erwan Richard <[email protected]> |
||
| 7 | * @license MIT http://opensource.org/licenses/MIT |
||
| 8 | * @link https://github.com/stevewest/changelog |
||
| 9 | */ |
||
| 10 | |||
| 11 | namespace ChangeLog\Console; |
||
| 12 | |||
| 13 | use ChangeLog\ChangeLog; |
||
| 14 | use ChangeLog\IO\File; |
||
| 15 | use ChangeLog\Parser\KeepAChangeLog; |
||
| 16 | use ChangeLog\Release as LogRelease; |
||
| 17 | use ChangeLog\Renderer\KeepAChangeLog as KeepAChangeLogRenderer; |
||
| 18 | use Symfony\Component\Console\Input\InputArgument; |
||
| 19 | use Symfony\Component\Console\Input\InputInterface; |
||
| 20 | use Symfony\Component\Console\Input\InputOption; |
||
| 21 | use Symfony\Component\Console\Output\OutputInterface; |
||
| 22 | |||
| 23 | /** |
||
| 24 | * Converts a release between formats. |
||
| 25 | */ |
||
| 26 | class Merge extends AbstractCommand |
||
| 27 | { |
||
| 28 | /** |
||
| 29 | * @return string |
||
| 30 | * @codeCoverageIgnore |
||
| 31 | */ |
||
| 32 | public function getDescription() |
||
| 33 | { |
||
| 34 | return 'Merge two or more changelog into one.'; |
||
| 35 | } |
||
| 36 | |||
| 37 | 1 | protected function configure() |
|
| 38 | { |
||
| 39 | 1 | parent::configure(); |
|
| 40 | |||
| 41 | 1 | $this->addArgument( |
|
| 42 | 1 | 'files', |
|
| 43 | 1 | InputArgument::IS_ARRAY, |
|
| 44 | 'Changelog to merge.' |
||
| 45 | 1 | ); |
|
| 46 | 1 | } |
|
| 47 | |||
| 48 | 1 | public function execute(InputInterface $input, OutputInterface $output) |
|
| 49 | { |
||
| 50 | 1 | parent::execute($input, $output); |
|
| 51 | |||
| 52 | // Parse existing CHANGELOG |
||
| 53 | 1 | $logs = $this->changeLog->parse(); |
|
| 54 | |||
| 55 | 1 | $files = $input->getArgument('files'); |
|
| 56 | 1 | foreach ($files as $f) { |
|
|
0 ignored issues
–
show
|
|||
| 57 | // Merge each file |
||
| 58 | 1 | $this->changeLog->setInput(new File(['file' => $f])); |
|
| 59 | 1 | $logs->mergeLog($this->changeLog->parse()); |
|
| 60 | 1 | } |
|
| 61 | |||
| 62 | // Write updated CHANGELOG |
||
| 63 | 1 | $this->changeLog->write($logs); |
|
| 64 | 1 | } |
|
| 65 | } |
||
| 66 |
There are different options of fixing this problem.
If you want to be on the safe side, you can add an additional type-check:
If you are sure that the expression is traversable, you might want to add a doc comment cast to improve IDE auto-completion and static analysis:
Mark the issue as a false-positive: Just hover the remove button, in the top-right corner of this issue for more options.