|
| 1 | +<?php |
| 2 | + |
| 3 | +declare(strict_types=1); |
| 4 | + |
| 5 | +namespace Safe; |
| 6 | + |
| 7 | +use Symfony\Component\Console\Command\Command; |
| 8 | +use Symfony\Component\Console\Input\InputInterface; |
| 9 | +use Symfony\Component\Console\Input\InputArgument; |
| 10 | +use Symfony\Component\Console\Output\OutputInterface; |
| 11 | + |
| 12 | +class FunctionInfoCommand extends Command |
| 13 | +{ |
| 14 | + protected function configure(): void |
| 15 | + { |
| 16 | + $this |
| 17 | + ->setName('function-info') |
| 18 | + ->setDescription('Displays parsed info about a function.') |
| 19 | + ->addArgument('function', InputArgument::REQUIRED, 'The function name to display info about.') |
| 20 | + ; |
| 21 | + } |
| 22 | + |
| 23 | + protected function execute(InputInterface $input, OutputInterface $output): int |
| 24 | + { |
| 25 | + $scanner = new Scanner(__DIR__ . '/../doc/doc-en/en/reference/'); |
| 26 | + $res = $scanner->getMethods($scanner->getFunctionsPaths(), $output); |
| 27 | + |
| 28 | + foreach ($res->methods as $function) { |
| 29 | + $name = $function->getFunctionName(); |
| 30 | + if ($name == $input->getArgument("function")) { |
| 31 | + $output->writeln("Params: "); |
| 32 | + foreach ($function->getParams() as $param) { |
| 33 | + $output->writeln(" " . $param->getParameterName()); |
| 34 | + $output->writeln(" ParameterType: " . $param->getParameterType()); |
| 35 | + $output->writeln(" SignatureType: " . $param->getSignatureType()); |
| 36 | + $output->writeln(" DocBlockType: " . $param->getDocBlockType()); |
| 37 | + } |
| 38 | + $writePhpFunction = new WritePhpFunction($function); |
| 39 | + $output->writeln($writePhpFunction->getPhpFunctionalFunction()); |
| 40 | + break; |
| 41 | + } |
| 42 | + } |
| 43 | + |
| 44 | + return 0; |
| 45 | + } |
| 46 | +} |
0 commit comments