Skip to content

Commit

Permalink
Use codestyle supporting php 8.1
Browse files Browse the repository at this point in the history
  • Loading branch information
MortalFlesh committed Apr 22, 2022
1 parent 4952e27 commit 6f8d368
Show file tree
Hide file tree
Showing 13 changed files with 49 additions and 57 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
<!-- There should always be "Unreleased" section at the beginning. -->

## Unreleased
- [**BC**] Require php 8.1
- Require php 8.1
- [**BC**] Use new language features and change method signatures

## 2.0.0 - 2021-08-10
- [**BC**] Add an `$initiator` to `ResponseDecoders` `supports` method
Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@
"ext-json": "*",
"ext-mbstring": "*",
"fig/http-message-util": "^1.1",
"lmc/cqrs-types": "dev-feature/require-php-81@dev",
"lmc/cqrs-types": "^3.0",
"psr/http-client": "^1.0",
"psr/http-factory": "^1.0",
"psr/http-message": "^1.0"
},
"require-dev": {
"ergebnis/composer-normalize": "^2.5",
"guzzlehttp/psr7": "^2.1",
"lmc/coding-standard": "^3.2",
"lmc/coding-standard": "^3.3",
"nyholm/psr7": "^1.4",
"php-parallel-lint/php-parallel-lint": "^1.2",
"phpstan/extension-installer": "^1.1",
Expand Down
10 changes: 2 additions & 8 deletions ecs.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
declare(strict_types=1);

use Lmc\CodingStandard\Sniffs\Naming\ClassNameSuffixByParentSniff;
use PhpCsFixer\Fixer\Operator\BinaryOperatorSpacesFixer;
use PhpCsFixer\Fixer\Phpdoc\NoSuperfluousPhpdocTagsFixer;
use PhpCsFixer\Fixer\PhpUnit\PhpUnitTestAnnotationFixer;
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
use Symplify\EasyCodingStandard\ValueObject\Option;
Expand All @@ -16,8 +14,7 @@
Option::SKIP,
[
'SlevomatCodingStandard\Sniffs\Exceptions\ReferenceThrowableOnlySniff.ReferencedGeneralException' => ['tests/Exception/*.php'],
BinaryOperatorSpacesFixer::class => null,
]
],
);

$containerConfigurator->import(__DIR__ . '/vendor/lmc/coding-standard/ecs.php');
Expand All @@ -30,8 +27,5 @@
$services->set(ClassNameSuffixByParentSniff::class)
->property('extraParentTypesToSuffixes', ['*ApplicatorInterface' => 'Applicator']);

$services->set(NoSuperfluousPhpdocTagsFixer::class)
->call('configure', [['allow_mixed' => true]]);

$containerConfigurator->import(__DIR__ . '/vendor/lmc/coding-standard/ecs-7.4.php');
$containerConfigurator->import(__DIR__ . '/vendor/lmc/coding-standard/ecs-8.1.php');
};
2 changes: 1 addition & 1 deletion phpstan.neon
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
parameters:
checkMissingIterableValueType: false
treatPhpDocTypesAsCertain: false
level: 7
level: 8
paths:
- src
- tests/
Expand Down
3 changes: 1 addition & 2 deletions src/Command/AbstractHttpCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,7 @@ public function modifyRequest(RequestInterface $request): RequestInterface
/** @see RequestMethodInterface */
abstract public function getHttpMethod(): string;

/** @return UriInterface|string */
abstract public function getUri();
abstract public function getUri(): UriInterface|string;

public function getProfilerId(): string
{
Expand Down
3 changes: 1 addition & 2 deletions src/Decoder/StreamResponseDecoder.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@ public function decode(mixed $response): mixed
: $response;
}

