Skip to content

Commit 563a671

Browse files
committed
🎨
1 parent c283603 commit 563a671

35 files changed

Lines changed: 562 additions & 281 deletions

src/Concerns/BuildsArray.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ trait BuildsArray
1515
* any vendor extensions registered via HasExtensions.
1616
*
1717
* @param array<string, mixed> $fields
18+
*
1819
* @return array<string, mixed>
1920
*/
2021
protected function buildArray(array $fields): array

src/Objects/Example.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,9 @@ public function toArray(): array
8383

8484
if ($this->hasValue) {
8585
// Inserted after buildArray so null literal values can be emitted.
86-
$output = ['value' => $this->value] + $output;
86+
$output = [
87+
'value' => $this->value,
88+
] + $output;
8789
// Restore conventional key order: summary, description, value, externalValue.
8890
$ordered = [];
8991

src/Objects/MediaType.php

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,6 @@ final class MediaType implements Serializable
1414
use BuildsArray;
1515
use HasExtensions;
1616

17-
/**
18-
* @var JsonSchema|array<string, mixed>|Reference|null
19-
*/
20-
private JsonSchema|array|Reference|null $schema = null;
21-
2217
private bool $hasExample = false;
2318

2419
private mixed $example = null;
@@ -38,10 +33,8 @@ final class MediaType implements Serializable
3833
*/
3934
private function __construct(
4035
private readonly string $contentType,
41-
JsonSchema|array|Reference|null $schema = null,
42-
) {
43-
$this->schema = $schema;
44-
}
36+
private JsonSchema|array|Reference|null $schema = null,
37+
) {}
4538

4639
public static function of(string $contentType): self
4740
{

src/Objects/OAuthFlows.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,30 +26,30 @@ public static function create(): self
2626
return new self();
2727
}
2828

29-
public function implicit(?OAuthFlow $flow): self
29+
public function implicit(?OAuthFlow $oAuthFlow): self
3030
{
31-
$this->implicit = $flow;
31+
$this->implicit = $oAuthFlow;
3232

3333
return $this;
3434
}
3535

36-
public function password(?OAuthFlow $flow): self
36+
public function password(?OAuthFlow $oAuthFlow): self
3737
{
38-
$this->password = $flow;
38+
$this->password = $oAuthFlow;
3939

4040
return $this;
4141
}
4242

43-
public function clientCredentials(?OAuthFlow $flow): self
43+
public function clientCredentials(?OAuthFlow $oAuthFlow): self
4444
{
45-
$this->clientCredentials = $flow;
45+
$this->clientCredentials = $oAuthFlow;
4646

4747
return $this;
4848
}
4949

50-
public function authorizationCode(?OAuthFlow $flow): self
50+
public function authorizationCode(?OAuthFlow $oAuthFlow): self
5151
{
52-
$this->authorizationCode = $flow;
52+
$this->authorizationCode = $oAuthFlow;
5353

5454
return $this;
5555
}

src/Objects/Operation.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ final class Operation implements Serializable
5757
private array $servers = [];
5858

5959
private function __construct(
60-
private readonly HttpMethod $method,
60+
private readonly HttpMethod $httpMethod,
6161
) {}
6262

6363
public static function get(): self
@@ -102,7 +102,7 @@ public static function trace(): self
102102

103103
public function getMethod(): HttpMethod
104104
{
105-
return $this->method;
105+
return $this->httpMethod;
106106
}
107107

108108
public function tags(string ...$tags): self

src/Objects/Parameter.php

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,6 @@ final class Parameter implements Serializable
2929

3030
private ?bool $allowReserved = null;
3131

32-
/**
33-
* @var JsonSchema|array<string, mixed>|Reference|null
34-
*/
35-
private JsonSchema|array|Reference|null $schema = null;
36-
3732
private bool $hasExample = false;
3833

3934
private mixed $example = null;
@@ -54,10 +49,8 @@ final class Parameter implements Serializable
5449
private function __construct(
5550
private readonly string $name,
5651
private readonly In $in,
57-
JsonSchema|array|Reference|null $schema = null,
52+
private JsonSchema|array|Reference|null $schema = null,
5853
) {
59-
$this->schema = $schema;
60-
6154
if ($in === In::Path) {
6255
$this->required = true;
6356
}

src/Objects/PathItem.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,14 +111,14 @@ public function toArray(): array
111111

112112
if ($this->parameters !== []) {
113113
$output['parameters'] = array_map(
114-
fn (Parameter|Reference $parameter): array => $parameter->toArray(),
114+
fn(Parameter|Reference $parameter): array => $parameter->toArray(),
115115
$this->parameters,
116116
);
117117
}
118118

119119
if ($this->servers !== []) {
120120
$output['servers'] = array_map(
121-
fn (Server $server): array => $server->toArray(),
121+
fn(Server $server): array => $server->toArray(),
122122
$this->servers,
123123
);
124124
}

src/Objects/Reference.php

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@
77
use InvalidArgumentException;
88
use Cortex\OpenApi\Contracts\Serializable;
99

10-
final class Reference implements Serializable
10+
final readonly class Reference implements Serializable
1111
{
1212
private function __construct(
13-
private readonly string $pointer,
14-
private readonly ?string $summary,
15-
private readonly ?string $description,
13+
private string $pointer,
14+
private ?string $summary,
15+
private ?string $description,
1616
) {}
1717

1818
public static function to(string $pointer, ?string $summary = null, ?string $description = null): self
@@ -29,7 +29,9 @@ public static function to(string $pointer, ?string $summary = null, ?string $des
2929
*/
3030
public function toArray(): array
3131
{
32-
$output = ['$ref' => $this->pointer];
32+
$output = [
33+
'$ref' => $this->pointer,
34+
];
3335

3436
if ($this->summary !== null) {
3537
$output['summary'] = $this->summary;

src/Objects/Response.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ final class Response implements Serializable
1616
/**
1717
* Default description used by the named constructors when the user does not override it.
1818
*/
19-
private const DEFAULT_DESCRIPTIONS = [
19+
private const array DEFAULT_DESCRIPTIONS = [
2020
'200' => 'OK',
2121
'201' => 'Created',
2222
'202' => 'Accepted',

src/Objects/SecurityRequirement.php

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

77
use Cortex\OpenApi\Contracts\Serializable;
88

9-
final class SecurityRequirement implements Serializable
9+
final readonly class SecurityRequirement implements Serializable
1010
{
1111
/**
1212
* @param array<int, string> $scopes
1313
*/
1414
private function __construct(
15-
private readonly ?string $scheme,
16-
private readonly array $scopes,
15+
private ?string $scheme,
16+
private array $scopes,
1717
) {}
1818

1919
/**
@@ -41,6 +41,8 @@ public function toArray(): array
4141
return [];
4242
}
4343

44-
return [$this->scheme => $this->scopes];
44+
return [
45+
$this->scheme => $this->scopes,
46+
];
4547
}
4648
}

0 commit comments

Comments
 (0)