Skip to content

Commit

Permalink
chore: Fix deprecated warnings (#34)
Browse files Browse the repository at this point in the history
- Use `Http\Discovery\Psr18ClientDiscovery` instead of deprecated
`Http\Discovery\HttpClientDiscovery`.
- PHPUnit configuration migrated to latest version.

---------

Signed-off-by: Oğuzhan Durgun <oguzhandurgun95@gmail.com>
  • Loading branch information
oguzhand95 authored May 3, 2023
1 parent a94661b commit 1f7b08b
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 41 deletions.
5 changes: 3 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
composer.phar
.phpunit.result.cache
.phpunit.cache/
vendor/*
build/

composer.phar
.phpunit.result.cache

# Editor files
.vscode
Expand Down
5 changes: 4 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,10 @@
"issues": "https://github.com/cerbos/cerbos-sdk-php/issues"
},
"config": {
"sort-packages": true
"sort-packages": true,
"allow-plugins": {
"php-http/discovery": true
}
},
"require": {
"ext-json": "*",
Expand Down
53 changes: 22 additions & 31 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,32 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd"
bootstrap="tests/bootstrap.php"
colors="true"
executionOrder="random"
failOnWarning="true"
failOnRisky="true"
failOnEmptyTestSuite="true"
beStrictAboutOutputDuringTests="true"
verbose="true"
>
<testsuites>
<testsuite name="cerbos-sdk-php test suite">
<directory>tests</directory>
</testsuite>
</testsuites>
<coverage>
<include>
<directory suffix=".php">./src</directory>
</include>
<report>
<html outputDirectory="build/coverage"/>
<text outputFile="build/coverage.txt"/>
<clover outputFile="build/logs/clover.xml"/>
</report>
</coverage>
<logging>
<junit outputFile="build/report.junit.xml"/>
</logging>
</phpunit>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.1/phpunit.xsd" bootstrap="tests/bootstrap.php" colors="true" executionOrder="random" failOnWarning="true" failOnRisky="true" failOnEmptyTestSuite="true" beStrictAboutOutputDuringTests="true" cacheDirectory=".phpunit.cache">
<testsuites>
<testsuite name="cerbos-sdk-php test suite">
<directory>tests</directory>
</testsuite>
</testsuites>
<coverage>
<report>
<html outputDirectory="build/coverage"/>
<text outputFile="build/coverage.txt"/>
<clover outputFile="build/logs/clover.xml"/>
</report>
</coverage>
<logging>
<junit outputFile="build/report.junit.xml"/>
</logging>
<source>
<include>
<directory suffix=".php">./src</directory>
</include>
</source>
</phpunit>
15 changes: 8 additions & 7 deletions src/Sdk/Builder/CerbosClientBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
use Http\Client\Common\Plugin\BaseUriPlugin;
use Http\Client\Common\Plugin\HeaderDefaultsPlugin;
use Http\Client\Common\PluginClientFactory;
use Http\Discovery\HttpClientDiscovery;
use Http\Discovery\Psr17FactoryDiscovery;
use Http\Discovery\Psr18ClientDiscovery;
use Psr\Http\Client\ClientInterface;
use Psr\Http\Message\RequestFactoryInterface;
use Psr\Http\Message\StreamFactoryInterface;
Expand All @@ -37,14 +37,15 @@ class CerbosClientBuilder
* @param StreamFactoryInterface|null $streamFactoryInterface
* @param UriFactoryInterface|null $uriFactoryInterface
*/
public function __construct(string $uri,
?ClientInterface $httpClient,
?RequestFactoryInterface $requestFactoryInterface,
?StreamFactoryInterface $streamFactoryInterface,
?UriFactoryInterface $uriFactoryInterface
public function __construct(
string $uri,
?ClientInterface $httpClient,
?RequestFactoryInterface $requestFactoryInterface,
?StreamFactoryInterface $streamFactoryInterface,
?UriFactoryInterface $uriFactoryInterface
)
{
$this->httpClient = $httpClient ?: HttpClientDiscovery::find();
$this->httpClient = $httpClient ?: Psr18ClientDiscovery::find();
$this->requestFactoryInterface = $requestFactoryInterface ?: Psr17FactoryDiscovery::findRequestFactory();
$this->streamFactoryInterface = $streamFactoryInterface ?: Psr17FactoryDiscovery::findStreamFactory();
$this->uriFactory = $uriFactoryInterface ?: Psr17FactoryDiscovery::findUriFactory();
Expand Down

0 comments on commit 1f7b08b

Please sign in to comment.