/** @return StreamInterface|string */
private function decodeStream(StreamInterface $stream)
private function decodeStream(StreamInterface $stream): StreamInterface|string
{
try {
if (!empty($contents = $stream->getContents())) {
Expand Down
2 changes: 1 addition & 1 deletion src/Exception/HttpBadRequestException.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public function __construct(
private RequestInterface $request,
private ResponseInterface $response,
int $code = 0,
?\Throwable $previous = null
?\Throwable $previous = null,
) {
parent::__construct(self::createMessage($response->getReasonPhrase()), $code, $previous);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Exception/HttpServerErrorException.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public function __construct(
private RequestInterface $request,
private ResponseInterface $response,
int $code = 0,
?\Throwable $previous = null
?\Throwable $previous = null,
) {
parent::__construct(self::createMessage($response->getReasonPhrase()), $code, $previous);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Query/AbstractHttpGetQuery.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public function getCacheKey(): CacheKey
return new CacheKey(sprintf(
'%s:%s',
static::class,
$this->getUri()
$this->getUri(),
));
}
}
3 changes: 1 addition & 2 deletions src/Query/AbstractHttpQuery.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,7 @@ public function modifyRequest(RequestInterface $request): RequestInterface
/** @see RequestMethodInterface */
abstract public function getHttpMethod(): string;

/** @return UriInterface|string */
abstract public function getUri();
abstract public function getUri(): UriInterface|string;

public function getProfilerId(): string
{
Expand Down
58 changes: 29 additions & 29 deletions tests/Formatter/HttpProfilerFormatterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,14 @@ public function provideNyholmItems(): iterable
'test',
'',
$request = (new \Nyholm\Psr7\Request('get', 'url'))
->withBody(\Nyholm\Psr7\Stream::create('body'))
->withBody(\Nyholm\Psr7\Stream::create('body')),
),
new ProfilerItem(
'id',
null,
'test',
'',
new FormattedValue($request, 'body')
new FormattedValue($request, 'body'),
),
];

Expand All @@ -69,14 +69,14 @@ public function provideNyholmItems(): iterable
'test',
'',
$request = (new \Nyholm\Psr7\Request('get', 'url'))
->withBody(\Nyholm\Psr7\Stream::create())
->withBody(\Nyholm\Psr7\Stream::create()),
),
new ProfilerItem(
'id',
null,
'test',
'',
new FormattedValue($request, '')
new FormattedValue($request, ''),
),
];

Expand All @@ -86,14 +86,14 @@ public function provideNyholmItems(): iterable
null,
'test',
'',
$response = (new \Nyholm\Psr7\Response(200, [], 'body'))
$response = (new \Nyholm\Psr7\Response(200, [], 'body')),
),
new ProfilerItem(
'id',
null,
'test',
'',
new FormattedValue($response, 'body')
new FormattedValue($response, 'body'),
),
];

Expand All @@ -103,14 +103,14 @@ public function provideNyholmItems(): iterable
null,
'test',
'',
$response = (new \Nyholm\Psr7\Response(200, [], \Nyholm\Psr7\Stream::create('body')))
$response = (new \Nyholm\Psr7\Response(200, [], \Nyholm\Psr7\Stream::create('body'))),
),
new ProfilerItem(
'id',
null,
'test',
'',
new FormattedValue($response, 'body')
new FormattedValue($response, 'body'),
),
];

Expand All @@ -120,14 +120,14 @@ public function provideNyholmItems(): iterable
null,
'test',
'',
$stream = (\Nyholm\Psr7\Stream::create('body'))
$stream = (\Nyholm\Psr7\Stream::create('body')),
),
new ProfilerItem(
'id',
null,
'test',
'',
new FormattedValue($stream, 'body')
new FormattedValue($stream, 'body'),
),
];
}
Expand All @@ -141,14 +141,14 @@ public function provideNyholmAdditioanlItems(): iterable
'additional' => $request = (new \Nyholm\Psr7\Request('get', 'url'))
->withBody(\Nyholm\Psr7\Stream::create('body')),
],
'test'
'test',
),
new ProfilerItem(
'id',
[
'additional' => new FormattedValue($request, 'body'),
],
'test'
'test',
),
];

Expand Down Expand Up @@ -193,17 +193,17 @@ public function provideNyholmAdditioanlItems(): iterable
'additional' => $response = (new \Nyholm\Psr7\Response(
200,
[],
\Nyholm\Psr7\Stream::create('body')
\Nyholm\Psr7\Stream::create('body'),
)),
],
'test'
'test',
),
new ProfilerItem(
'id',
[
'additional' => new FormattedValue($response, 'body'),
],
'test'
'test',
),
];

