Skip to content

Commit

Permalink
Merge pull request #40 from veewee/bump-psl
Browse files Browse the repository at this point in the history
Bump PSL
  • Loading branch information
veewee authored Sep 6, 2024
2 parents e848144 + 743afbd commit ee9ca4b
Show file tree
Hide file tree
Showing 31 changed files with 46,082 additions and 35,271 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/grumphp.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ jobs:
strategy:
matrix:
operating-system: [ubuntu-latest]
php-versions: ['8.1', '8.2', '8.3']
php-versions: ['8.2', '8.3']
composer-options: ['', '--prefer-lowest']
fail-fast: false
name: PHP ${{ matrix.php-versions }} @ ${{ matrix.operating-system }} with ${{ matrix.composer-options }}
Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
}
],
"require": {
"php": "~8.1.0 || ~8.2.0 || ~8.3.0",
"php": "~8.2.0 || ~8.3.0",
"ext-json": "*",
"azjezz/psl": "^2.5",
"azjezz/psl": "^3.0",
"cardinalby/content-disposition": "^1.1",
"league/uri": "^7.3",
"php-http/client-common": "^2.7",
Expand Down
6 changes: 3 additions & 3 deletions phive.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<phive xmlns="https://phar.io/phive">
<phar name="psalm" version="^5.15.0" installed="5.16.0" location="./tools/psalm.phar" copy="true"/>
<phar name="phpunit" version="^9.6.13" installed="9.6.13" location="./tools/phpunit.phar" copy="true"/>
<phar name="php-cs-fixer" version="^3.30.0" installed="3.39.0" location="./tools/php-cs-fixer.phar" copy="true"/>
<phar name="psalm" version="^5.15.0" installed="5.25.0" location="./tools/psalm.phar" copy="true"/>
<phar name="phpunit" version="^9.6.13" installed="9.6.20" location="./tools/phpunit.phar" copy="true"/>
<phar name="php-cs-fixer" version="^3.30.0" installed="3.64.0" location="./tools/php-cs-fixer.phar" copy="true"/>
</phive>
2 changes: 1 addition & 1 deletion src/Encoding/Binary/BinaryFile.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public function __construct(
private readonly ?string $mimeType,
private readonly ?string $fileName,
private readonly ?string $extension,
private readonly ?string $hash
private readonly ?string $hash,
) {
}

Expand Down
4 changes: 2 additions & 2 deletions src/Encoding/Binary/BinaryFileDecoder.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public function __construct(
callable $mimeTypeExtractor,
callable $fileNameExtractor,
callable $extensionExtractor,
callable $hashExtractor
callable $hashExtractor,
) {
$this->sizeExtractor = $sizeExtractor;
$this->mimeTypeExtractor = $mimeTypeExtractor;
Expand All @@ -66,7 +66,7 @@ public static function createWithAutodiscoveredPsrFactories(): self
new Extractor\MimeTypeExtractor(),
new Extractor\FilenameExtractor(),
new Extractor\ExtensionExtractor(),
new Extractor\HashExtractor(Algorithm::MD5),
new Extractor\HashExtractor(Algorithm::Md5),
);
}

