Skip to content

Commit 0b4f073

Browse files
committed
Lint fix
1 parent 89767b4 commit 0b4f073

File tree

3 files changed

+12
-11
lines changed

3 files changed

+12
-11
lines changed

src/Plugin_Command.php

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,9 @@
33
use WP_CLI\CommandWithUpgrade;
44
use WP_CLI\ParsePluginNameInput;
55
use WP_CLI\Utils;
6+
use WP_CLI\Path;
67
use WP_CLI\WpOrgApi;
78

8-
use function WP_CLI\Utils\normalize_path;
9-
109
/**
1110
* Manages plugins, including installs, activations, and updates.
1211
*
@@ -1003,7 +1002,7 @@ protected function get_item_list() {
10031002
];
10041003

10051004
if ( $this->check_headers['tested_up_to'] ) {
1006-
$plugin_readme = normalize_path( dirname( WP_PLUGIN_DIR . '/' . $file ) . '/readme.txt' );
1005+
$plugin_readme = Path::normalize( dirname( WP_PLUGIN_DIR . '/' . $file ) . '/readme.txt' );
10071006

10081007
if ( file_exists( $plugin_readme ) && is_readable( $plugin_readme ) ) {
10091008
$readme_obj = new SplFileObject( $plugin_readme );
@@ -2026,7 +2025,7 @@ protected function get_status( $file ) {
20262025
* Gets the template path based on installation type.
20272026
*/
20282027
private static function get_template_path( $template ) {
2029-
$command_root = Utils\phar_safe_path( dirname( __DIR__ ) );
2028+
$command_root = Path::phar_safe( dirname( __DIR__ ) );
20302029
$template_path = "{$command_root}/templates/{$template}";
20312030

20322031
if ( ! file_exists( $template_path ) ) {
@@ -2044,7 +2043,7 @@ private static function get_template_path( $template ) {
20442043
*/
20452044
private function get_details( $file ) {
20462045
$plugin_folder = get_plugins( '/' . plugin_basename( dirname( $file ) ) );
2047-
$plugin_file = Utils\basename( $file );
2046+
$plugin_file = Path::basename( $file );
20482047

20492048
return $plugin_folder[ $plugin_file ];
20502049
}

src/Theme_Command.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
use WP_CLI\CommandWithUpgrade;
44
use WP_CLI\ParseThemeNameInput;
55
use WP_CLI\Utils;
6+
use WP_CLI\Path;
67

78
/**
89
* Manages themes, including installs, activations, and updates.
@@ -1074,7 +1075,7 @@ public function list_( $_, $assoc_args ) {
10741075
* Gets the template path based on installation type.
10751076
*/
10761077
private static function get_template_path( $template ) {
1077-
$command_root = Utils\phar_safe_path( dirname( __DIR__ ) );
1078+
$command_root = Path::phar_safe( dirname( __DIR__ ) );
10781079
$template_path = "{$command_root}/templates/{$template}";
10791080

10801081
if ( ! file_exists( $template_path ) ) {

src/WP_CLI/CommandWithUpgrade.php

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
use WP_CLI\Fetchers;
1010
use WP_CLI\Loggers;
1111
use WP_CLI\Utils;
12+
use WP_CLI\Path;
1213
use WP_Error;
1314

1415
/**
@@ -284,7 +285,7 @@ public function install( $args, $assoc_args ) {
284285
*/
285286
global $wp_filesystem;
286287

287-
$source_dir = Utils\basename( $source ); // `$source` is trailing-slashed path to the unzipped archive directory.
288+
$source_dir = Path::basename( $source ); // `$source` is trailing-slashed path to the unzipped archive directory.
288289
if ( $source_dir === $custom_slug ) {
289290
return $source;
290291
}
@@ -314,15 +315,15 @@ public function install( $args, $assoc_args ) {
314315
* @var string $path
315316
*/
316317
$path = Utils\parse_url( $slug, PHP_URL_PATH );
317-
$slug_dir = Utils\basename( $path, '.zip' );
318+
$slug_dir = Path::basename( $path, '.zip' );
318319

319320
// Don't use the zip name if archive attached to release, as name likely to contain version tag/branch.
320321
if ( preg_match( '#github\.com/[^/]+/([^/]+)/archive/#', $slug, $matches ) ) {
321322
// Note this will be wrong if the project name isn't the same as the plugin/theme slug name.
322323
$slug_dir = $matches[1];
323324
}
324325

325-
$source_dir = Utils\basename( $source ); // `$source` is trailing-slashed path to the unzipped archive directory, so basename returns the unslashed directory.
326+
$source_dir = Path::basename( $source ); // `$source` is trailing-slashed path to the unzipped archive directory, so basename returns the unslashed directory.
326327
if ( $source_dir === $slug_dir ) {
327328
return $source;
328329
}
@@ -430,10 +431,10 @@ protected function install_from_php_file( $url, $assoc_args ) {
430431

431432
// Extract and validate filename before downloading.
432433
$url_path = (string) Utils\parse_url( $url, PHP_URL_PATH );
433-
$filename = Utils\basename( $url_path );
434+
$filename = Path::basename( $url_path );
434435

435436
// Validate the filename doesn't contain directory separators or relative path components.
436-
// Note: Utils\basename() already strips directory components (including ".."), so this check
437+
// Note: Path::basename() already strips directory components (including ".."), so this check
437438
// is primarily a defense-in-depth safeguard in case its behavior changes or is bypassed.
438439
if ( strpos( $filename, '/' ) !== false || strpos( $filename, '\\' ) !== false || strpos( $filename, '..' ) !== false ) {
439440
return new WP_Error( 'invalid_filename', 'The filename contains invalid path components.' );

0 commit comments

Comments
 (0)