mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-04-05 05:04:31 +00:00
Coding Standards: Replace alias PHP functions with the canonical names.
Using the canonical function name for PHP functions is strongly recommended, as aliases may be deprecated or removed without (much) warning. This replaces all uses of the following: * `join()` with `implode()` * `sizeof()` with `count()` * `is_writeable()` with `is_writable()` * `doubleval()` with a `(float)` cast In part, this is a follow-up to #47746. Props jrf. See #50767. git-svn-id: https://develop.svn.wordpress.org/trunk@49193 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -28,7 +28,7 @@ function strip_ws( $txt ) {
|
||||
}
|
||||
}
|
||||
|
||||
return trim( join( "\n", $result ) );
|
||||
return trim( implode( "\n", $result ) );
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -275,7 +275,7 @@ function xml_join_atts( $atts ) {
|
||||
foreach ( $atts as $k => $v ) {
|
||||
$a[] = $k . '="' . $v . '"';
|
||||
}
|
||||
return join( ' ', $a );
|
||||
return implode( ' ', $a );
|
||||
}
|
||||
|
||||
function xml_array_dumbdown( &$data ) {
|
||||
@@ -332,7 +332,7 @@ function gen_tests_array( $name, $array ) {
|
||||
$out[] = gen_tests_array( "{$name}[{$index}]", $v );
|
||||
}
|
||||
}
|
||||
return join( "\n", $out ) . "\n";
|
||||
return implode( "\n", $out ) . "\n";
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -2719,7 +2719,7 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase {
|
||||
foreach ( $error->errors as $code => $messages ) {
|
||||
$this->assertArrayHasKey( $code, $validity );
|
||||
$this->assertInternalType( 'array', $validity[ $code ] );
|
||||
$this->assertSame( join( ' ', $messages ), $validity[ $code ]['message'] );
|
||||
$this->assertSame( implode( ' ', $messages ), $validity[ $code ]['message'] );
|
||||
$this->assertArrayHasKey( 'data', $validity[ $code ] );
|
||||
$this->assertSame( $validity[ $code ]['data'], $error->get_error_data( $code ) );
|
||||
}
|
||||
|
||||
@@ -489,7 +489,7 @@ class Tests_DB extends WP_UnitTestCase {
|
||||
global $wpdb;
|
||||
$str = $wpdb->get_caller();
|
||||
$calls = explode( ', ', $str );
|
||||
$called = join( '->', array( __CLASS__, __FUNCTION__ ) );
|
||||
$called = implode( '->', array( __CLASS__, __FUNCTION__ ) );
|
||||
$this->assertSame( $called, end( $calls ) );
|
||||
}
|
||||
|
||||
|
||||
@@ -337,12 +337,12 @@ Paragraph two.';
|
||||
$content[] = "<$block>foo</$block>";
|
||||
}
|
||||
|
||||
$expected = join( "\n", $content );
|
||||
$input = join( "\n\n", $content ); // Whitespace difference.
|
||||
$expected = implode( "\n", $content );
|
||||
$input = implode( "\n\n", $content ); // Whitespace difference.
|
||||
|
||||
$this->assertSame( $expected, trim( wpautop( $input ) ) );
|
||||
|
||||
$input = join( '', $content ); // Whitespace difference.
|
||||
$input = implode( '', $content ); // Whitespace difference.
|
||||
|
||||
$this->assertSame( $expected, trim( wpautop( $input ) ) );
|
||||
|
||||
@@ -353,8 +353,8 @@ Paragraph two.';
|
||||
$content[] = "<$block/>";
|
||||
}
|
||||
|
||||
$expected = join( "\n", $content );
|
||||
$input = join( '', $content );
|
||||
$expected = implode( "\n", $content );
|
||||
$input = implode( '', $content );
|
||||
|
||||
$this->assertSame( $expected, trim( wpautop( $input ) ) );
|
||||
|
||||
@@ -365,8 +365,8 @@ Paragraph two.';
|
||||
$content[] = "<$block attr='value'>foo</$block>";
|
||||
}
|
||||
|
||||
$expected = join( "\n", $content );
|
||||
$input = join( '', $content );
|
||||
$expected = implode( "\n", $content );
|
||||
$input = implode( '', $content );
|
||||
|
||||
$this->assertSame( $expected, trim( wpautop( $input ) ) );
|
||||
}
|
||||
@@ -426,8 +426,8 @@ Paragraph two.';
|
||||
$expected[] = "<p><$inline>foo</$inline></p>";
|
||||
}
|
||||
|
||||
$content = join( "\n\n", $content );
|
||||
$expected = join( "\n", $expected );
|
||||
$content = implode( "\n\n", $content );
|
||||
$expected = implode( "\n", $expected );
|
||||
|
||||
$this->assertSame( $expected, trim( wpautop( $content ) ) );
|
||||
}
|
||||
|
||||
@@ -512,8 +512,8 @@ https://w.org</a>',
|
||||
$ids2_srcs[] = 'http://' . WP_TESTS_DOMAIN . '/wp-content/uploads/' . "image$i.jpg";
|
||||
}
|
||||
|
||||
$ids1_joined = join( ',', $ids1 );
|
||||
$ids2_joined = join( ',', $ids2 );
|
||||
$ids1_joined = implode( ',', $ids1 );
|
||||
$ids2_joined = implode( ',', $ids2 );
|
||||
|
||||
$blob = <<<BLOB
|
||||
[gallery ids="$ids1_joined"]
|
||||
@@ -662,8 +662,8 @@ BLOB;
|
||||
$ids2_srcs[] = 'http://' . WP_TESTS_DOMAIN . '/wp-content/uploads/' . "image$i.jpg";
|
||||
}
|
||||
|
||||
$ids1_joined = join( ',', $ids1 );
|
||||
$ids2_joined = join( ',', $ids2 );
|
||||
$ids1_joined = implode( ',', $ids1 );
|
||||
$ids2_joined = implode( ',', $ids2 );
|
||||
|
||||
$blob = <<<BLOB
|
||||
[gallery ids="$ids1_joined"]
|
||||
|
||||
@@ -13,7 +13,7 @@ class Tests_Post_BodyClass extends WP_UnitTestCase {
|
||||
}
|
||||
|
||||
public function test_body_class() {
|
||||
$expected = 'class="' . join( ' ', get_body_class( '', $this->post_id ) ) . '"';
|
||||
$expected = 'class="' . implode( ' ', get_body_class( '', $this->post_id ) ) . '"';
|
||||
$this->expectOutputString( $expected );
|
||||
body_class( '', $this->post_id );
|
||||
}
|
||||
@@ -21,7 +21,7 @@ class Tests_Post_BodyClass extends WP_UnitTestCase {
|
||||
public function test_body_class_extra_esc_attr() {
|
||||
$classes = get_body_class( '', $this->post_id );
|
||||
$escaped_again = array_map( 'esc_attr', $classes );
|
||||
$escaped_another_time = 'class="' . esc_attr( join( ' ', $escaped_again ) ) . '"';
|
||||
$escaped_another_time = 'class="' . esc_attr( implode( ' ', $escaped_again ) ) . '"';
|
||||
|
||||
$this->expectOutputString( $escaped_another_time );
|
||||
body_class( '', $this->post_id );
|
||||
|
||||
@@ -13,7 +13,7 @@ class Tests_Post_PostClass extends WP_UnitTestCase {
|
||||
}
|
||||
|
||||
public function test_post_class() {
|
||||
$expected = 'class="' . join( ' ', get_post_class( '', $this->post_id ) ) . '"';
|
||||
$expected = 'class="' . implode( ' ', get_post_class( '', $this->post_id ) ) . '"';
|
||||
$this->expectOutputString( $expected );
|
||||
post_class( '', $this->post_id );
|
||||
}
|
||||
@@ -21,7 +21,7 @@ class Tests_Post_PostClass extends WP_UnitTestCase {
|
||||
public function test_post_class_extra_esc_attr() {
|
||||
$classes = get_post_class( '', $this->post_id );
|
||||
$escaped_again = array_map( 'esc_attr', $classes );
|
||||
$escaped_another_time = 'class="' . esc_attr( join( ' ', $escaped_again ) ) . '"';
|
||||
$escaped_another_time = 'class="' . esc_attr( implode( ' ', $escaped_again ) ) . '"';
|
||||
|
||||
$this->expectOutputString( $escaped_another_time );
|
||||
post_class( '', $this->post_id );
|
||||
|
||||
@@ -7,7 +7,7 @@ class Tests_Post_Template extends WP_UnitTestCase {
|
||||
|
||||
function test_wp_link_pages() {
|
||||
$contents = array( 'One', 'Two', 'Three' );
|
||||
$content = join( '<!--nextpage-->', $contents );
|
||||
$content = implode( '<!--nextpage-->', $contents );
|
||||
$post_id = self::factory()->post->create( array( 'post_content' => $content ) );
|
||||
|
||||
$this->go_to( '?p=' . $post_id );
|
||||
|
||||
@@ -101,7 +101,7 @@ class Test_WP_Widget_Media_Gallery extends WP_UnitTestCase {
|
||||
|
||||
$this->assertTrue( wp_script_is( 'media-gallery-widget' ) );
|
||||
|
||||
$after = join( '', wp_scripts()->registered['media-gallery-widget']->extra['after'] );
|
||||
$after = implode( '', wp_scripts()->registered['media-gallery-widget']->extra['after'] );
|
||||
$this->assertContains( 'wp.mediaWidgets.modelConstructors[ "media_gallery" ].prototype', $after );
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user