Coding Standards: Rename the $file parameter to $path in some WP_Filesystem_* methods.

This aims to bring more clarity to the code, and applies to methods where the path can be a file or a directory:

* `WP_Filesystem_*::exists()`
* `WP_Filesystem_*::is_writable()`

Follow-up to [6779], [25560].

See #55647.
Built from https://develop.svn.wordpress.org/trunk@53872


git-svn-id: http://core.svn.wordpress.org/trunk@53431 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Sergey Biryukov 2022-08-09 11:33:10 +00:00
parent 60d0586c27
commit c3783c9f3a
6 changed files with 38 additions and 38 deletions

View File

@ -663,10 +663,10 @@ class WP_Filesystem_Base {
* @since 2.5.0 * @since 2.5.0
* @abstract * @abstract
* *
* @param string $file Path to file or directory. * @param string $path Path to file or directory.
* @return bool Whether $file exists or not. * @return bool Whether $path exists or not.
*/ */
public function exists( $file ) { public function exists( $path ) {
return false; return false;
} }
@ -715,10 +715,10 @@ class WP_Filesystem_Base {
* @since 2.5.0 * @since 2.5.0
* @abstract * @abstract
* *
* @param string $file Path to file or directory. * @param string $path Path to file or directory.
* @return bool Whether $file is writable. * @return bool Whether $path is writable.
*/ */
public function is_writable( $file ) { public function is_writable( $path ) {
return false; return false;
} }

View File

@ -399,11 +399,11 @@ class WP_Filesystem_Direct extends WP_Filesystem_Base {
* *
* @since 2.5.0 * @since 2.5.0
* *
* @param string $file Path to file or directory. * @param string $path Path to file or directory.
* @return bool Whether $file exists or not. * @return bool Whether $path exists or not.
*/ */
public function exists( $file ) { public function exists( $path ) {
return @file_exists( $file ); return @file_exists( $path );
} }
/** /**
@ -447,11 +447,11 @@ class WP_Filesystem_Direct extends WP_Filesystem_Base {
* *
* @since 2.5.0 * @since 2.5.0
* *
* @param string $file Path to file or directory. * @param string $path Path to file or directory.
* @return bool Whether $file is writable. * @return bool Whether $path is writable.
*/ */
public function is_writable( $file ) { public function is_writable( $path ) {
return @is_writable( $file ); return @is_writable( $path );
} }
/** /**

View File

@ -415,15 +415,15 @@ class WP_Filesystem_FTPext extends WP_Filesystem_Base {
* @since 6.1.0 Uses WP_Filesystem_FTPext::is_dir() to check for directory existence * @since 6.1.0 Uses WP_Filesystem_FTPext::is_dir() to check for directory existence
* and ftp_rawlist() to check for file existence. * and ftp_rawlist() to check for file existence.
* *
* @param string $file Path to file or directory. * @param string $path Path to file or directory.
* @return bool Whether $file exists or not. * @return bool Whether $path exists or not.
*/ */
public function exists( $file ) { public function exists( $path ) {
if ( $this->is_dir( $file ) ) { if ( $this->is_dir( $path ) ) {
return true; return true;
} }
return ! empty( ftp_rawlist( $this->link, $file ) ); return ! empty( ftp_rawlist( $this->link, $path ) );
} }
/** /**
@ -475,10 +475,10 @@ class WP_Filesystem_FTPext extends WP_Filesystem_Base {
* *
* @since 2.5.0 * @since 2.5.0
* *
* @param string $file Path to file or directory. * @param string $path Path to file or directory.
* @return bool Whether $file is writable. * @return bool Whether $path is writable.
*/ */
public function is_writable( $file ) { public function is_writable( $path ) {
return true; return true;
} }

View File

@ -417,15 +417,15 @@ class WP_Filesystem_ftpsockets extends WP_Filesystem_Base {
* @since 6.1.0 Uses WP_Filesystem_ftpsockets::is_dir() to check for directory existence * @since 6.1.0 Uses WP_Filesystem_ftpsockets::is_dir() to check for directory existence
* and file size to check for file existence. * and file size to check for file existence.
* *
* @param string $file Path to file or directory. * @param string $path Path to file or directory.
* @return bool Whether $file exists or not. * @return bool Whether $path exists or not.
*/ */
public function exists( $file ) { public function exists( $path ) {
if ( $this->is_dir( $file ) ) { if ( $this->is_dir( $path ) ) {
return true; return true;
} }
return is_numeric( $this->size( $file ) ); return is_numeric( $this->size( $path ) );
} }
/** /**
@ -484,10 +484,10 @@ class WP_Filesystem_ftpsockets extends WP_Filesystem_Base {
* *
* @since 2.5.0 * @since 2.5.0
* *
* @param string $file Path to file or directory. * @param string $path Path to file or directory.
* @return bool Whether $file is writable. * @return bool Whether $path is writable.
*/ */
public function is_writable( $file ) { public function is_writable( $path ) {
return true; return true;
} }

View File

@ -557,11 +557,11 @@ class WP_Filesystem_SSH2 extends WP_Filesystem_Base {
* *
* @since 2.7.0 * @since 2.7.0
* *
* @param string $file Path to file or directory. * @param string $path Path to file or directory.
* @return bool Whether $file exists or not. * @return bool Whether $path exists or not.
*/ */
public function exists( $file ) { public function exists( $path ) {
return file_exists( $this->sftp_path( $file ) ); return file_exists( $this->sftp_path( $path ) );
} }
/** /**
@ -605,10 +605,10 @@ class WP_Filesystem_SSH2 extends WP_Filesystem_Base {
* *
* @since 2.7.0 * @since 2.7.0
* *
* @param string $file Path to file or directory. * @param string $path Path to file or directory.
* @return bool Whether $file is writable. * @return bool Whether $path is writable.
*/ */
public function is_writable( $file ) { public function is_writable( $path ) {
// PHP will base its writable checks on system_user === file_owner, not ssh_user === file_owner. // PHP will base its writable checks on system_user === file_owner, not ssh_user === file_owner.
return true; return true;
} }

View File

@ -16,7 +16,7 @@
* *
* @global string $wp_version * @global string $wp_version
*/ */
$wp_version = '6.1-alpha-53871'; $wp_version = '6.1-alpha-53872';
/** /**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema. * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.