Expand Down Expand Up @@ -234,14 +234,14 @@ public function provideGuzzleItems(): iterable
'test',
'',
$request = (new \GuzzleHttp\Psr7\Request('post', 'url'))
->withBody(Utils::streamFor('body'))
->withBody(Utils::streamFor('body')),
),
new ProfilerItem(
'id',
null,
'test',
'',
new FormattedValue($request, 'body')
new FormattedValue($request, 'body'),
),
];

Expand All @@ -252,14 +252,14 @@ public function provideGuzzleItems(): iterable
'test',
'',
$request = (new \GuzzleHttp\Psr7\Request('post', 'url'))
->withBody(Utils::streamFor(null))
->withBody(Utils::streamFor(null)),
),
new ProfilerItem(
'id',
null,
'test',
'',
new FormattedValue($request, '')
new FormattedValue($request, ''),
),
];

Expand All @@ -269,14 +269,14 @@ public function provideGuzzleItems(): iterable
null,
'test',
'',
$response = (new \GuzzleHttp\Psr7\Response(200, [], 'body'))
$response = (new \GuzzleHttp\Psr7\Response(200, [], 'body')),
),
new ProfilerItem(
'id',
null,
'test',
'',
new FormattedValue($response, 'body')
new FormattedValue($response, 'body'),
),
];

Expand All @@ -286,14 +286,14 @@ public function provideGuzzleItems(): iterable
null,
'test',
'',
$response = (new \GuzzleHttp\Psr7\Response(200, [], Utils::streamFor('body')))
$response = (new \GuzzleHttp\Psr7\Response(200, [], Utils::streamFor('body'))),
),
new ProfilerItem(
'id',
null,
'test',
'',
new FormattedValue($response, 'body')
new FormattedValue($response, 'body'),
),
];

Expand All @@ -303,14 +303,14 @@ public function provideGuzzleItems(): iterable
null,
'test',
'',
$stream = (Utils::streamFor('body'))
$stream = (Utils::streamFor('body')),
),
new ProfilerItem(
'id',
null,
'test',
'',
new FormattedValue($stream, 'body')
new FormattedValue($stream, 'body'),
),
];
}
Expand All @@ -331,7 +331,7 @@ public function provideGuzzleAdditionalItems(): iterable
[
'additional' => new FormattedValue($request, 'body'),
],
'test'
'test',
),
];

Expand All @@ -348,7 +348,7 @@ public function provideGuzzleAdditionalItems(): iterable
[
'additional' => new FormattedValue($request, ''),
],
'test'
'test',
),
];

Expand Down Expand Up @@ -392,14 +392,14 @@ public function provideGuzzleAdditionalItems(): iterable
null,
'test',
'',
$stream = (Utils::streamFor('body'))
$stream = (Utils::streamFor('body')),
),
new ProfilerItem(
'id',
null,
'test',
'',
new FormattedValue($stream, 'body')
new FormattedValue($stream, 'body'),
),
];
}
Expand Down
6 changes: 3 additions & 3 deletions tests/Handler/HttpQueryHandlerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public function shouldFetchHttpQuery(): void
new OnSuccessCallback(
fn (ResponseInterface $response) => $this->assertSame($data, $response->getBody()->getContents())
),
new OnErrorCallback(fn (\Throwable $error) => $this->fail($error->getMessage()))
new OnErrorCallback(fn (\Throwable $error) => $this->fail($error->getMessage())),
);
}

Expand Down Expand Up @@ -72,7 +72,7 @@ public function shouldFetchHttpQueryAsErrorWithBadRequest(): void
$this->assertSame($request, $error->getRequest());
$this->assertSame($response, $error->getResponse());
}
})
}),
);
}

Expand Down Expand Up @@ -103,7 +103,7 @@ public function shouldFetchHttpQueryAsErrorWithServerError(): void
$this->assertSame($request, $error->getRequest());
$this->assertSame($response, $error->getResponse());
}
})
}),
);
}
}
Loading

0 comments on commit 6f8d368

Please sign in to comment.