[php-src] Issue #9667: ftp_raw returns string instead of array|null

From: Date: Tue, 04 Oct 2022 08:54:14 +0000
Subject: [php-src] Issue #9667: ftp_raw returns string instead of array|null
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-242518@lists.php.net to get a copy of this message
Issue: https://github.com/php/php-src/issues/9667 Author: adrenth ### Description The following code: ```php <?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: https://github.com/thephpleague/flysystem/issues/1481 ### PHP Version PHP 8.0.19 ### Operating System CentOS Linux release 7.9.2009 (Core)

« previous php.bugs (#242518) next »