From 479fac9e10857f02bcdb6a99afbe68dedba4ef79 Mon Sep 17 00:00:00 2001 From: mundschenk_at Date: Sat, 18 May 2024 13:32:41 +0200 Subject: [PATCH] Remove unused method Strings::maybe_split_parameters --- src/class-strings.php | 17 +---------------- tests/class-strings-test.php | 30 ------------------------------ 2 files changed, 1 insertion(+), 46 deletions(-) diff --git a/src/class-strings.php b/src/class-strings.php index 39d1135..0fb2f5e 100644 --- a/src/class-strings.php +++ b/src/class-strings.php @@ -34,6 +34,7 @@ * * @since 4.2.0 * @since 7.0.0 The deprecated static methods `mb_str_split`, and `uchr` have been removed. + * The now unused static method `maybe_split_parameters` has also been removed. * * @phpstan-type String_Functions array{ * 'strlen' : callable, @@ -114,20 +115,4 @@ public static function functions( $str ) { throw new Invalid_Encoding_Exception( "String '$str' uses neither ASCII nor UTF-8 encoding." ); } - - /** - * If necessary, split the passed parameters string into an array. - * - * @param string[]|string $params Parameters. - * - * @return string[] - */ - public static function maybe_split_parameters( $params ) { - if ( ! \is_array( $params ) ) { - // We can safely assume an array here, as long as $params convertible to a string. - $params = \preg_split( self::RE_PARAMETER_SPLITTING, $params, -1, PREG_SPLIT_NO_EMPTY ) ?: []; // phpcs:ignore Universal.Operators.DisallowShortTernary -- Ensure array type in case of error. - } - - return $params; - } } diff --git a/tests/class-strings-test.php b/tests/class-strings-test.php index 11c0aa7..247ed15 100644 --- a/tests/class-strings-test.php +++ b/tests/class-strings-test.php @@ -85,34 +85,4 @@ public function test_functions_invalid_encoding() { $this->assertEmpty( Strings::functions( \mb_convert_encoding( 'Ungültiges Encoding', 'ISO-8859-2' ) ) ); } - - /** - * Provide data for testing maybe_split_parameters. - * - * @return array - */ - public function provide_maybe_split_parameters_data() { - return [ - [ [], [] ], - [ '', [] ], - [ ',', [] ], - [ 'a,b', [ 'a', 'b' ] ], - [ 'foo, bar, xxx', [ 'foo', 'bar', 'xxx' ] ], - [ [ 'foo', 'bar', 'xxx' ], [ 'foo', 'bar', 'xxx' ] ], - [ [ 1, 2, 'drei' ], [ 1, 2, 'drei' ] ], - ]; - } - - /** - * Test maybe_split_parameters. - * - * @covers ::maybe_split_parameters - * @dataProvider provide_maybe_split_parameters_data - * - * @param string|array $input Parameters sring/array. - * @param array $result Expected output. - */ - public function test_maybe_split_parameters( $input, $result ) { - $this->assertSame( $result, Strings::maybe_split_parameters( $input ) ); - } }