Skip to content

Commit 90ce269

Browse files
author
liutao
committed
feat: format
1 parent f89e940 commit 90ce269

10 files changed

Lines changed: 117 additions & 119 deletions

File tree

src/Contract/PathGetterInterface.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,5 @@
88

99
interface PathGetterInterface
1010
{
11-
public static function getPath(string $controller, string $function, MethodEnum $requestMethod = null): ?string;
11+
public static function getPath(string $controller, string $function, ?MethodEnum $requestMethod = null): ?string;
1212
}

src/Schema/Get.php

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -27,22 +27,22 @@ class Get extends \OpenApi\Attributes\Get
2727
* @param null|Attachable[] $attachables
2828
*/
2929
public function __construct(
30-
string $path = null,
31-
string $operationId = null,
32-
string $description = null,
33-
string $summary = null,
34-
array $security = null,
35-
array $servers = null,
36-
RequestBody $requestBody = null,
37-
array $tags = null,
38-
array $parameters = null,
39-
array $responses = null,
40-
array $callbacks = null,
41-
ExternalDocumentation $externalDocs = null,
42-
bool $deprecated = null,
30+
?string $path = null,
31+
?string $operationId = null,
32+
?string $description = null,
33+
?string $summary = null,
34+
?array $security = null,
35+
?array $servers = null,
36+
?RequestBody $requestBody = null,
37+
?array $tags = null,
38+
?array $parameters = null,
39+
?array $responses = null,
40+
?array $callbacks = null,
41+
?ExternalDocumentation $externalDocs = null,
42+
?bool $deprecated = null,
4343
// annotation
44-
array $x = null,
45-
array $attachables = null
44+
?array $x = null,
45+
?array $attachables = null
4646
) {
4747
parent::__construct(
4848
path: $path ?: RouteGetter::getRouteByContent(Generator::$context, MethodEnum::GET),

src/Schema/JsonContent.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
#[Attribute(Attribute::TARGET_CLASS)]
1212
class JsonContent extends SwaggerJsonContent
1313
{
14-
public function __construct(bool $isResponse, string $ref = null, array $properties = null)
14+
public function __construct(bool $isResponse, ?string $ref = null, ?array $properties = null)
1515
{
1616
if ($isResponse) {
1717
$baseProperties = static::getResponseBaseProperties();

src/Schema/Post.php

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -15,22 +15,22 @@
1515
class Post extends \OpenApi\Attributes\Post
1616
{
1717
public function __construct(
18-
string $path = null,
19-
string $operationId = null,
20-
string $description = null,
21-
string $summary = null,
22-
array $security = null,
23-
array $servers = null,
24-
RequestBody $requestBody = null,
25-
array $tags = null,
26-
array $parameters = null,
27-
array $responses = null,
28-
array $callbacks = null,
29-
ExternalDocumentation $externalDocs = null,
30-
bool $deprecated = null,
18+
?string $path = null,
19+
?string $operationId = null,
20+
?string $description = null,
21+
?string $summary = null,
22+
?array $security = null,
23+
?array $servers = null,
24+
?RequestBody $requestBody = null,
25+
?array $tags = null,
26+
?array $parameters = null,
27+
?array $responses = null,
28+
?array $callbacks = null,
29+
?ExternalDocumentation $externalDocs = null,
30+
?bool $deprecated = null,
3131
// annotation
32-
array $x = null,
33-
array $attachables = null
32+
?array $x = null,
33+
?array $attachables = null
3434
) {
3535
parent::__construct(
3636
path: $path ?: RouteGetter::getRouteByContent(Generator::$context, MethodEnum::POST),

src/Schema/Property.php

Lines changed: 35 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -35,47 +35,47 @@ class Property extends \OpenApi\Attributes\Property
3535
* @param null|Attachable[] $attachables
3636
*/
3737
public function __construct(
38-
string $property = null,
38+
?string $property = null,
3939
// schema
40-
object|string $ref = null,
41-
string $schema = null,
42-
string $title = null,
43-
string $description = null,
44-
int $maxProperties = null,
45-
int $minProperties = null,
46-
array $required = null,
47-
array $properties = null,
48-
array|string $type = null,
49-
string $format = null,
50-
Items $items = null,
51-
string $collectionFormat = null,
40+
null|object|string $ref = null,
41+
?string $schema = null,
42+
?string $title = null,
43+
?string $description = null,
44+
?int $maxProperties = null,
45+
?int $minProperties = null,
46+
?array $required = null,
47+
?array $properties = null,
48+
null|array|string $type = null,
49+
?string $format = null,
50+
?Items $items = null,
51+
?string $collectionFormat = null,
5252
mixed $default = Generator::UNDEFINED,
5353
$maximum = null,
54-
bool|float|int $exclusiveMaximum = null,
54+
null|bool|float|int $exclusiveMaximum = null,
5555
$minimum = null,
56-
bool|float|int $exclusiveMinimum = null,
57-
int $maxLength = null,
58-
int $minLength = null,
59-
int $maxItems = null,
60-
int $minItems = null,
61-
bool $uniqueItems = null,
62-
string $pattern = null,
63-
array|string $enum = null,
64-
Discriminator $discriminator = null,
65-
bool $readOnly = null,
66-
bool $writeOnly = null,
67-
Xml $xml = null,
68-
ExternalDocumentation $externalDocs = null,
56+
null|bool|float|int $exclusiveMinimum = null,
57+
?int $maxLength = null,
58+
?int $minLength = null,
59+
?int $maxItems = null,
60+
?int $minItems = null,
61+
?bool $uniqueItems = null,
62+
?string $pattern = null,
63+
null|array|string $enum = null,
64+
?Discriminator $discriminator = null,
65+
?bool $readOnly = null,
66+
?bool $writeOnly = null,
67+
?Xml $xml = null,
68+
?ExternalDocumentation $externalDocs = null,
6969
mixed $example = Generator::UNDEFINED,
70-
bool $nullable = null,
71-
bool $deprecated = null,
72-
array $allOf = null,
73-
array $anyOf = null,
74-
array $oneOf = null,
75-
AdditionalProperties|bool $additionalProperties = null,
70+
?bool $nullable = null,
71+
?bool $deprecated = null,
72+
?array $allOf = null,
73+
?array $anyOf = null,
74+
?array $oneOf = null,
75+
null|AdditionalProperties|bool $additionalProperties = null,
7676
// annotation
77-
array $x = null,
78-
array $attachables = null,
77+
?array $x = null,
78+
?array $attachables = null,
7979
) {
8080
parent::__construct(
8181
$property,

src/Schema/RequestBody.php

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,15 @@ class RequestBody extends \OpenApi\Attributes\RequestBody
1515
* @param null|Attachable[] $attachables
1616
*/
1717
public function __construct(
18-
object|string $ref = null,
19-
string $request = null,
20-
string $description = null,
21-
bool $required = null,
18+
null|object|string $ref = null,
19+
?string $request = null,
20+
?string $description = null,
21+
?bool $required = null,
2222
// annotation
23-
array $x = null,
24-
array $attachables = null,
23+
?array $x = null,
24+
?array $attachables = null,
2525
) {
26-
$content = new class($ref) extends JsonContent
27-
{
26+
$content = new class($ref) extends JsonContent {
2827
public function __construct(string $ref)
2928
{
3029
parent::__construct(isResponse: false, ref: $ref);

src/Schema/Schema.php

Lines changed: 35 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -38,47 +38,47 @@ class Schema extends \OpenApi\Attributes\Schema
3838
*/
3939
public function __construct(
4040
// schema
41-
object|string $ref = null,
42-
string $schema = null,
43-
string $title = null,
44-
string $description = null,
45-
int $maxProperties = null,
46-
int $minProperties = null,
47-
array $required = null,
48-
array $properties = null,
49-
array|string $type = null,
50-
string $format = null,
51-
Items $items = null,
52-
string $collectionFormat = null,
41+
null|object|string $ref = null,
42+
?string $schema = null,
43+
?string $title = null,
44+
?string $description = null,
45+
?int $maxProperties = null,
46+
?int $minProperties = null,
47+
?array $required = null,
48+
?array $properties = null,
49+
null|array|string $type = null,
50+
?string $format = null,
51+
?Items $items = null,
52+
?string $collectionFormat = null,
5353
mixed $default = Generator::UNDEFINED,
5454
$maximum = null,
55-
bool|float|int $exclusiveMaximum = null,
55+
null|bool|float|int $exclusiveMaximum = null,
5656
$minimum = null,
57-
bool|float|int $exclusiveMinimum = null,
58-
int $maxLength = null,
59-
int $minLength = null,
60-
int $maxItems = null,
61-
int $minItems = null,
62-
bool $uniqueItems = null,
63-
string $pattern = null,
64-
array|string $enum = null,
65-
Discriminator $discriminator = null,
66-
bool $readOnly = null,
67-
bool $writeOnly = null,
68-
Xml $xml = null,
69-
ExternalDocumentation $externalDocs = null,
57+
null|bool|float|int $exclusiveMinimum = null,
58+
?int $maxLength = null,
59+
?int $minLength = null,
60+
?int $maxItems = null,
61+
?int $minItems = null,
62+
?bool $uniqueItems = null,
63+
?string $pattern = null,
64+
null|array|string $enum = null,
65+
?Discriminator $discriminator = null,
66+
?bool $readOnly = null,
67+
?bool $writeOnly = null,
68+
?Xml $xml = null,
69+
?ExternalDocumentation $externalDocs = null,
7070
mixed $example = Generator::UNDEFINED,
71-
array $examples = null,
72-
bool $nullable = null,
73-
bool $deprecated = null,
74-
array $allOf = null,
75-
array $anyOf = null,
76-
array $oneOf = null,
77-
AdditionalProperties|bool $additionalProperties = null,
71+
?array $examples = null,
72+
?bool $nullable = null,
73+
?bool $deprecated = null,
74+
?array $allOf = null,
75+
?array $anyOf = null,
76+
?array $oneOf = null,
77+
null|AdditionalProperties|bool $additionalProperties = null,
7878
mixed $const = Generator::UNDEFINED,
7979
// annotation
80-
array $x = null,
81-
array $attachables = null
80+
?array $x = null,
81+
?array $attachables = null
8282
) {
8383
parent::__construct(
8484
ref: $ref,

src/Schema/SuccessJsonResponse.php

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,15 @@
1212
class SuccessJsonResponse extends Response
1313
{
1414
public function __construct(
15-
object|string $ref = null,
16-
array $headers = null,
17-
array $links = null,
18-
array $x = null,
19-
array $attachables = null,
15+
null|object|string $ref = null,
16+
?array $headers = null,
17+
?array $links = null,
18+
?array $x = null,
19+
?array $attachables = null,
2020
string $description = 'success',
2121
null|int|string $response = 200,
2222
) {
23-
$content = new class($ref) extends JsonContent
24-
{
23+
$content = new class($ref) extends JsonContent {
2524
public function __construct(object|string $ref)
2625
{
2726
if ($ref instanceof CustomPropertyInterface) {

src/Swagger.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,6 @@ public static function gen(): void
2121
$path = $config['output_dir'];
2222
@mkdir($path, 0755, true);
2323
$ext = pathinfo($config['filename'], PATHINFO_EXTENSION);
24-
file_put_contents(rtrim($path, '/') . '/' . $config['filename'], 'json' == $ext ? $openapi->toJson() : $openapi->toYaml());
24+
file_put_contents(rtrim($path, '/') . '/' . $config['filename'], $ext == 'json' ? $openapi->toJson() : $openapi->toYaml());
2525
}
2626
}

src/Util/RouteGetter.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class RouteGetter
1616
* @return null|class-string
1717
* @throws Exception
1818
*/
19-
public static function getRouteByContent(?Context $context, MethodEnum $requestMethod = null): ?string
19+
public static function getRouteByContent(?Context $context, ?MethodEnum $requestMethod = null): ?string
2020
{
2121
if (! $context) {
2222
return null;

0 commit comments

Comments
 (0)