wowstack /
php-dbc-parser
| 1 | <?php |
||||
| 2 | |||||
| 3 | declare(strict_types=1); |
||||
| 4 | |||||
| 5 | namespace Wowstack\Dbc\Command; |
||||
| 6 | |||||
| 7 | use Symfony\Component\Console\Command\Command; |
||||
| 8 | use Symfony\Component\Console\Input\InputArgument; |
||||
| 9 | use Symfony\Component\Console\Input\InputInterface; |
||||
| 10 | use Symfony\Component\Console\Input\InputOption; |
||||
| 11 | use Symfony\Component\Console\Output\OutputInterface; |
||||
| 12 | use Symfony\Component\Console\Style\SymfonyStyle; |
||||
| 13 | use Wowstack\Dbc\DBC; |
||||
| 14 | use Wowstack\Dbc\Mapping; |
||||
| 15 | use Wowstack\Dbc\Export\XMLExport; |
||||
| 16 | |||||
| 17 | /** |
||||
| 18 | * @codeCoverageIgnore |
||||
| 19 | */ |
||||
| 20 | class ExportCommand extends Command |
||||
| 21 | { |
||||
| 22 | /** |
||||
| 23 | * {@inheritdoc} |
||||
| 24 | */ |
||||
| 25 | protected function configure() |
||||
| 26 | { |
||||
| 27 | $this |
||||
| 28 | ->setName('dbc:export') |
||||
| 29 | ->setDescription('Dumps the contents of a DBC file.') |
||||
| 30 | ->setHelp('This command allows you to dump any DBC file using a file map.') |
||||
| 31 | ; |
||||
| 32 | |||||
| 33 | $this |
||||
| 34 | ->addArgument('file', InputArgument::REQUIRED, 'Path to the DBC file') |
||||
| 35 | ->addArgument('map', InputArgument::REQUIRED, 'Path to the YAML map') |
||||
| 36 | ->addArgument('xml', InputArgument::REQUIRED, 'Where to create the XML dump') |
||||
| 37 | ; |
||||
| 38 | |||||
| 39 | $this |
||||
| 40 | ->addOption( |
||||
| 41 | 'client-version', |
||||
| 42 | null, |
||||
| 43 | InputOption::VALUE_REQUIRED, |
||||
| 44 | 'WoW client version', |
||||
| 45 | '1.12.1' |
||||
| 46 | ); |
||||
| 47 | } |
||||
| 48 | |||||
| 49 | /** |
||||
| 50 | * {@inheritdoc} |
||||
| 51 | */ |
||||
| 52 | protected function execute(InputInterface $input, OutputInterface $output) |
||||
| 53 | { |
||||
| 54 | $DBC = new DBC($input->getArgument('file'), Mapping::fromYAML($input->getArgument('map'))); |
||||
|
0 ignored issues
–
show
Bug
introduced
by
Loading history...
It seems like
$input->getArgument('file') can also be of type null and string[]; however, parameter $path of Wowstack\Dbc\DBC::__construct() does only seem to accept string, maybe add an additional type check?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||
| 55 | $format = 'XML'; |
||||
| 56 | |||||
| 57 | $styledOutput = new SymfonyStyle($input, $output); |
||||
| 58 | $styledOutput->text([ |
||||
| 59 | sprintf( |
||||
| 60 | 'Dumping %s file contents in %s format to %s.', |
||||
| 61 | $DBC->getName(), |
||||
| 62 | $format, |
||||
| 63 | $input->getArgument('xml') |
||||
|
0 ignored issues
–
show
It seems like
$input->getArgument('xml') can also be of type string[]; however, parameter $args of sprintf() does only seem to accept string, maybe add an additional type check?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||
| 64 | ), |
||||
| 65 | '', |
||||
| 66 | ]); |
||||
| 67 | |||||
| 68 | $XMLExport = new XMLExport(); |
||||
| 69 | $XMLExport->export($DBC, $input->getArgument('xml'), $input->getOption('client-version')); |
||||
|
0 ignored issues
–
show
It seems like
$input->getArgument('xml') can also be of type null and string[]; however, parameter $targetPath of Wowstack\Dbc\Export\XMLExport::export() does only seem to accept string, maybe add an additional type check?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||
| 70 | |||||
| 71 | foreach ($DBC->getErrors() as $error) { |
||||
| 72 | $output->writeln([ |
||||
| 73 | '#'.$error['record'].' ('.$error['type'].'/'.$error['field'].'): '.$error['hint'], |
||||
|
0 ignored issues
–
show
|
|||||
| 74 | ]); |
||||
| 75 | } |
||||
| 76 | } |
||||
| 77 | } |
||||
| 78 |