From e24074b4b25b420789217611d749e90e1319871d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maur=C3=ADcio=20Meneghini=20Fauth?= Date: Fri, 13 Apr 2018 03:08:03 -0300 Subject: [PATCH] Replace func_get_args by ... operator MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: MaurĂ­cio Meneghini Fauth --- libraries/classes/ListAbstract.php | 8 ++++---- libraries/classes/Message.php | 4 ++-- test/classes/Plugins/Auth/AuthenticationHttpTest.php | 3 +-- test/classes/PmaTestCase.php | 6 ++---- 4 files changed, 9 insertions(+), 12 deletions(-) diff --git a/libraries/classes/ListAbstract.php b/libraries/classes/ListAbstract.php index 9e28490e34..b09c97457d 100644 --- a/libraries/classes/ListAbstract.php +++ b/libraries/classes/ListAbstract.php @@ -55,17 +55,17 @@ abstract class ListAbstract extends ArrayObject * checks if the given db names exists in the current list, if there is * missing at least one item it returns false otherwise true * - * @return boolean true if all items exists, otherwise false + * @param mixed ...$params + * @return bool true if all items exists, otherwise false */ - public function exists() + public function exists(...$params) { $this_elements = $this->getArrayCopy(); - foreach (func_get_args() as $result) { + foreach ($params as $result) { if (! in_array($result, $this_elements)) { return false; } } - return true; } diff --git a/libraries/classes/Message.php b/libraries/classes/Message.php index efeeca673a..c8a8722a8d 100644 --- a/libraries/classes/Message.php +++ b/libraries/classes/Message.php @@ -648,11 +648,11 @@ class Message /** * wrapper for sprintf() * + * @param mixed ...$params * @return string formatted */ - static public function format() + static public function format(...$params) { - $params = func_get_args(); if (isset($params[1]) && is_array($params[1])) { array_unshift($params[1], $params[0]); $params = $params[1]; diff --git a/test/classes/Plugins/Auth/AuthenticationHttpTest.php b/test/classes/Plugins/Auth/AuthenticationHttpTest.php index 4fc2338d51..ac72bd292e 100644 --- a/test/classes/Plugins/Auth/AuthenticationHttpTest.php +++ b/test/classes/Plugins/Auth/AuthenticationHttpTest.php @@ -55,7 +55,7 @@ class AuthenticationHttpTest extends PmaTestCase unset($this->object); } - public function doMockResponse($set_minimal, $body_id, $set_title) + public function doMockResponse($set_minimal, $body_id, $set_title, ...$headers) { // mock footer $mockFooter = $this->getMockBuilder('PhpMyAdmin\Footer') @@ -89,7 +89,6 @@ class AuthenticationHttpTest extends PmaTestCase ->with(); // set mocked headers and footers - $headers = array_slice(func_get_args(), 3); $mockResponse = $this->mockResponse($headers); $mockResponse->expects($this->exactly($set_title)) diff --git a/test/classes/PmaTestCase.php b/test/classes/PmaTestCase.php index b2e72b7a51..d00a500a1b 100644 --- a/test/classes/PmaTestCase.php +++ b/test/classes/PmaTestCase.php @@ -33,11 +33,11 @@ class PmaTestCase extends TestCase /** * Creates mock of Response object for header testing * - * @param mixed $param parameter for header method + * @param mixed ...$param parameter for header method * * @return void */ - public function mockResponse() + public function mockResponse(...$param) { $this->restoreInstance = Response::getInstance(); @@ -55,8 +55,6 @@ class PmaTestCase extends TestCase ->with() ->will($this->returnValue(false)); - $param = func_get_args(); - if (count($param) > 0) { if (is_array($param[0])) { if (is_array($param[0][0]) && count($param) == 1) {