wp/wp-admin/includes/class-wp-filesystem-base.php
changeset 21 48c4eec2b7e6
parent 19 3d72ae0968f4
--- a/wp/wp-admin/includes/class-wp-filesystem-base.php	Thu Sep 29 08:06:27 2022 +0200
+++ b/wp/wp-admin/includes/class-wp-filesystem-base.php	Fri Sep 05 18:40:08 2025 +0200
@@ -11,6 +11,7 @@
  *
  * @since 2.5.0
  */
+#[AllowDynamicProperties]
 class WP_Filesystem_Base {
 
 	/**
@@ -56,8 +57,10 @@
 	public function abspath() {
 		$folder = $this->find_folder( ABSPATH );
 
-		// Perhaps the FTP folder is rooted at the WordPress install.
-		// Check for wp-includes folder in root. Could have some false positives, but rare.
+		/*
+		 * Perhaps the FTP folder is rooted at the WordPress install.
+		 * Check for wp-includes folder in root. Could have some false positives, but rare.
+		 */
 		if ( ! $folder && $this->is_dir( '/' . WPINC ) ) {
 			$folder = '/';
 		}
@@ -213,13 +216,13 @@
 				}
 			}
 		} elseif ( 'direct' === $this->method ) {
-			$folder = str_replace( '\\', '/', $folder ); // Windows path sanitisation.
+			$folder = str_replace( '\\', '/', $folder ); // Windows path sanitization.
 
 			return trailingslashit( $folder );
 		}
 
 		$folder = preg_replace( '|^([a-z]{1}):|i', '', $folder ); // Strip out Windows drive letter if it's there.
-		$folder = str_replace( '\\', '/', $folder ); // Windows path sanitisation.
+		$folder = str_replace( '\\', '/', $folder ); // Windows path sanitization.
 
 		if ( isset( $this->cache[ $folder ] ) ) {
 			return $this->cache[ $folder ];
@@ -262,7 +265,7 @@
 
 		if ( $this->verbose ) {
 			/* translators: 1: Folder to locate, 2: Folder to start searching from. */
-			printf( "\n" . __( 'Looking for %1$s in %2$s' ) . "<br/>\n", $folder, $base );
+			printf( "\n" . __( 'Looking for %1$s in %2$s' ) . "<br />\n", $folder, $base );
 		}
 
 		$folder_parts     = explode( '/', $folder );
@@ -291,7 +294,7 @@
 
 				if ( $this->verbose ) {
 					/* translators: %s: Directory name. */
-					printf( "\n" . __( 'Changing to %s' ) . "<br/>\n", $newdir );
+					printf( "\n" . __( 'Changing to %s' ) . "<br />\n", $newdir );
 				}
 
 				// Only search for the remaining path tokens in the directory, not the full path again.
@@ -304,27 +307,32 @@
 			}
 		}
 
-		// Only check this as a last resort, to prevent locating the incorrect install.
-		// All above procedures will fail quickly if this is the right branch to take.
+		/*
+		 * Only check this as a last resort, to prevent locating the incorrect install.
+		 * All above procedures will fail quickly if this is the right branch to take.
+		 */
 		if ( isset( $files[ $last_path ] ) ) {
 			if ( $this->verbose ) {
 				/* translators: %s: Directory name. */
-				printf( "\n" . __( 'Found %s' ) . "<br/>\n", $base . $last_path );
+				printf( "\n" . __( 'Found %s' ) . "<br />\n", $base . $last_path );
 			}
 
 			return trailingslashit( $base . $last_path );
 		}
 
-		// Prevent this function from looping again.
-		// No need to proceed if we've just searched in `/`.
+		/*
+		 * Prevent this function from looping again.
+		 * No need to proceed if we've just searched in `/`.
+		 */
 		if ( $loop || '/' === $base ) {
 			return false;
 		}
 
-		// As an extra last resort, Change back to / if the folder wasn't found.
-		// This comes into effect when the CWD is /home/user/ but WP is at /var/www/....
+		/*
+		 * As an extra last resort, Change back to / if the folder wasn't found.
+		 * This comes into effect when the CWD is /home/user/ but WP is at /var/www/....
+		 */
 		return $this->search_for_folder( $folder, '/', true );
-
 	}
 
 	/**
@@ -397,7 +405,7 @@
 	}
 
 	/**
-	 * Converts *nix-style file permissions to a octal number.
+	 * Converts *nix-style file permissions to an octal number.
 	 *
 	 * Converts '-rw-r--r--' to 0644
 	 * From "info at rvgate dot nl"'s comment on the PHP documentation for chmod()
@@ -663,10 +671,10 @@
 	 * @since 2.5.0
 	 * @abstract
 	 *
-	 * @param string $file Path to file or directory.
-	 * @return bool Whether $file exists or not.
+	 * @param string $path Path to file or directory.
+	 * @return bool Whether $path exists or not.
 	 */
-	public function exists( $file ) {
+	public function exists( $path ) {
 		return false;
 	}
 
@@ -715,10 +723,10 @@
 	 * @since 2.5.0
 	 * @abstract
 	 *
-	 * @param string $file Path to file or directory.
-	 * @return bool Whether $file is writable.
+	 * @param string $path Path to file or directory.
+	 * @return bool Whether $path is writable.
 	 */
-	public function is_writable( $file ) {
+	public function is_writable( $path ) {
 		return false;
 	}
 
@@ -826,22 +834,31 @@
 	 * @param bool   $recursive      Optional. Whether to recursively include file details in nested directories.
 	 *                               Default false.
 	 * @return array|false {
-	 *     Array of files. False if unable to list directory contents.
+	 *     Array of arrays containing file information. False if unable to list directory contents.
+	 *
+	 *     @type array ...$0 {
+	 *         Array of file information. Note that some elements may not be available on all filesystems.
 	 *
-	 *     @type string $name        Name of the file or directory.
-	 *     @type string $perms       *nix representation of permissions.
-	 *     @type string $permsn      Octal representation of permissions.
-	 *     @type string $owner       Owner name or ID.
-	 *     @type int    $size        Size of file in bytes.
-	 *     @type int    $lastmodunix Last modified unix timestamp.
-	 *     @type mixed  $lastmod     Last modified month (3 letter) and day (without leading 0).
-	 *     @type int    $time        Last modified time.
-	 *     @type string $type        Type of resource. 'f' for file, 'd' for directory.
-	 *     @type mixed  $files       If a directory and `$recursive` is true, contains another array of files.
+	 *         @type string           $name        Name of the file or directory.
+	 *         @type string           $perms       *nix representation of permissions.
+	 *         @type string           $permsn      Octal representation of permissions.
+	 *         @type int|string|false $number      File number. May be a numeric string. False if not available.
+	 *         @type string|false     $owner       Owner name or ID, or false if not available.
+	 *         @type string|false     $group       File permissions group, or false if not available.
+	 *         @type int|string|false $size        Size of file in bytes. May be a numeric string.
+	 *                                             False if not available.
+	 *         @type int|string|false $lastmodunix Last modified unix timestamp. May be a numeric string.
+	 *                                             False if not available.
+	 *         @type string|false     $lastmod     Last modified month (3 letters) and day (without leading 0), or
+	 *                                             false if not available.
+	 *         @type string|false     $time        Last modified time, or false if not available.
+	 *         @type string           $type        Type of resource. 'f' for file, 'd' for directory, 'l' for link.
+	 *         @type array|false      $files       If a directory and `$recursive` is true, contains another array of
+	 *                                             files. False if unable to list directory contents.
+	 *     }
 	 * }
 	 */
 	public function dirlist( $path, $include_hidden = true, $recursive = false ) {
 		return false;
 	}
-
 }