Skip to content

Commit 78ec0a3

Browse files
canvuralscaytrase
authored andcommitted
Update doctrine/coding-standard to 8.2
1 parent 8e083f4 commit 78ec0a3

File tree

179 files changed

+591
-473
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

179 files changed

+591
-473
lines changed

composer.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
},
3636
"require-dev": {
3737
"cache/array-adapter": "^1.0",
38-
"doctrine/coding-standard": "^6.0",
38+
"doctrine/coding-standard": "^8.0",
3939
"guzzlehttp/psr7": "^1.5",
4040
"phpunit/phpunit": "^7|^8"
4141
},

phpcs.xml

+7-1
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,11 @@
1313
<file>tests</file>
1414

1515
<!-- Include full Doctrine Coding Standard -->
16-
<rule ref="Doctrine"/>
16+
<rule ref="Doctrine">
17+
<exclude name="SlevomatCodingStandard.PHP.RequireExplicitAssertion"/>
18+
19+
// This is only for PHP 7.4 and up
20+
<exclude name="SlevomatCodingStandard.TypeHints.PropertyTypeHint.MissingNativeTypeHint"/>
21+
<exclude name="SlevomatCodingStandard.ControlStructures.RequireNullCoalesceEqualOperator.RequiredNullCoalesceEqualOperator"/>
22+
</rule>
1723
</ruleset>

