Skip to content

Commit b82d082

Browse files
authored
feat: upgrade to doctrine/codingstandard:10 (#115)
1 parent eed34c1 commit b82d082

18 files changed

+101
-139
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
"thecodingmachine/safe": "^2.2"
1919
},
2020
"require-dev": {
21-
"doctrine/coding-standard": "^9",
21+
"doctrine/coding-standard": "^10",
2222
"ergebnis/composer-normalize": "^2.27",
2323
"infection/infection": "^0.26",
2424
"phpstan/extension-installer": "^1.1",

src/Exception/NoResponse.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ class NoResponse extends Exception
1212
{
1313
protected string $method;
1414
protected string $path;
15-
protected ?string $statusCode = null;
15+
protected string|null $statusCode = null;
1616

1717
public static function forPathAndMethod(string $path, string $method): self
1818
{

src/OpenAPIFaker.php

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ public static function createFromYaml(string $yaml): self
6666
public function mockRequest(
6767
string $path,
6868
string $method,
69-
string $contentType = 'application/json'
69+
string $contentType = 'application/json',
7070
): mixed {
7171
$operation = $this->findOperation($path, $method);
7272

@@ -93,7 +93,7 @@ public function mockResponse(
9393
string $path,
9494
string $method,
9595
string $statusCode = '200',
96-
string $contentType = 'application/json'
96+
string $contentType = 'application/json',
9797
): mixed {
9898
$operation = $this->findOperation($path, $method);
9999

@@ -119,9 +119,7 @@ public function mockResponse(
119119
return (new SchemaFaker($content->schema, $this->options))->generate();
120120
}
121121

122-
/**
123-
* @throws Exception
124-
*/
122+
/** @throws Exception */
125123
public function mockComponentSchema(string $schemaName): mixed
126124
{
127125
if ($this->openAPISchema->components === null) {
@@ -138,9 +136,7 @@ public function mockComponentSchema(string $schemaName): mixed
138136
return (new SchemaFaker($schema, $this->options))->generate();
139137
}
140138

141-
/**
142-
* @param array{minItems?:?int, maxItems?:?int, alwaysFakeOptionals?:bool} $options
143-
*/
139+
/** @param array{minItems?:?int, maxItems?:?int, alwaysFakeOptionals?:bool} $options */
144140
public function setOptions(array $options): self
145141
{
146142
foreach ($options as $key => $value) {
@@ -154,15 +150,13 @@ public function setOptions(array $options): self
154150
return $this;
155151
}
156152

157-
/**
158-
* @throws NoPath
159-
*/
153+
/** @throws NoPath */
160154
private function findOperation(string $path, string $method): Operation
161155
{
162156
try {
163157
$operation = (new LeagueOpenAPI\SpecFinder($this->openAPISchema))
164158
->findOperationSpec(new LeagueOpenAPI\OperationAddress($path, strtolower($method)));
165-
} catch (LeagueOpenAPI\Exception\NoPath $e) {
159+
} catch (LeagueOpenAPI\Exception\NoPath) {
166160
throw NoPath::forPathAndMethod($path, $method);
167161
}
168162

src/Options.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66

77
final class Options
88
{
9-
private ?int $minItems = null;
10-
private ?int $maxItems = null;
9+
private int|null $minItems = null;
10+
private int|null $maxItems = null;
1111
private bool $alwaysFakeOptionals = false;
1212

1313
public function setMinItems(int $minItems): Options
@@ -31,12 +31,12 @@ public function setAlwaysFakeOptionals(bool $alwaysFakeOptionals): self
3131
return $this;
3232
}
3333

34-
public function getMinItems(): ?int
34+
public function getMinItems(): int|null
3535
{
3636
return $this->minItems;
3737
}
3838

39-
public function getMaxItems(): ?int
39+
public function getMaxItems(): int|null
4040
{
4141
return $this->maxItems;
4242
}

src/SchemaFaker/ArrayFaker.php

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,10 @@
1515
use const SORT_REGULAR;
1616
use const SORT_STRING;
1717

18-
/**
19-
* @internal
20-
*/
18+
/** @internal */
2119
final class ArrayFaker
2220
{
23-
/**
24-
* @return array<mixed>
25-
*/
21+
/** @return array<mixed> */
2622
public static function generate(Schema $schema, Options $options): array
2723
{
2824
$minimum = $schema->minItems ?? 0;

src/SchemaFaker/BooleanFaker.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,7 @@
99

1010
use function random_int;
1111

12-
/**
13-
* @internal
14-
*/
12+
/** @internal */
1513
final class BooleanFaker
1614
{
1715
public static function generate(Schema $schema): bool

src/SchemaFaker/NumberFaker.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,7 @@
99

1010
use function mt_getrandmax;
1111

12-
/**
13-
* @internal
14-
*/
12+
/** @internal */
1513
final class NumberFaker
1614
{
1715
public static function generate(Schema $schema): int|float

src/SchemaFaker/ObjectFaker.php

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,10 @@
1414
use function count;
1515
use function in_array;
1616

17-
/**
18-
* @internal
19-
*/
17+
/** @internal */
2018
final class ObjectFaker
2119
{
22-
/**
23-
* @return array<mixed>
24-
*/
20+
/** @return array<mixed> */
2521
public static function generate(Schema $schema, Options $options, bool $request = false): array
2622
{
2723
$result = [];

src/SchemaFaker/SchemaFaker.php

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -16,26 +16,18 @@
1616
use function Safe\json_decode;
1717
use function Safe\json_encode;
1818

19-
/**
20-
* @internal
21-
*/
19+
/** @internal */
2220
final class SchemaFaker
2321
{
2422
private Schema $schema;
25-
private Options $options;
26-
private bool $request;
2723

28-
public function __construct(Schema $schema, Options $options, bool $request = false)
24+
public function __construct(Schema $schema, private Options $options, private bool $request = false)
2925
{
30-
$schemaData = json_decode(json_encode($schema->getSerializableData()), true);
31-
$this->schema = new Schema($this->resolveOfConstraints($schemaData));
32-
$this->options = $options;
33-
$this->request = $request;
26+
$schemaData = json_decode(json_encode($schema->getSerializableData()), true);
27+
$this->schema = new Schema($this->resolveOfConstraints($schemaData));
3428
}
3529

36-
/**
37-
* @return array<mixed>|string|bool|int|float
38-
*/
30+
/** @return array<mixed>|string|bool|int|float */
3931
public function generate(): array|string|bool|int|float
4032
{
4133
if ($this->schema->type === 'array') {

src/SchemaFaker/StringFaker.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,7 @@
1818

1919
use const DATE_RFC3339;
2020

21-
/**
22-
* @internal
23-
*/
21+
/** @internal */
2422
final class StringFaker
2523
{
2624
public static function generate(Schema $schema): string

0 commit comments

Comments
 (0)