@@ -71,15 +71,15 @@ public function post_type( $args, $assoc_args ) {
7171 WP_CLI ::error ( 'Post type slugs cannot exceed 20 characters in length. ' );
7272 }
7373
74- $ defaults = array (
74+ $ defaults = [
7575 'textdomain ' => '' ,
7676 'dashicon ' => 'admin-post ' ,
77- ) ;
77+ ] ;
7878
79- $ templates = array (
79+ $ templates = [
8080 'post_type.mustache ' ,
8181 'post_type_extended.mustache ' ,
82- ) ;
82+ ] ;
8383
8484 $ this ->scaffold ( $ args [0 ], $ assoc_args , $ defaults , '/post-types/ ' , $ templates );
8585 }
@@ -124,32 +124,32 @@ public function post_type( $args, $assoc_args ) {
124124 * @alias tax
125125 */
126126 public function taxonomy ( $ args , $ assoc_args ) {
127- $ defaults = array (
127+ $ defaults = [
128128 'textdomain ' => '' ,
129129 'post_types ' => "'post' " ,
130- ) ;
130+ ] ;
131131
132132 if ( isset ( $ assoc_args ['post_types ' ] ) ) {
133133 $ assoc_args ['post_types ' ] = $ this ->quote_comma_list_elements ( $ assoc_args ['post_types ' ] );
134134 }
135135
136- $ templates = array (
136+ $ templates = [
137137 'taxonomy.mustache ' ,
138138 'taxonomy_extended.mustache ' ,
139- ) ;
139+ ] ;
140140
141141 $ this ->scaffold ( $ args [0 ], $ assoc_args , $ defaults , '/taxonomies/ ' , $ templates );
142142 }
143143
144144 private function scaffold ( $ slug , $ assoc_args , $ defaults , $ subdir , $ templates ) {
145145 $ wp_filesystem = $ this ->init_wp_filesystem ();
146146
147- $ control_defaults = array (
147+ $ control_defaults = [
148148 'label ' => preg_replace ( '/_|-/ ' , ' ' , strtolower ( $ slug ) ),
149149 'theme ' => false ,
150150 'plugin ' => false ,
151151 'raw ' => false ,
152- ) ;
152+ ] ;
153153 $ control_args = $ this ->extract_args ( $ assoc_args , $ control_defaults );
154154
155155 $ vars = $ this ->extract_args ( $ assoc_args , $ defaults );
@@ -190,7 +190,7 @@ private function scaffold( $slug, $assoc_args, $defaults, $subdir, $templates )
190190 $ filename = "{$ path }{$ slug }.php " ;
191191
192192 $ force = Utils \get_flag_value ( $ assoc_args , 'force ' );
193- $ files_written = $ this ->create_files ( array ( $ filename => $ final_output ) , $ force );
193+ $ files_written = $ this ->create_files ( [ $ filename => $ final_output ] , $ force );
194194 $ skip_message = "Skipped creating ' {$ filename }'. " ;
195195 $ success_message = "Created ' {$ filename }'. " ;
196196 $ this ->log_whether_files_written ( $ files_written , $ skip_message , $ success_message );
@@ -269,10 +269,10 @@ public function block( $args, $assoc_args ) {
269269 WP_CLI ::error ( 'Invalid block slug specified. Block slugs can contain only lowercase alphanumeric characters or dashes, and start with a letter. ' );
270270 }
271271
272- $ defaults = array (
272+ $ defaults = [
273273 'title ' => str_replace ( '- ' , ' ' , $ slug ),
274274 'category ' => 'widgets ' ,
275- ) ;
275+ ] ;
276276 $ data = $ this ->extract_args ( $ assoc_args , $ defaults );
277277
278278 $ data ['slug ' ] = $ slug ;
@@ -284,11 +284,11 @@ public function block( $args, $assoc_args ) {
284284 $ data ['dashicon ' ] = $ dashicon ;
285285 }
286286
287- $ control_defaults = array (
287+ $ control_defaults = [
288288 'force ' => false ,
289289 'plugin ' => false ,
290290 'theme ' => false ,
291- ) ;
291+ ] ;
292292 $ control_args = $ this ->extract_args ( $ assoc_args , $ control_defaults );
293293
294294 if ( isset ( $ control_args ['plugin ' ] ) ) {
@@ -307,12 +307,12 @@ public function block( $args, $assoc_args ) {
307307 WP_CLI ::error ( 'No plugin or theme selected. ' );
308308 }
309309
310- $ files_to_create = array (
310+ $ files_to_create = [
311311 "{$ block_dir }/ {$ slug }.php " => self ::mustache_render ( 'block-php.mustache ' , $ data ),
312312 "{$ block_dir }/ {$ slug }/index.js " => self ::mustache_render ( 'block-index-js.mustache ' , $ data ),
313313 "{$ block_dir }/ {$ slug }/editor.css " => self ::mustache_render ( 'block-editor-css.mustache ' , $ data ),
314314 "{$ block_dir }/ {$ slug }/style.css " => self ::mustache_render ( 'block-style-css.mustache ' , $ data ),
315- ) ;
315+ ] ;
316316 $ files_written = $ this ->create_files ( $ files_to_create , $ control_args ['force ' ] );
317317 $ skip_message = 'All block files were skipped. ' ;
318318 $ success_message = "Created block ' {$ data ['title_ucfirst ' ]}'. " ;
@@ -372,11 +372,11 @@ public function underscores( $args, $assoc_args ) {
372372 WP_CLI ::error ( 'Invalid theme slug specified. Theme slugs can only contain letters, numbers, underscores and hyphens, and can only start with a letter or underscore. ' );
373373 }
374374
375- $ defaults = array (
375+ $ defaults = [
376376 'theme_name ' => ucfirst ( $ theme_slug ),
377377 'author ' => 'Me ' ,
378378 'author_uri ' => '' ,
379- ) ;
379+ ] ;
380380 $ data = wp_parse_args ( $ assoc_args , $ defaults );
381381
382382 $ _s_theme_path = "$ theme_path/ $ data [theme_name]" ;
@@ -395,7 +395,7 @@ public function underscores( $args, $assoc_args ) {
395395
396396 $ theme_description = "Custom theme: {$ data ['theme_name ' ]}, developed by {$ data ['author ' ]}" ;
397397
398- $ body = array () ;
398+ $ body = [] ;
399399 $ body ['underscoresme_name ' ] = $ data ['theme_name ' ];
400400 $ body ['underscoresme_slug ' ] = $ theme_slug ;
401401 $ body ['underscoresme_author ' ] = $ data ['author ' ];
@@ -412,12 +412,12 @@ public function underscores( $args, $assoc_args ) {
412412 }
413413
414414 $ tmpfname = wp_tempnam ( $ url );
415- $ post_args = array (
415+ $ post_args = [
416416 'timeout ' => $ timeout ,
417417 'body ' => $ body ,
418418 'stream ' => true ,
419419 'filename ' => $ tmpfname ,
420- ) ;
420+ ] ;
421421
422422 $ response = wp_remote_post ( $ url , $ post_args );
423423
@@ -449,19 +449,19 @@ public function underscores( $args, $assoc_args ) {
449449 unlink ( $ tmpfname );
450450
451451 if ( true === $ unzip_result ) {
452- $ files_to_create = array (
452+ $ files_to_create = [
453453 "{$ theme_path }/ {$ theme_slug }/.editorconfig " => file_get_contents ( self ::get_template_path ( '.editorconfig ' ) ),
454- ) ;
454+ ] ;
455455 $ this ->create_files ( $ files_to_create , false );
456456 WP_CLI ::success ( "Created theme ' {$ data ['theme_name ' ]}'. " );
457457 } else {
458458 WP_CLI ::error ( "Could not decompress your theme files (' {$ tmpfname }') at ' {$ theme_path }': {$ unzip_result ->get_error_message ()}" );
459459 }
460460
461461 if ( Utils \get_flag_value ( $ assoc_args , 'activate ' ) ) {
462- WP_CLI ::run_command ( array ( 'theme ' , 'activate ' , $ theme_slug ) );
462+ WP_CLI ::run_command ( [ 'theme ' , 'activate ' , $ theme_slug ] );
463463 } elseif ( Utils \get_flag_value ( $ assoc_args , 'enable-network ' ) ) {
464- WP_CLI ::run_command ( array ( 'theme ' , 'enable ' , $ theme_slug ), array ( 'network ' => true ) );
464+ WP_CLI ::run_command ( [ 'theme ' , 'enable ' , $ theme_slug ], [ 'network ' => true ] );
465465 }
466466 }
467467
@@ -510,20 +510,20 @@ public function underscores( $args, $assoc_args ) {
510510 public function child_theme ( $ args , $ assoc_args ) {
511511 $ theme_slug = $ args [0 ];
512512
513- if ( in_array ( $ theme_slug , array ( '. ' , '.. ' ) , true ) ) {
513+ if ( in_array ( $ theme_slug , [ '. ' , '.. ' ] , true ) ) {
514514 WP_CLI ::error ( "Invalid theme slug specified. The slug cannot be '.' or '..'. " );
515515 }
516516
517- $ defaults = array (
517+ $ defaults = [
518518 'theme_name ' => ucfirst ( $ theme_slug ),
519519 'author ' => 'Me ' ,
520520 'author_uri ' => '' ,
521521 'theme_uri ' => '' ,
522- ) ;
522+ ] ;
523523
524524 $ data = wp_parse_args ( $ assoc_args , $ defaults );
525525 $ data ['slug ' ] = $ theme_slug ;
526- $ data ['parent_theme_function_safe ' ] = str_replace ( array ( ' ' , '- ' ) , '_ ' , $ data ['parent_theme ' ] );
526+ $ data ['parent_theme_function_safe ' ] = str_replace ( [ ' ' , '- ' ] , '_ ' , $ data ['parent_theme ' ] );
527527 $ data ['description ' ] = ucfirst ( $ data ['parent_theme ' ] ) . ' child theme. ' ;
528528
529529 $ theme_dir = WP_CONTENT_DIR . "/themes/ {$ theme_slug }" ;
@@ -538,21 +538,21 @@ public function child_theme( $args, $assoc_args ) {
538538
539539 $ this ->maybe_create_themes_dir ();
540540
541- $ files_to_create = array (
541+ $ files_to_create = [
542542 $ theme_style_path => self ::mustache_render ( 'child_theme.mustache ' , $ data ),
543543 $ theme_functions_path => self ::mustache_render ( 'child_theme_functions.mustache ' , $ data ),
544544 "{$ theme_dir }/.editorconfig " => file_get_contents ( self ::get_template_path ( '.editorconfig ' ) ),
545- ) ;
545+ ] ;
546546 $ force = Utils \get_flag_value ( $ assoc_args , 'force ' );
547547 $ files_written = $ this ->create_files ( $ files_to_create , $ force );
548548 $ skip_message = 'All theme files were skipped. ' ;
549549 $ success_message = "Created ' {$ theme_dir }'. " ;
550550 $ this ->log_whether_files_written ( $ files_written , $ skip_message , $ success_message );
551551
552552 if ( Utils \get_flag_value ( $ assoc_args , 'activate ' ) ) {
553- WP_CLI ::run_command ( array ( 'theme ' , 'activate ' , $ theme_slug ) );
553+ WP_CLI ::run_command ( [ 'theme ' , 'activate ' , $ theme_slug ] );
554554 } elseif ( Utils \get_flag_value ( $ assoc_args , 'enable-network ' ) ) {
555- WP_CLI ::run_command ( array ( 'theme ' , 'enable ' , $ theme_slug ), array ( 'network ' => true ) );
555+ WP_CLI ::run_command ( [ 'theme ' , 'enable ' , $ theme_slug ], [ 'network ' => true ] );
556556 }
557557 }
558558
@@ -660,11 +660,11 @@ public function plugin( $args, $assoc_args ) {
660660 $ plugin_name = ucwords ( str_replace ( '- ' , ' ' , $ plugin_slug ) );
661661 $ plugin_package = str_replace ( ' ' , '_ ' , $ plugin_name );
662662
663- if ( in_array ( $ plugin_slug , array ( '. ' , '.. ' ) , true ) ) {
663+ if ( in_array ( $ plugin_slug , [ '. ' , '.. ' ] , true ) ) {
664664 WP_CLI ::error ( "Invalid plugin slug specified. The slug cannot be '.' or '..'. " );
665665 }
666666
667- $ defaults = array (
667+ $ defaults = [
668668 'plugin_slug ' => $ plugin_slug ,
669669 'plugin_name ' => $ plugin_name ,
670670 'plugin_package ' => $ plugin_package ,
@@ -673,7 +673,7 @@ public function plugin( $args, $assoc_args ) {
673673 'plugin_author_uri ' => 'YOUR SITE HERE ' ,
674674 'plugin_uri ' => 'PLUGIN SITE HERE ' ,
675675 'plugin_tested_up_to ' => get_bloginfo ( 'version ' ),
676- ) ;
676+ ] ;
677677 $ data = wp_parse_args ( $ assoc_args , $ defaults );
678678
679679 $ data ['textdomain ' ] = $ plugin_slug ;
@@ -696,15 +696,15 @@ public function plugin( $args, $assoc_args ) {
696696 $ plugin_path = "{$ plugin_dir }/ {$ plugin_slug }.php " ;
697697 $ plugin_readme_path = "{$ plugin_dir }/readme.txt " ;
698698
699- $ files_to_create = array (
699+ $ files_to_create = [
700700 $ plugin_path => self ::mustache_render ( 'plugin.mustache ' , $ data ),
701701 $ plugin_readme_path => self ::mustache_render ( 'plugin-readme.mustache ' , $ data ),
702702 "{$ plugin_dir }/package.json " => self ::mustache_render ( 'plugin-packages.mustache ' , $ data ),
703703 "{$ plugin_dir }/Gruntfile.js " => self ::mustache_render ( 'plugin-gruntfile.mustache ' , $ data ),
704704 "{$ plugin_dir }/.gitignore " => self ::mustache_render ( 'plugin-gitignore.mustache ' , $ data ),
705705 "{$ plugin_dir }/.distignore " => self ::mustache_render ( 'plugin-distignore.mustache ' , $ data ),
706706 "{$ plugin_dir }/.editorconfig " => file_get_contents ( self ::get_template_path ( '.editorconfig ' ) ),
707- ) ;
707+ ] ;
708708 $ force = Utils \get_flag_value ( $ assoc_args , 'force ' );
709709 $ files_written = $ this ->create_files ( $ files_to_create , $ force );
710710
@@ -713,18 +713,18 @@ public function plugin( $args, $assoc_args ) {
713713 $ this ->log_whether_files_written ( $ files_written , $ skip_message , $ success_message );
714714
715715 if ( ! Utils \get_flag_value ( $ assoc_args , 'skip-tests ' ) ) {
716- $ command_args = array (
716+ $ command_args = [
717717 'dir ' => $ plugin_dir ,
718718 'ci ' => empty ( $ assoc_args ['ci ' ] ) ? '' : $ assoc_args ['ci ' ],
719719 'force ' => $ force ,
720- ) ;
721- WP_CLI ::run_command ( array ( 'scaffold ' , 'plugin-tests ' , $ plugin_slug ) , $ command_args );
720+ ] ;
721+ WP_CLI ::run_command ( [ 'scaffold ' , 'plugin-tests ' , $ plugin_slug ] , $ command_args );
722722 }
723723
724724 if ( Utils \get_flag_value ( $ assoc_args , 'activate ' ) ) {
725- WP_CLI ::run_command ( array ( 'plugin ' , 'activate ' , $ plugin_slug ) );
725+ WP_CLI ::run_command ( [ 'plugin ' , 'activate ' , $ plugin_slug ] );
726726 } elseif ( Utils \get_flag_value ( $ assoc_args , 'activate-network ' ) ) {
727- WP_CLI ::run_command ( array ( 'plugin ' , 'activate ' , $ plugin_slug ), array ( 'network ' => true ) );
727+ WP_CLI ::run_command ( [ 'plugin ' , 'activate ' , $ plugin_slug ], [ 'network ' => true ] );
728728 }
729729 }
730730
@@ -839,7 +839,7 @@ private function scaffold_plugin_theme_tests( $args, $assoc_args, $type ) {
839839
840840 if ( ! empty ( $ args [0 ] ) ) {
841841 $ slug = $ args [0 ];
842- if ( in_array ( $ slug , array ( '. ' , '.. ' ) , true ) ) {
842+ if ( in_array ( $ slug , [ '. ' , '.. ' ] , true ) ) {
843843 WP_CLI ::error ( "Invalid {$ type } slug specified. The slug cannot be '.' or '..'. " );
844844 }
845845 if ( 'theme ' === $ type ) {
@@ -885,7 +885,7 @@ private function scaffold_plugin_theme_tests( $args, $assoc_args, $type ) {
885885 $ wp_filesystem ->mkdir ( $ tests_dir );
886886 $ wp_filesystem ->mkdir ( $ bin_dir );
887887
888- $ wp_versions_to_test = array () ;
888+ $ wp_versions_to_test = [] ;
889889 // Parse plugin readme.txt
890890 if ( file_exists ( "{$ target_dir }/readme.txt " ) ) {
891891 $ readme_content = file_get_contents ( "{$ target_dir }/readme.txt " );
@@ -898,16 +898,16 @@ private function scaffold_plugin_theme_tests( $args, $assoc_args, $type ) {
898898 $ wp_versions_to_test [] = 'latest ' ;
899899 $ wp_versions_to_test [] = 'trunk ' ;
900900
901- $ template_data = array (
901+ $ template_data = [
902902 "{$ type }_slug " => $ slug ,
903903 "{$ type }_package " => $ package ,
904- ) ;
904+ ] ;
905905
906906 $ force = Utils \get_flag_value ( $ assoc_args , 'force ' );
907- $ files_to_create = array (
907+ $ files_to_create = [
908908 "{$ tests_dir }/bootstrap.php " => self ::mustache_render ( "{$ type }-bootstrap.mustache " , $ template_data ),
909909 "{$ tests_dir }/test-sample.php " => self ::mustache_render ( "{$ type }-test-sample.mustache " , $ template_data ),
910- ) ;
910+ ] ;
911911 if ( 'travis ' === $ assoc_args ['ci ' ] ) {
912912 $ files_to_create [ "{$ target_dir }/.travis.yml " ] = self ::mustache_render ( 'plugin-travis.mustache ' , compact ( 'wp_versions_to_test ' ) );
913913 } elseif ( 'circle ' === $ assoc_args ['ci ' ] ) {
@@ -920,11 +920,11 @@ private function scaffold_plugin_theme_tests( $args, $assoc_args, $type ) {
920920
921921 $ files_written = $ this ->create_files ( $ files_to_create , $ force );
922922
923- $ to_copy = array (
923+ $ to_copy = [
924924 'install-wp-tests.sh ' => $ bin_dir ,
925925 'phpunit.xml.dist ' => $ target_dir ,
926926 '.phpcs.xml.dist ' => $ target_dir ,
927- ) ;
927+ ] ;
928928
929929 foreach ( $ to_copy as $ file => $ dir ) {
930930 $ file_name = "{$ dir }/ {$ file }" ;
@@ -973,7 +973,7 @@ private function check_target_directory( $type, $target_dir ) {
973973
974974 protected function create_files ( $ files_and_contents , $ force ) {
975975 $ wp_filesystem = $ this ->init_wp_filesystem ();
976- $ wrote_files = array () ;
976+ $ wrote_files = [] ;
977977
978978 foreach ( $ files_and_contents as $ filename => $ contents ) {
979979 $ should_write_file = $ this ->prompt_if_files_will_be_overwritten ( $ filename , $ force );
@@ -1007,7 +1007,7 @@ protected function prompt_if_files_will_be_overwritten( $filename, $force ) {
10071007 $ default = false ,
10081008 $ marker = '[s/r]: '
10091009 );
1010- } while ( ! in_array ( $ answer , array ( 's ' , 'r ' ) , true ) );
1010+ } while ( ! in_array ( $ answer , [ 's ' , 'r ' ] , true ) );
10111011 $ should_write_file = 'r ' === $ answer ;
10121012 }
10131013
@@ -1081,7 +1081,7 @@ private function pluralize( $word ) {
10811081 }
10821082
10831083 protected function extract_args ( $ assoc_args , $ defaults ) {
1084- $ out = array () ;
1084+ $ out = [] ;
10851085
10861086 foreach ( $ defaults as $ key => $ value ) {
10871087 $ out [ $ key ] = Utils \get_flag_value ( $ assoc_args , $ key , $ value );
@@ -1130,7 +1130,7 @@ protected function init_wp_filesystem() {
11301130 /**
11311131 * Localizes the template path.
11321132 */
1133- private static function mustache_render ( $ template , $ data = array () ) {
1133+ private static function mustache_render ( $ template , $ data = [] ) {
11341134 return Utils \mustache_render ( dirname ( dirname ( __FILE__ ) ) . "/templates/ {$ template }" , $ data );
11351135 }
11361136
@@ -1167,7 +1167,7 @@ private static function canonicalize_path( $path ) {
11671167 $ path .= '/ ' ;
11681168 }
11691169
1170- $ output = array () ;
1170+ $ output = [] ;
11711171
11721172 foreach ( explode ( '/ ' , $ path ) as $ segment ) {
11731173 if ( '.. ' === $ segment ) {
0 commit comments