Expand Down
6 changes: 4 additions & 2 deletions src/Encoding/Binary/Extractor/ExtensionExtractor.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,17 @@ final class ExtensionExtractor
{
public function __invoke(ResponseInterface $response): ?string
{
if ($mimeType = (new MimeTypeExtractor())($response)) {
$mimeType = (new MimeTypeExtractor())($response);
if (null !== $mimeType) {
SymfonyMimeDependency::guard();
$extensions = MimeTypes::getDefault()->getExtensions($mimeType);
if ($extensions) {
return first($extensions);
}
}

if ($originalName = (new FilenameExtractor())($response)) {
$originalName = (new FilenameExtractor())($response);
if (null !== $originalName) {
return pathinfo($originalName, PATHINFO_EXTENSION) ?: null;
}

Expand Down
3 changes: 2 additions & 1 deletion src/Encoding/Binary/Extractor/FilenameExtractor.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ final class FilenameExtractor
{
public function __invoke(ResponseInterface $response): ?string
{
if (!$disposition = first($response->getHeader('Content-Disposition'))) {
$disposition = first($response->getHeader('Content-Disposition'));
if (null === $disposition) {
return null;
}

Expand Down
2 changes: 1 addition & 1 deletion src/Encoding/Binary/Extractor/HashExtractor.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
final class HashExtractor
{
public function __construct(
private readonly Algorithm $algorithm
private readonly Algorithm $algorithm,
) {
}

Expand Down
6 changes: 4 additions & 2 deletions src/Encoding/Binary/Extractor/MimeTypeExtractor.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,13 @@ final class MimeTypeExtractor
{
public function __invoke(ResponseInterface $response): ?string
{
if ($contentType = first($response->getHeader('Content-Type'))) {
$contentType = first($response->getHeader('Content-Type'));
if (null !== $contentType && '' !== $contentType) {
return $contentType;
}

if ($originalName = (new FilenameExtractor())($response)) {
$originalName = (new FilenameExtractor())($response);
if (null !== $originalName) {
if ($extension = pathinfo($originalName, PATHINFO_EXTENSION)) {
SymfonyMimeDependency::guard();
$mimeTypes = MimeTypes::getDefault()->getMimeTypes($extension);
Expand Down
3 changes: 2 additions & 1 deletion src/Encoding/Binary/Extractor/SizeExtractor.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ public function __invoke(ResponseInterface $response): ?int
return $size;
}

if ($length = first($response->getHeader('Content-Length'))) {
$length = first($response->getHeader('Content-Length'));
if (null !== $length) {
return try_catch(
static fn () => int()->coerce($length),
static fn () => null
Expand Down
2 changes: 1 addition & 1 deletion src/Exception/RuntimeException.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

abstract class RuntimeException extends \RuntimeException
{
protected function __construct(string $message = '', int $code = 0, Throwable $previous = null)
protected function __construct(string $message = '', int $code = 0, ?Throwable $previous = null)
{
parent::__construct($message, $code, $previous);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Formatter/RemoveSensitiveQueryStringsFormatter.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ final class RemoveSensitiveQueryStringsFormatter implements HttpFormatter
*/
public function __construct(
HttpFormatter $formatter,
array $sensitiveKeys
array $sensitiveKeys,
) {
$this->formatter = $formatter;
$this->sensitiveKeys = $sensitiveKeys;
Expand Down
2 changes: 1 addition & 1 deletion src/Test/UseHttpToolsFactories.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ private function createToolsRequest(
string $method,
string $uri,
array $uriParams = [],
$body = null
$body = null,
): RequestInterface {
return new Request($method, $uri, $uriParams, $body);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Test/UseMockClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ trait UseMockClient
/**
* @param callable(Client $client): Client|null $configurator
*/
private function mockClient(callable $configurator = null): Client
private function mockClient(?callable $configurator = null): Client
{
MockClientDependency::guard();
$configurator ??= fn (Client $client) => $client;
Expand Down
2 changes: 1 addition & 1 deletion src/Test/UseVcrClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ trait UseVcrClient
/**
* @return array{RecordPlugin, ReplayPlugin}
*/
private function useRecording(string $path, NamingStrategyInterface $namingStrategy = null): array
private function useRecording(string $path, ?NamingStrategyInterface $namingStrategy = null): array
{
VcrPluginDependency::guard();

Expand Down
2 changes: 1 addition & 1 deletion src/Transport/CallbackTransport.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ final class CallbackTransport implements TransportInterface
public function __construct(
callable $requestConverter,
callable $sender,
callable $responseConverter
callable $responseConverter,
) {
$this->requestConverter = $requestConverter;
$this->sender = $sender;
Expand Down
2 changes: 1 addition & 1 deletion src/Transport/EncodedTransportFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public static function create(
ClientInterface $client,
UriBuilderInterface $uriBuilder,
EncoderInterface $encoder,
DecoderInterface $decoder
DecoderInterface $decoder,
): TransportInterface {
/** @var CallbackTransport<RequestType, ResponseType> $transport */
$transport = new CallbackTransport(
Expand Down
4 changes: 2 additions & 2 deletions src/Transport/IO/Input/EncodingRequestConverter.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ final class EncodingRequestConverter implements RequestConverterInterface
public function __construct(
RequestFactoryInterface $requestFactory,
UriBuilderInterface $uriBuilder,
EncoderInterface $encoder
EncoderInterface $encoder,
) {
$this->requestFactory = $requestFactory;
$this->encoder = $encoder;
Expand All @@ -40,7 +40,7 @@ public function __construct(

public static function createWithAutodiscoveredPsrFactories(
UriBuilderInterface $uriBuilder,
EncoderInterface $encoder
EncoderInterface $encoder,
): self {
return new self(
Psr17FactoryDiscovery::findRequestFactory(),
Expand Down
6 changes: 3 additions & 3 deletions src/Transport/Presets/BinaryDownloadPreset.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ final class BinaryDownloadPreset
*/
public static function create(
ClientInterface $client,
UriBuilderInterface $uriBuilder
UriBuilderInterface $uriBuilder,
): TransportInterface {
return self::withEmptyRequest($client, $uriBuilder);
}
Expand All @@ -33,7 +33,7 @@ public static function create(
*/
public static function withEmptyRequest(
ClientInterface $client,
UriBuilderInterface $uriBuilder
UriBuilderInterface $uriBuilder,
): TransportInterface {
return EncodedTransportFactory::create(
$client,
Expand All @@ -48,7 +48,7 @@ public static function withEmptyRequest(
*/
public static function withMultiPartRequest(
ClientInterface $client,
UriBuilderInterface $uriBuilder
UriBuilderInterface $uriBuilder,
): TransportInterface {
return EncodedTransportFactory::create(
$client,
Expand Down
2 changes: 1 addition & 1 deletion src/Transport/Presets/JsonPreset.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ final class JsonPreset
*/
public static function create(
ClientInterface $client,
UriBuilderInterface $uriBuilder
UriBuilderInterface $uriBuilder,
): TransportInterface {
return EncodedTransportFactory::create(
$client,
Expand Down
2 changes: 1 addition & 1 deletion src/Transport/Presets/PsrPreset.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ final class PsrPreset
*/
public static function create(
ClientInterface $client,
UriBuilderInterface $uriBuilder
UriBuilderInterface $uriBuilder,
): TransportInterface {
return EncodedTransportFactory::create(
$client,
Expand Down
2 changes: 1 addition & 1 deletion src/Transport/Presets/RawPreset.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ final class RawPreset
*/
public static function create(
ClientInterface $client,
UriBuilderInterface $uriBuilder
UriBuilderInterface $uriBuilder,
): TransportInterface {
return EncodedTransportFactory::create(
$client,
Expand Down
2 changes: 1 addition & 1 deletion src/Transport/Serializer/SerializerTransport.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ final class SerializerTransport implements TransportInterface
*/
public function __construct(
SerializerInterface $serializer,
TransportInterface $transport
TransportInterface $transport,
) {
$this->transport = $transport;
$this->serializer = $serializer;
Expand Down
2 changes: 1 addition & 1 deletion tests/Unit/Encoding/Binary/BinaryFileDecoderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ final class BinaryFileDecoderTest extends TestCase
public function it_can_decode_binary_files(
BinaryFileDecoder $decoder,
ResponseInterface $response,
BinaryFile $expected
BinaryFile $expected,
): void {
$actual = $decoder($response);

Expand Down
8 changes: 4 additions & 4 deletions tests/Unit/Encoding/Binary/Extractor/HashExtractorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ final class HashExtractorTest extends TestCase
*/
public function it_can_extract_hash(ResponseInterface $response, string $expected, int $endPosition = 0): void
{
$extractor = new HashExtractor(Algorithm::MD5);
$extractor = new HashExtractor(Algorithm::Md5);
$actual = $extractor($response);

self::assertSame($actual, $expected);
Expand All @@ -35,23 +35,23 @@ public function provideCases()
{
yield 'from-empty-stream-size' => [
$this->createResponse(),
hash('', Algorithm::MD5),
hash('', Algorithm::Md5),
];

yield 'from-stream-size' => [
$this->createResponse()
->withBody(
$this->createStream('12345')
),
hash('12345', Algorithm::MD5),
hash('12345', Algorithm::Md5),
];

$stream = $this->createStream('12345');
$stream->seek(3);
yield 'from-partially-read-stream' => [
$this->createResponse()
->withBody($stream),
hash('12345', Algorithm::MD5),
hash('12345', Algorithm::Md5),
3,
];
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public function it_can_remove_sensitive_keys_from_response(array $headers, array
*/
public function it_can_remove_sensitive_keys_from_response_with_request_context(
array $headers,
array $expected
array $expected,
): void {
$request = $this->createRequest('GET', 'something');

Expand All @@ -96,7 +96,7 @@ public function it_can_remove_sensitive_keys_from_response_with_request_context(
*/
public function it_can_remove_sensitive_keys_from_response_with_request_context_even_if_base_method_does_not_exist(
array $headers,
array $expected
array $expected,
): void {
$request = $this->createRequest('GET', 'something');

Expand Down
4 changes: 2 additions & 2 deletions tests/Unit/Formatter/RemoveSensitiveJsonKeysFormatterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public function it_can_remove_sensitive_json_keys_from_response(array $content,
*/
public function it_can_remove_sensitive_json_keys_from_response_with_request_context(
array $content,
array $expected
array $expected,
): void {
$request = $this->createRequest('GET', 'something')
->withBody(
Expand All @@ -91,7 +91,7 @@ public function it_can_remove_sensitive_json_keys_from_response_with_request_con
*/
public function it_can_remove_sensitive_json_keys_from_response_with_request_context_if_base_method_does_not_exist(
array $content,
array $expected
array $expected,
): void {
$request = $this->createRequest('GET', 'something')
->withBody(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ protected function setUp(): void
*/
public function it_can_remove_sensitive_query_strings_from_request(
string $actual,
string $expected
string $expected,
): void {
$request = $this->createRequest('GET', $actual);
$formatted = $this->formatter->formatRequest($request);
Expand Down
Binary file modified tools/php-cs-fixer.phar
Binary file not shown.
Loading

0 comments on commit ee9ca4b

Please sign in to comment.