From 802c23e0595262f9c594b61f3de9c5c560caae3e Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Sun, 15 Sep 2019 11:55:42 +0000 Subject: [PATCH] Code Modernisation: Replace `call_user_func_array()` in `tests/phpunit/tests/db.php` with dynamic function calls. Props jrf. See #47678. git-svn-id: https://develop.svn.wordpress.org/trunk@46145 602fd350-edb4-49c9-b593-d223f7449a82 --- tests/phpunit/tests/db.php | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/tests/phpunit/tests/db.php b/tests/phpunit/tests/db.php index 0583ae132a..842246528d 100644 --- a/tests/phpunit/tests/db.php +++ b/tests/phpunit/tests/db.php @@ -422,11 +422,8 @@ class Tests_DB extends WP_UnitTestCase { public function test_prepare_incorrect_arg_count( $query, $args, $expected ) { global $wpdb; - // $query is the first argument to be passed to wpdb::prepare() - array_unshift( $args, $query ); - - // phpcs:ignore WordPress.PHP.NoSilencedErrors.Discouraged - $prepared = @call_user_func_array( array( $wpdb, 'prepare' ), $args ); + // phpcs:ignore WordPress.PHP.NoSilencedErrors.Discouraged,WordPress.DB.PreparedSQL + $prepared = @$wpdb->prepare( $query, ...$args ); $this->assertEquals( $expected, $prepared ); } @@ -1366,9 +1363,8 @@ class Tests_DB extends WP_UnitTestCase { $values = array( $values ); } - array_unshift( $values, $sql ); - - $sql = call_user_func_array( array( $wpdb, 'prepare' ), $values ); + // phpcs:ignore WordPress.DB.PreparedSQL + $sql = $wpdb->prepare( $sql, ...$values ); $this->assertEquals( $expected, $sql ); } @@ -1386,7 +1382,8 @@ class Tests_DB extends WP_UnitTestCase { $values = array( $values ); } - $sql = call_user_func_array( array( $wpdb, 'prepare' ), array( $sql, $values ) ); + // phpcs:ignore WordPress.DB.PreparedSQL + $sql = $wpdb->prepare( $sql, $values ); $this->assertEquals( $expected, $sql ); }