Skip to content

Commit

Permalink
Remove deprecated function usage (#17)
Browse files Browse the repository at this point in the history
* remove utf8_encode as it is deprecated from php 8.2, replace with mbstring and add it as requirement in composer

* remove deprecated usage of json_encode from guzzle, add phpstan extension to check for deprecated usage
  • Loading branch information
sf-cg authored Nov 15, 2023
1 parent 48bbdc5 commit 79a8c0f
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 5 deletions.
5 changes: 3 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,15 @@
"require": {
"php": "^7.4.0||^8.0",
"guzzlehttp/guzzle": "^7.2",
"ext-json": "*"
"ext-json": "*",
"ext-mbstring": "*"
},
"require-dev": {
"dealerdirect/phpcodesniffer-composer-installer": "^0.7",
"php-vcr/php-vcr": "^1.5.2",
"phpstan/phpstan": "^1.10",
"phpstan/phpstan-deprecation-rules": "^1.1",
"phpunit/phpunit": "^9.0",
"symfony/var-dumper": "^4.2",
"vlucas/phpdotenv": "^2.5"
},
"autoload": {
Expand Down
1 change: 1 addition & 0 deletions phpstan.neon
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
includes:
- phpstan-baseline.neon
- vendor/phpstan/phpstan-deprecation-rules/rules.neon

parameters:
paths:
Expand Down
2 changes: 1 addition & 1 deletion src/Middleware/AuthMiddleware.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ private function makeSignatureString(string $signatureContentString)
hash_hmac(
static::SIGNATURE_ALGORITHM,
$signatureContentString,
utf8_encode($this->apiSecret),
mb_convert_encoding($this->apiSecret, 'UTF-8', mb_detect_encoding($this->apiSecret)),
true
)
);
Expand Down
4 changes: 2 additions & 2 deletions src/XCover.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
use GuzzleHttp\Client;
use GuzzleHttp\ClientInterface;
use GuzzleHttp\Exception\GuzzleException;
use GuzzleHttp\Utils;
use GuzzleHttp\HandlerStack;
use Psr\Http\Message\ResponseInterface;
use XCoverClient\Exceptions\ResponseException;
use XCoverClient\Exceptions\XCoverException;
use XCoverClient\Middleware\AuthMiddleware;
Expand Down Expand Up @@ -50,7 +50,7 @@ public function __construct(Config $config, ClientInterface $client = null)
public function call($method, $url, $expectedStatusCode = null, $payload = [], $queryParams = [])
{
$options = [
'body' => $payload ? \GuzzleHttp\json_encode($payload) : "{}",
'body' => $payload ? Utils::jsonEncode($payload) : "{}",
'query' => $queryParams,
];

Expand Down

0 comments on commit 79a8c0f

Please sign in to comment.