From 932bd68c023f101397acd0d9f73ef227a24264a1 Mon Sep 17 00:00:00 2001 From: AustinB Date: Fri, 18 Dec 2020 18:23:25 -0600 Subject: [PATCH 1/2] Fix one character variables to pass PHPMD. --- src/GameQ/Buffer.php | 4 ++-- src/GameQ/GameQ.php | 10 +++++----- src/GameQ/Protocols/Ventrilo.php | 14 +++++++------- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/GameQ/Buffer.php b/src/GameQ/Buffer.php index e9e1552d..ca23eb6d 100644 --- a/src/GameQ/Buffer.php +++ b/src/GameQ/Buffer.php @@ -276,8 +276,8 @@ public function readStringMulti($delims, &$delimfound = null) // Get position of delimiters $pos = []; foreach ($delims as $delim) { - if ($p = strpos($this->data, $delim, min($this->index, $this->length))) { - $pos[] = $p; + if ($index = strpos($this->data, $delim, min($this->index, $this->length))) { + $pos[] = $index; } } diff --git a/src/GameQ/GameQ.php b/src/GameQ/GameQ.php index 2ddfc735..fdc8ef70 100644 --- a/src/GameQ/GameQ.php +++ b/src/GameQ/GameQ.php @@ -410,10 +410,10 @@ protected function doChallenges() 'server_id' => $server_id, 'socket' => $socket, ]; - } catch (QueryException $e) { + } catch (QueryException $exception) { // Check to see if we are in debug, if so bubble up the exception if ($this->debug) { - throw new \Exception($e->getMessage(), $e->getCode(), $e); + throw new \Exception($exception->getMessage(), $exception->getCode(), $exception); } } @@ -511,10 +511,10 @@ protected function doQueries() 'server_id' => $server_id, 'socket' => $socket, ]; - } catch (QueryException $e) { + } catch (QueryException $exception) { // Check to see if we are in debug, if so bubble up the exception if ($this->debug) { - throw new \Exception($e->getMessage(), $e->getCode(), $e); + throw new \Exception($exception->getMessage(), $exception->getCode(), $exception); } continue; @@ -638,7 +638,7 @@ protected function doApplyFilters(array $results, Server $server) // Apply the filter to the data $results = $filter->apply($results, $server); - } catch (\ReflectionException $e) { + } catch (\ReflectionException $exception) { // Invalid, skip it continue; } diff --git a/src/GameQ/Protocols/Ventrilo.php b/src/GameQ/Protocols/Ventrilo.php index 8a1e0e8e..6986bedc 100644 --- a/src/GameQ/Protocols/Ventrilo.php +++ b/src/GameQ/Protocols/Ventrilo.php @@ -778,11 +778,11 @@ protected function decryptPackets(array $packets = []) $characterCount = count($chars); $key = 0; - for ($i = 1; $i <= $characterCount; $i++) { - $chars[$i] -= ($table[$a2] + (($i - 1) % 5)) & 0xFF; + for ($index = 1; $index <= $characterCount; $index++) { + $chars[$index] -= ($table[$a2] + (($index - 1) % 5)) & 0xFF; $a2 = ($a2 + $a1) & 0xFF; - if (($i % 2) == 0) { - $short_array = unpack("n1", pack("C2", $chars[$i - 1], $chars[$i])); + if (($index % 2) == 0) { + $short_array = unpack("n1", pack("C2", $chars[$index - 1], $chars[$index])); $header_items[$key] = $short_array[1]; ++$key; } @@ -818,10 +818,10 @@ protected function decryptPackets(array $packets = []) $data = ""; $characterCount = count($chars); - for ($i = 1; $i <= $characterCount; $i++) { - $chars[$i] -= ($table[$a2] + (($i - 1) % 72)) & 0xFF; + for ($index = 1; $index <= $characterCount; $index++) { + $chars[$index] -= ($table[$a2] + (($index - 1) % 72)) & 0xFF; $a2 = ($a2 + $a1) & 0xFF; - $data .= chr($chars[$i]); + $data .= chr($chars[$index]); } //@todo: Check CRC ??? $decrypted[$header_items['pck']] = $data; From 9fb26843a9d62814ee0c22ec75dddc09704c487f Mon Sep 17 00:00:00 2001 From: AustinB Date: Fri, 18 Dec 2020 18:24:10 -0600 Subject: [PATCH 2/2] Update PHPMD with new ignores and rules for short class names. #561 --- build/config/phpmd.xml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/build/config/phpmd.xml b/build/config/phpmd.xml index 6cb89214..ad293eef 100644 --- a/build/config/phpmd.xml +++ b/build/config/phpmd.xml @@ -17,6 +17,7 @@ + @@ -33,7 +34,11 @@ - + + + + +