Make WordPress Core

Changeset 53872


Ignore:
Timestamp:
08/09/2022 11:32:01 AM (4 years ago)
Author:
SergeyBiryukov
Message:

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.

Location:
trunk/src/wp-admin/includes
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/includes/class-wp-filesystem-base.php

    r53014 r53872  
    664664         * @abstract
    665665         *
    666          * @param string $file Path to file or directory.
    667          * @return bool Whether $file exists or not.
    668          */
    669         public function exists( $file ) {
     666         * @param string $path Path to file or directory.
     667         * @return bool Whether $path exists or not.
     668         */
     669        public function exists( $path ) {
    670670                return false;
    671671        }
     
    716716         * @abstract
    717717         *
    718          * @param string $file Path to file or directory.
    719          * @return bool Whether $file is writable.
    720          */
    721         public function is_writable( $file ) {
     718         * @param string $path Path to file or directory.
     719         * @return bool Whether $path is writable.
     720         */
     721        public function is_writable( $path ) {
    722722                return false;
    723723        }
  • trunk/src/wp-admin/includes/class-wp-filesystem-direct.php

    r52332 r53872  
    400400         * @since 2.5.0
    401401         *
    402          * @param string $file Path to file or directory.
    403          * @return bool Whether $file exists or not.
    404          */
    405         public function exists( $file ) {
    406                 return @file_exists( $file );
     402         * @param string $path Path to file or directory.
     403         * @return bool Whether $path exists or not.
     404         */
     405        public function exists( $path ) {
     406                return @file_exists( $path );
    407407        }
    408408
     
    448448         * @since 2.5.0
    449449         *
    450          * @param string $file Path to file or directory.
    451          * @return bool Whether $file is writable.
    452          */
    453         public function is_writable( $file ) {
    454                 return @is_writable( $file );
     450         * @param string $path Path to file or directory.
     451         * @return bool Whether $path is writable.
     452         */
     453        public function is_writable( $path ) {
     454                return @is_writable( $path );
    455455        }
    456456
  • trunk/src/wp-admin/includes/class-wp-filesystem-ftpext.php

    r53862 r53872  
    416416         *              and ftp_rawlist() to check for file existence.
    417417         *
    418          * @param string $file Path to file or directory.
    419          * @return bool Whether $file exists or not.
    420          */
    421         public function exists( $file ) {
    422                 if ( $this->is_dir( $file ) ) {
     418         * @param string $path Path to file or directory.
     419         * @return bool Whether $path exists or not.
     420         */
     421        public function exists( $path ) {
     422                if ( $this->is_dir( $path ) ) {
    423423                        return true;
    424424                }
    425425
    426                 return ! empty( ftp_rawlist( $this->link, $file ) );
     426                return ! empty( ftp_rawlist( $this->link, $path ) );
    427427        }
    428428
     
    476476         * @since 2.5.0
    477477         *
    478          * @param string $file Path to file or directory.
    479          * @return bool Whether $file is writable.
    480          */
    481         public function is_writable( $file ) {
     478         * @param string $path Path to file or directory.
     479         * @return bool Whether $path is writable.
     480         */
     481        public function is_writable( $path ) {
    482482                return true;
    483483        }
  • trunk/src/wp-admin/includes/class-wp-filesystem-ftpsockets.php

    r53862 r53872  
    418418         *              and file size to check for file existence.
    419419         *
    420          * @param string $file Path to file or directory.
    421          * @return bool Whether $file exists or not.
    422          */
    423         public function exists( $file ) {
    424                 if ( $this->is_dir( $file ) ) {
     420         * @param string $path Path to file or directory.
     421         * @return bool Whether $path exists or not.
     422         */
     423        public function exists( $path ) {
     424                if ( $this->is_dir( $path ) ) {
    425425                        return true;
    426426                }
    427427
    428                 return is_numeric( $this->size( $file ) );
     428                return is_numeric( $this->size( $path ) );
    429429        }
    430430
     
    485485         * @since 2.5.0
    486486         *
    487          * @param string $file Path to file or directory.
    488          * @return bool Whether $file is writable.
    489          */
    490         public function is_writable( $file ) {
     487         * @param string $path Path to file or directory.
     488         * @return bool Whether $path is writable.
     489         */
     490        public function is_writable( $path ) {
    491491                return true;
    492492        }
  • trunk/src/wp-admin/includes/class-wp-filesystem-ssh2.php

    r52807 r53872  
    558558         * @since 2.7.0
    559559         *
    560          * @param string $file Path to file or directory.
    561          * @return bool Whether $file exists or not.
    562          */
    563         public function exists( $file ) {
    564                 return file_exists( $this->sftp_path( $file ) );
     560         * @param string $path Path to file or directory.
     561         * @return bool Whether $path exists or not.
     562         */
     563        public function exists( $path ) {
     564                return file_exists( $this->sftp_path( $path ) );
    565565        }
    566566
     
    606606         * @since 2.7.0
    607607         *
    608          * @param string $file Path to file or directory.
    609          * @return bool Whether $file is writable.
    610          */
    611         public function is_writable( $file ) {
     608         * @param string $path Path to file or directory.
     609         * @return bool Whether $path is writable.
     610         */
     611        public function is_writable( $path ) {
    612612                // PHP will base its writable checks on system_user === file_owner, not ssh_user === file_owner.
    613613                return true;
Note: See TracChangeset for help on using the changeset viewer.