src/Foundation/ArrayHelper.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ final class ArrayHelper
2020
*
2121
* @param mixed[] $arr
2222
*/
23-
public static function isAssoc(array $arr) : bool
23+
public static function isAssoc(array $arr): bool
2424
{
2525
if ($arr === []) {
2626
return false;

src/PSR15/Exception/InvalidRequestMessage.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
class InvalidRequestMessage extends ValidationFailed
1010
{
11-
public static function because(ValidationFailed $e) : self
11+
public static function because(ValidationFailed $e): self
1212
{
1313
return new static('Request message failed validation', 0, $e);
1414
}

src/PSR15/Exception/InvalidResponseMessage.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
class InvalidResponseMessage extends ValidationFailed
1010
{
11-
public static function because(ValidationFailed $e) : self
11+
public static function because(ValidationFailed $e): self
1212
{
1313
return new static('Response message failed validation', 0, $e);
1414
}

src/PSR15/Exception/InvalidServerRequestMessage.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
class InvalidServerRequestMessage extends ValidationFailed
1010
{
11-
public static function because(ValidationFailed $e) : self
11+
public static function because(ValidationFailed $e): self
1212
{
1313
return new static('Server Request message failed validation', 0, $e);
1414
}

src/PSR15/SlimAdapter.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public function __construct(MiddlewareInterface $middleware)
2727
$this->middleware = $middleware;
2828
}
2929

30-
public function __invoke(ServerRequestInterface $request, ResponseInterface $response, callable $next) : ResponseInterface
30+
public function __invoke(ServerRequestInterface $request, ResponseInterface $response, callable $next): ResponseInterface
3131
{
3232
$this->response = $response;
3333
$this->next = $next;
@@ -37,7 +37,7 @@ public function __invoke(ServerRequestInterface $request, ResponseInterface $res
3737
return $this->middleware->process($request, $this);
3838
}
3939

40-
public function handle(ServerRequestInterface $request) : ResponseInterface
40+
public function handle(ServerRequestInterface $request): ResponseInterface
4141
{
4242
return ($this->next)($request, $this->response);
4343
}

src/PSR15/ValidationMiddleware.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public function __construct(ServerRequestValidator $requestValidator, ResponseVa
3434
* If unable to produce the response itself, it may delegate to the provided
3535
* request handler to do so.
3636
*/
37-
public function process(ServerRequestInterface $request, RequestHandlerInterface $handler) : ResponseInterface
37+
public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
3838
{
3939
// 1. Validate request
4040
try {

src/PSR15/ValidationMiddlewareBuilder.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
class ValidationMiddlewareBuilder extends ValidatorBuilder
1111
{
12-
public function getValidationMiddleware() : MiddlewareInterface
12+
public function getValidationMiddleware(): MiddlewareInterface
1313
{
1414
return new ValidationMiddleware(
1515
$this->getServerRequestValidator(),

src/PSR7/CacheableSchemaFactory.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@
66

77
interface CacheableSchemaFactory extends SchemaFactory
88
{
9-
public function getCacheKey() : string;
9+
public function getCacheKey(): string;
1010
}

src/PSR7/CallbackAddress.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -21,17 +21,17 @@ public function __construct(string $path, string $method, string $callbackName,
2121
$this->callbackMethod = $callbackMethod;
2222
}
2323

24-
public function callbackName() : string
24+
public function callbackName(): string
2525
{
2626
return $this->callbackName;
2727
}
2828

29-
public function callbackMethod() : string
29+
public function callbackMethod(): string
3030
{
3131
return $this->callbackMethod;
3232
}
3333

34-
public function __toString() : string
34+
public function __toString(): string
3535
{
3636
return sprintf('Callback [%s %s %s %s]', $this->method, $this->path, $this->callbackName, $this->callbackMethod);
3737
}

src/PSR7/CallbackRequestValidator.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -32,15 +32,15 @@ public function __construct(OpenApi $schema)
3232
);
3333
}
3434

35-
public function getSchema() : OpenApi
35+
public function getSchema(): OpenApi
3636
{
3737
return $this->openApi;
3838
}
3939

4040
/**
4141
* @throws ValidationFailed
4242
*/
43-
public function validate(CallbackAddress $opAddr, RequestInterface $serverRequest) : void
43+
public function validate(CallbackAddress $opAddr, RequestInterface $serverRequest): void
4444
{
4545
$this->validator->validate($opAddr, $serverRequest);
4646
}

src/PSR7/CallbackResponseAddress.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,12 @@ public function __construct(string $path, string $method, string $callbackName,
1717
$this->responseCode = $responseCode;
1818
}
1919

20-
public function responseCode() : int
20+
public function responseCode(): int
2121
{
2222
return $this->responseCode;
2323
}
2424

25-
public function __toString() : string
25+
public function __toString(): string
2626
{
2727
return sprintf('Callback [%s %s %s %s %d]', $this->method, $this->path, $this->callbackName, $this->callbackMethod, $this->responseCode);
2828
}

src/PSR7/CallbackResponseValidator.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,15 @@ public function __construct(OpenApi $schema)
2828
);
2929
}
3030

31-
public function getSchema() : OpenApi
31+
public function getSchema(): OpenApi
3232
{
3333
return $this->openApi;
3434
}
3535

3636
/**
3737
* @throws ValidationFailed
3838
*/
39-
public function validate(CallbackAddress $opAddr, ResponseInterface $serverRequest) : void
39+
public function validate(CallbackAddress $opAddr, ResponseInterface $serverRequest): void
4040
{
4141
$opAddr = new CallbackResponseAddress(
4242
$opAddr->path(),

src/PSR7/Exception/MultipleOperationsMismatchForRequest.php

+3-2
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
namespace League\OpenAPIValidation\PSR7\Exception;
66

77
use League\OpenAPIValidation\PSR7\OperationAddress;
8+
89
use function array_map;
910
use function implode;
1011
use function sprintf;
@@ -17,7 +18,7 @@ class MultipleOperationsMismatchForRequest extends ValidationFailed
1718
/**
1819
* @param OperationAddress[] $addrs
1920
*/
20-
public static function fromMatchedAddrs(array $addrs) : self
21+
public static function fromMatchedAddrs(array $addrs): self
2122
{
2223
$addrsStrings = array_map(static function (OperationAddress $addr) {
2324
return sprintf('[%s,%s]', $addr->path(), $addr->method());
@@ -33,7 +34,7 @@ public static function fromMatchedAddrs(array $addrs) : self
3334
/**
3435
* @return OperationAddress[]
3536
*/
36-
public function matchedAddrs() : array
37+
public function matchedAddrs(): array
3738
{
3839
return $this->matchedAddrs;
3940
}

src/PSR7/Exception/NoCallback.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class NoCallback extends NoOperation
1414
/** @var string */
1515
protected $callbackMethod;
1616

17-
public static function fromCallbackPath(string $path, string $method, string $callbackName, string $callbackMethod) : self
17+
public static function fromCallbackPath(string $path, string $method, string $callbackName, string $callbackMethod): self
1818
{
1919
$i = new self(sprintf('OpenAPI spec contains no such callback [%s,%s,%s,%s]', $path, $method, $callbackName, $callbackMethod));
2020
$i->path = $path;
@@ -25,7 +25,7 @@ public static function fromCallbackPath(string $path, string $method, string $ca
2525
return $i;
2626
}
2727

28-
public function method() : string
28+
public function method(): string
2929
{
3030
return $this->method;
3131
}

src/PSR7/Exception/NoOperation.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ class NoOperation extends NoPath
1111
/** @var string */
1212
protected $method;
1313

14-
public static function fromPathAndMethod(string $path, string $method) : self
14+
public static function fromPathAndMethod(string $path, string $method): self
1515
{
1616
$i = new self(sprintf('OpenAPI spec contains no such operation [%s,%s]', $path, $method));
1717
$i->path = $path;
@@ -20,7 +20,7 @@ public static function fromPathAndMethod(string $path, string $method) : self
2020
return $i;
2121
}
2222

23-
public function method() : string
23+
public function method(): string
2424
{
2525
return $this->method;
2626
}

src/PSR7/Exception/NoPath.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,15 @@ class NoPath extends ValidationFailed
1111
/** @var string */
1212
protected $path;
1313

14-
public static function fromPath(string $path) : self
14+
public static function fromPath(string $path): self
1515
{
1616
$i = new self(sprintf('OpenAPI spec contains no such operation [%s]', $path));
1717
$i->path = $path;
1818

1919
return $i;
2020
}
2121

22-
public function path() : string
22+
public function path(): string
2323
{
2424
return $this->path;
2525
}

src/PSR7/Exception/NoResponseCode.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ class NoResponseCode extends NoOperation
1111
/** @var int */
1212
protected $responseCode;
1313

14-
public static function fromPathAndMethodAndResponseCode(string $path, string $method, int $responseCode) : self
14+
public static function fromPathAndMethodAndResponseCode(string $path, string $method, int $responseCode): self
1515
{
1616
$i = new self(sprintf('OpenAPI spec contains no such operation [%s,%s,%d]', $path, $method, $responseCode));
1717
$i->path = $path;
@@ -21,7 +21,7 @@ public static function fromPathAndMethodAndResponseCode(string $path, string $me
2121
return $i;
2222
}
2323

24-
public function responseCode() : int
24+
public function responseCode(): int
2525
{
2626
return $this->responseCode;
2727
}

src/PSR7/Exception/Validation/AddressValidationFailed.php

+4-3
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
use League\OpenAPIValidation\PSR7\Exception\ValidationFailed;
88
use League\OpenAPIValidation\PSR7\OperationAddress;
99
use Throwable;
10+
1011
use function sprintf;
1112

1213
abstract class AddressValidationFailed extends ValidationFailed
@@ -17,7 +18,7 @@ abstract class AddressValidationFailed extends ValidationFailed
1718
/**
1819
* @return static
1920
*/
20-
public static function fromAddrAndPrev(OperationAddress $address, Throwable $prev) : self
21+
public static function fromAddrAndPrev(OperationAddress $address, Throwable $prev): self
2122
{
2223
$ex = new static(sprintf('Validation failed for %s', $address), $prev->getCode(), $prev);
2324
$ex->address = $address;
@@ -28,15 +29,15 @@ public static function fromAddrAndPrev(OperationAddress $address, Throwable $pre
2829
/**
2930
* @return static
3031
*/
31-
public static function fromAddr(OperationAddress $address) : self
32+
public static function fromAddr(OperationAddress $address): self
3233
{
3334
$ex = new static(sprintf('Validation failed for %s', $address));
3435
$ex->address = $address;
3536

3637
return $ex;
3738
}
3839

39-
public function getAddress() : OperationAddress
40+
public function getAddress(): OperationAddress
4041
{
4142
return $this->address;
4243
}

src/PSR7/Exception/Validation/InvalidBody.php

+4-3
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
use League\OpenAPIValidation\PSR7\OperationAddress;
88
use League\OpenAPIValidation\Schema\Exception\SchemaMismatch;
9+
910
use function sprintf;
1011

1112
class InvalidBody extends AddressValidationFailed
@@ -14,7 +15,7 @@ public static function becauseBodyDoesNotMatchSchema(
1415
string $contentType,
1516
OperationAddress $addr,
1617
SchemaMismatch $prev
17-
) : self {
18+
): self {
1819
$exception = static::fromAddrAndPrev($addr, $prev);
1920
$exception->message = sprintf('Body does not match schema for content-type "%s" for %s', $contentType, $addr);
2021

@@ -26,7 +27,7 @@ public static function becauseBodyDoesNotMatchSchemaMultipart(
2627
string $contentType,
2728
OperationAddress $addr,
2829
?SchemaMismatch $prev = null
29-
) : self {
30+
): self {
3031
$exception = $prev ? static::fromAddrAndPrev($addr, $prev) : static::fromAddr($addr);
3132
$exception->message = sprintf(
3233
'Multipart body does not match schema for part "%s" with content-type "%s" for %s',
@@ -38,7 +39,7 @@ public static function becauseBodyDoesNotMatchSchemaMultipart(
3839
return $exception;
3940
}
4041

41-
public static function becauseBodyIsNotValidJson(string $error, OperationAddress $addr) : self
42+
public static function becauseBodyIsNotValidJson(string $error, OperationAddress $addr): self
4243
{
4344
$exception = static::fromAddr($addr);
4445
$exception->message = sprintf('JSON parsing failed with "%s" for %s', $error, $addr);

src/PSR7/Exception/Validation/InvalidCookies.php

+3-2
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,20 @@
66

77
use League\OpenAPIValidation\PSR7\OperationAddress;
88
use League\OpenAPIValidation\Schema\Exception\SchemaMismatch;
9+
910
use function sprintf;
1011

1112
class InvalidCookies extends AddressValidationFailed
1213
{
13-
public static function becauseOfMissingRequiredCookie(string $cookieName, OperationAddress $address) : self
14+
public static function becauseOfMissingRequiredCookie(string $cookieName, OperationAddress $address): self
1415
{
1516
$exception = static::fromAddr($address);
1617
$exception->message = sprintf('Missing required cookie "%s" for %s', $cookieName, $address);
1718

1819
return $exception;
1920
}
2021

21-
public static function becauseValueDoesNotMatchSchema(string $cookieName, string $cookieValue, OperationAddress $address, SchemaMismatch $prev) : self
22+
public static function becauseValueDoesNotMatchSchema(string $cookieName, string $cookieValue, OperationAddress $address, SchemaMismatch $prev): self
2223
{
2324
$exception = static::fromAddrAndPrev($address, $prev);
2425
$exception->message = sprintf('Value "%s" for cookie "%s" is invalid for %s', $cookieValue, $cookieName, $address);

0 commit comments

Comments
 (0)