-
-
Notifications
You must be signed in to change notification settings - Fork 159
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
I'm trying to figure out why some functions claim to take a `resource` when they actually take a `FTP\Connection` or a `GdImage` -- this CLI command helps with debugging. Example: ``` $ php ./generator/safe.php function-info ftp_alloc Params: ftp ParameterType: FTP\Connection SignatureType: DocBlockType: resource size ParameterType: int SignatureType: int DocBlockType: int response ParameterType: string SignatureType: ?string DocBlockType: string|null /** * Sends an ALLO command to the remote FTP server to * allocate space for a file to be uploaded. * * @param resource $ftp An FTP\Connection instance. * @param int $size The number of bytes to allocate. * @param string|null $response A textual representation of the servers response will be returned by * reference in response if a variable is provided. * @throws FtpException * */ function ftp_alloc($ftp, int $size, ?string &$response = null): void { error_clear_last(); $safeResult = \ftp_alloc($ftp, $size, $response); if ($safeResult === false) { throw FtpException::createFromPhpError(); } } ```
- Loading branch information
Showing
6 changed files
with
53 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Safe; | ||
|
||
use Symfony\Component\Console\Command\Command; | ||
use Symfony\Component\Console\Input\InputInterface; | ||
use Symfony\Component\Console\Input\InputArgument; | ||
use Symfony\Component\Console\Output\OutputInterface; | ||
|
||
class FunctionInfoCommand extends Command | ||
{ | ||
protected function configure(): void | ||
{ | ||
$this | ||
->setName('function-info') | ||
->setDescription('Displays parsed info about a function.') | ||
->addArgument('function', InputArgument::REQUIRED, 'The function name to display info about.') | ||
; | ||
} | ||
|
||
protected function execute(InputInterface $input, OutputInterface $output): int | ||
{ | ||
$scanner = new Scanner(__DIR__ . '/../doc/doc-en/en/reference/'); | ||
$res = $scanner->getMethods($scanner->getFunctionsPaths(), $output); | ||
|
||
foreach ($res->methods as $function) { | ||
$name = $function->getFunctionName(); | ||
if ($name == $input->getArgument("function")) { | ||
$output->writeln("Params: "); | ||
foreach ($function->getParams() as $param) { | ||
$output->writeln(" " . $param->getParameterName()); | ||
$output->writeln(" ParameterType: " . $param->getParameterType()); | ||
$output->writeln(" SignatureType: " . $param->getSignatureType()); | ||
$output->writeln(" DocBlockType: " . $param->getDocBlockType()); | ||
} | ||
$writePhpFunction = new WritePhpFunction($function); | ||
$output->writeln($writePhpFunction->getPhpFunctionalFunction()); | ||
break; | ||
} | ||
} | ||
|
||
return 0; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters