Skip to content

Conversation

@shish
Copy link
Collaborator

@shish shish commented Jan 30, 2025

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();
    }
}

@shish
Copy link
Collaborator Author

shish commented Jan 30, 2025

(The addition of a seemingly-unused $output parameter is to make this PR compatible with #530)

@shish shish force-pushed the pr531 branch 5 times, most recently from ef512fb to 6d60bf7 Compare January 31, 2025 06:32
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
$ 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();
    }
}
```
@shish shish merged commit ad0e6ab into master Feb 2, 2025
23 checks passed
@shish shish deleted the pr531 branch February 2, 2025 09:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants