From 23232f4e6a2d432d5e5317760aa9ae10ae0c4b6a Mon Sep 17 00:00:00 2001 From: Joshua Ramon Enslin Date: Thu, 15 Sep 2022 21:38:41 +0200 Subject: [PATCH] Remove superfluous variable assignments --- exceptions/MDCoordinateOutOfRange.php | 3 +-- exceptions/MDJailSecurityOptionNotSetException.php | 3 +-- exceptions/MDJsonEncodingFailedException.php | 3 +-- src/MDFormatter.php | 4 +--- src/MD_STD.php | 11 +++++------ 5 files changed, 9 insertions(+), 15 deletions(-) diff --git a/exceptions/MDCoordinateOutOfRange.php b/exceptions/MDCoordinateOutOfRange.php index b59ea97..4b218dd 100644 --- a/exceptions/MDCoordinateOutOfRange.php +++ b/exceptions/MDCoordinateOutOfRange.php @@ -13,8 +13,7 @@ final class MDCoordinateOutOfRange extends MDExpectedException { */ public function errorMessage() { //error message - $errorMsg = 'Parameter: ' . $this->getMessage() . ' is not a valid, numeric values.'; - return $errorMsg; + return 'Parameter: ' . $this->getMessage() . ' is not a valid, numeric values.'; } } diff --git a/exceptions/MDJailSecurityOptionNotSetException.php b/exceptions/MDJailSecurityOptionNotSetException.php index 4b33d37..251d7b0 100644 --- a/exceptions/MDJailSecurityOptionNotSetException.php +++ b/exceptions/MDJailSecurityOptionNotSetException.php @@ -12,8 +12,7 @@ final class MDJailSecurityOptionNotSetException extends Exception { */ public function errorMessage() { //error message - $errorMsg = 'A security option of MD_JAIL has not been set: ' . $this->getMessage() . ').'; - return $errorMsg; + return 'A security option of MD_JAIL has not been set: ' . $this->getMessage() . ').'; } } diff --git a/exceptions/MDJsonEncodingFailedException.php b/exceptions/MDJsonEncodingFailedException.php index 48af23c..25a4acb 100644 --- a/exceptions/MDJsonEncodingFailedException.php +++ b/exceptions/MDJsonEncodingFailedException.php @@ -12,8 +12,7 @@ final class MDJsonEncodingFailedException extends Exception { */ public function errorMessage() { //error message - $errorMsg = 'Failed to encode JSON data.'; - return $errorMsg; + return 'Failed to encode JSON data.'; } } diff --git a/src/MDFormatter.php b/src/MDFormatter.php index 404680c..736c236 100644 --- a/src/MDFormatter.php +++ b/src/MDFormatter.php @@ -132,12 +132,10 @@ final class MDFormatter { */ public static function formatMarkdownCodeBlock(string $content, string $language = ''):string { - $output = '```' . $language . ' + return '```' . $language . ' ' . $content . ' ```' . PHP_EOL; - return $output; - } /** diff --git a/src/MD_STD.php b/src/MD_STD.php index a12caab..425ea68 100644 --- a/src/MD_STD.php +++ b/src/MD_STD.php @@ -386,11 +386,12 @@ final class MD_STD { } while($running > 0); $res = []; - foreach($urls as $i => $url) { + $keys = \array_keys($urls); + foreach($keys as $i){ $res[$i] = \curl_multi_getcontent($curl_array[$i]) ?: ''; } - foreach($urls as $i => $url){ + foreach($keys as $i){ \curl_multi_remove_handle($mh, $curl_array[$i]); } \curl_multi_close($mh); @@ -579,8 +580,7 @@ final class MD_STD { */ public static function openssl_random_pseudo_bytes(int $length):string { - $output = \openssl_random_pseudo_bytes($length); - return $output; + return \openssl_random_pseudo_bytes($length); } @@ -750,8 +750,7 @@ final class MD_STD { */ public static function string_to_color_code(string $str):string { - $code = \substr(\dechex(\crc32($str)), 0, 6); - return $code; + return \substr(\dechex(\crc32($str)), 0, 6); }