Skip to content

implode() refers to wrong parameter name #9667

@adrenth

Description

@adrenth

Description

The following code:

<?php

private function getRawExecResponseCode($command)
{
    $response = @ftp_raw($this->connection, trim($command));

    return (int) preg_replace('/\D/', '', implode(' ', $response)); // <---- line 577; $response is of type `string`
}

For complete file see: https://github.com/thephpleague/flysystem/blob/1.x/src/Adapter/Ftp.php#L577

Resulted in this output:

In Ftp.php line 577:
 implode(): Argument #1 ($pieces) must be of type array, string given

But I expected this output instead:

$result = $this->getRawExecResponseCode('CWD mydirectory');

echo $result;

// 250

Apparently the native ftp_raw method returns a string as return value instead of array|null.

Setting the connection configuration passive = true fixes the issue for now.
But this kind of type errors should not occur.

Related to: thephpleague/flysystem#1481

PHP Version

PHP 8.0.19

Operating System

CentOS Linux release 7.9.2009 (Core)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions