diff --git a/plugins/woocommerce/src/Internal/Admin/Logging/FileV2/File.php b/plugins/woocommerce/src/Internal/Admin/Logging/FileV2/File.php index e31ea4e2de8..1bce0c7ce06 100644 --- a/plugins/woocommerce/src/Internal/Admin/Logging/FileV2/File.php +++ b/plugins/woocommerce/src/Internal/Admin/Logging/FileV2/File.php @@ -2,24 +2,37 @@ namespace Automattic\WooCommerce\Internal\Admin\Logging\FileV2; +/** + * File class. + * + * An object representation of a single log file. + */ class File { /** - * @var string The absolute path of the file. + * The absolute path of the file. + * + * @var string */ protected $path; /** - * @var string The source property of the file, derived from the filename. + * The source property of the file, derived from the filename. + * + * @var string */ protected $source; /** - * @var int The date the file was created, as a Unix timestamp, derived from the filename. + * The date the file was created, as a Unix timestamp, derived from the filename. + * + * @var int */ protected $created; /** - * @var string The key property of the file, derived from the filename. + * The key property of the file, derived from the filename. + * + * @var string */ protected $key; @@ -125,6 +138,6 @@ class File { * @return bool */ public function delete() { - return @unlink( $this->path ); + return @unlink( $this->path ); // phpcs:ignore WordPress.PHP.NoSilencedErrors.Discouraged } } diff --git a/plugins/woocommerce/src/Internal/Admin/Logging/FileV2/FileController.php b/plugins/woocommerce/src/Internal/Admin/Logging/FileV2/FileController.php index ab2786b9bde..e6675dea8be 100644 --- a/plugins/woocommerce/src/Internal/Admin/Logging/FileV2/FileController.php +++ b/plugins/woocommerce/src/Internal/Admin/Logging/FileV2/FileController.php @@ -10,7 +10,9 @@ use WP_Error; */ class FileController { /** - * @const array Default values for arguments for the get_files method. + * Default values for arguments for the get_files method. + * + * @const array */ public const DEFAULTS_GET_FILES = array( 'offset' => 0, @@ -21,7 +23,9 @@ class FileController { ); /** - * @var string The absolute path to the log directory. + * The absolute path to the log directory. + * + * @var string */ private $log_directory; @@ -51,7 +55,7 @@ class FileController { public function get_files( array $args = array(), bool $count_only = false ) { $args = wp_parse_args( $args, self::DEFAULTS_GET_FILES ); - $pattern = $args['source'] . '*' . '.log'; + $pattern = $args['source'] . '*.log'; $files = glob( $this->log_directory . $pattern ); if ( false === $files ) { @@ -90,7 +94,7 @@ class FileController { $comparison = $set[0] <=> $set[1]; } - if ( $comparison !== 0 ) { + if ( 0 !== $comparison ) { break; } } @@ -101,7 +105,7 @@ class FileController { switch ( $args['orderby'] ) { case 'created': $sort_callback = function( $a, $b ) use ( $args, $multi_sorter ) { - $sort_sets = array( + $sort_sets = array( array( $a->get_created_timestamp(), $b->get_created_timestamp() ), array( $a->get_source(), $b->get_source() ), ); @@ -111,7 +115,7 @@ class FileController { break; case 'modified': $sort_callback = function( $a, $b ) use ( $args, $multi_sorter ) { - $sort_sets = array( + $sort_sets = array( array( $a->get_modified_timestamp(), $b->get_modified_timestamp() ), array( $a->get_source(), $b->get_source() ), ); @@ -121,7 +125,7 @@ class FileController { break; case 'source': $sort_callback = function( $a, $b ) use ( $args, $multi_sorter ) { - $sort_sets = array( + $sort_sets = array( array( $a->get_source(), $b->get_source() ), array( $a->get_created_timestamp(), $b->get_created_timestamp() ), ); @@ -131,7 +135,7 @@ class FileController { break; case 'size': $sort_callback = function( $a, $b ) use ( $args, $multi_sorter ) { - $sort_sets = array( + $sort_sets = array( array( $a->get_file_size(), $b->get_file_size() ), array( $a->get_source(), $b->get_source() ), ); diff --git a/plugins/woocommerce/src/Internal/Admin/Logging/FileV2/ListTable.php b/plugins/woocommerce/src/Internal/Admin/Logging/FileV2/ListTable.php index ce7bcd0bf13..f08d7cf53bb 100644 --- a/plugins/woocommerce/src/Internal/Admin/Logging/FileV2/ListTable.php +++ b/plugins/woocommerce/src/Internal/Admin/Logging/FileV2/ListTable.php @@ -11,22 +11,30 @@ use WP_List_Table; */ class ListTable extends WP_List_Table { /** + * The user option key for saving the preferred number of files displayed per page. * @const string */ public const PER_PAGE_USER_OPTION_KEY = 'woocommerce_logging_file_list_per_page'; /** + * Instance of FileController. + * * @var FileController */ private $file_controller; /** + * Instance of PageController. + * * @var PageController */ private $page_controller; /** * ListTable class. + * + * @param FileController $file_controller Instance of FileController. + * @param PageController $page_controller Instance of PageController. */ public function __construct( FileController $file_controller, PageController $page_controller ) { $this->file_controller = $file_controller; @@ -76,7 +84,7 @@ class ListTable extends WP_List_Table { /** * Displays extra controls between bulk actions and pagination. * - * @param string $which + * @param string $which The location of the tablenav being rendered. 'top' or 'bottom'. * * @return void */ @@ -91,7 +99,7 @@ class ListTable extends WP_List_Table {