Skip to content

Commit 2f178fa

Browse files
authored
Merge pull request #214 from jrfnl/feature/cs-fixes-4
PHPCS: fix up the code base [4] - assignments in conditions
2 parents 9bd1774 + 8edaf2e commit 2f178fa

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

src/Scaffold_Command.php

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,8 @@ private function _scaffold( $slug, $assoc_args, $defaults, $subdir, $templates )
181181
$final_output = $raw_output;
182182
}
183183

184-
if ( $path = $this->get_output_path( $control_args, $subdir ) ) {
184+
$path = $this->get_output_path( $control_args, $subdir );
185+
if ( is_string( $path ) && ! empty( $path ) ) {
185186
$filename = "{$path}{$slug}.php";
186187

187188
$force = \WP_CLI\Utils\get_flag_value( $assoc_args, 'force' );
@@ -365,7 +366,8 @@ public function _s( $args, $assoc_args ) {
365366

366367
$_s_theme_path = "$theme_path/$data[theme_name]";
367368

368-
if ( $error_msg = $this->check_target_directory( 'theme', $_s_theme_path ) ) {
369+
$error_msg = $this->check_target_directory( 'theme', $_s_theme_path );
370+
if ( ! empty( $error_msg ) ) {
369371
WP_CLI::error( "Invalid theme slug specified. {$error_msg}" );
370372
}
371373

@@ -509,7 +511,8 @@ public function child_theme( $args, $assoc_args ) {
509511

510512
$theme_dir = WP_CONTENT_DIR . "/themes/{$theme_slug}";
511513

512-
if ( $error_msg = $this->check_target_directory( 'theme', $theme_dir ) ) {
514+
$error_msg = $this->check_target_directory( 'theme', $theme_dir );
515+
if ( ! empty( $error_msg ) ) {
513516
WP_CLI::error( "Invalid theme slug specified. {$error_msg}" );
514517
}
515518

@@ -665,7 +668,8 @@ public function plugin( $args, $assoc_args ) {
665668
$plugin_dir = WP_PLUGIN_DIR . "/{$plugin_slug}";
666669
$this->maybe_create_plugins_dir();
667670

668-
if ( $error_msg = $this->check_target_directory( 'plugin', $plugin_dir ) ) {
671+
$error_msg = $this->check_target_directory( 'plugin', $plugin_dir );
672+
if ( ! empty( $error_msg ) ) {
669673
WP_CLI::error( "Invalid plugin slug specified. {$error_msg}" );
670674
}
671675
}
@@ -831,7 +835,9 @@ private function scaffold_plugin_theme_tests( $args, $assoc_args, $type ) {
831835
if ( empty( $assoc_args['dir'] ) && ! is_dir( $target_dir ) ) {
832836
WP_CLI::error( "Invalid {$type} slug specified. No such target directory '{$target_dir}'." );
833837
}
834-
if ( $error_msg = $this->check_target_directory( $type, $target_dir ) ) {
838+
839+
$error_msg = $this->check_target_directory( $type, $target_dir );
840+
if ( ! empty( $error_msg ) ) {
835841
WP_CLI::error( "Invalid {$type} slug specified. {$error_msg}" );
836842
}
837843
}

0 commit comments

Comments
 (0)