Skip to content

Commit aa58027

Browse files
committed
phpcs
1 parent 8f375ec commit aa58027

File tree

3 files changed

+26
-19
lines changed

3 files changed

+26
-19
lines changed

phpcs.xml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,18 @@
44
<file>src</file>
55
<file>tests</file>
66

7-
<exclude-pattern type="relative-root">tests/*</exclude-pattern>
87
<rule ref="PSR2"/>
98
<rule ref="Generic.Files.LineLength">
109
<properties>
1110
<property name="lineLimit" value="210"/>
1211
<property name="absoluteLineLimit" value="0"/>
1312
</properties>
1413
</rule>
14+
15+
<!-- Align corresponding assignment statement tokens -->
16+
<rule ref="Generic.Formatting.MultipleStatementAlignment">
17+
<properties>
18+
<property name="error" value="true"/>
19+
</properties>
20+
</rule>
1521
</ruleset>

src/LaravelRequestDocsToOpenApi.php

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,14 @@ private function docsToOpenApi(array $docs): void
3535
$this->openApi['paths'] = [];
3636
foreach ($docs as $doc) {
3737
$requestHasFile = false;
38-
$httpMethod = strtolower($doc->getHttpMethod());
39-
$isGet = $httpMethod == 'get';
40-
$isPost = $httpMethod == 'post';
41-
$isPut = $httpMethod == 'put';
42-
$isDelete = $httpMethod == 'delete';
38+
$httpMethod = strtolower($doc->getHttpMethod());
39+
$isGet = $httpMethod == 'get';
40+
$isPost = $httpMethod == 'post';
41+
$isPut = $httpMethod == 'put';
42+
$isDelete = $httpMethod == 'delete';
4343

4444
$this->openApi['paths'][$doc->getUri()][$httpMethod]['description'] = $doc->getDocBlock();
45-
$this->openApi['paths'][$doc->getUri()][$httpMethod]['parameters'] = [];
45+
$this->openApi['paths'][$doc->getUri()][$httpMethod]['parameters'] = [];
4646

4747
$this->openApi['paths'][$doc->getUri()][$httpMethod]['responses'] = config('request-docs.open_api.responses', []);
4848

@@ -70,7 +70,7 @@ private function docsToOpenApi(array $docs): void
7070
foreach ($doc->getRules() as $attribute => $rules) {
7171
foreach ($rules as $rule) {
7272
if ($isGet) {
73-
$parameter = $this->makeQueryParameterItem($attribute, $rule);
73+
$parameter = $this->makeQueryParameterItem($attribute, $rule);
7474
$this->openApi['paths'][$doc->getUri()][$httpMethod]['parameters'][] = $parameter;
7575
}
7676
if ($isPost || $isPut || $isDelete) {
@@ -108,7 +108,7 @@ protected function makeRequestBodyItem(string $contentType): array
108108
'content' => [
109109
$contentType => [
110110
'schema' => [
111-
'type' => 'object',
111+
'type' => 'object',
112112
'properties' => [],
113113
],
114114
],
@@ -122,9 +122,9 @@ protected function makeRequestBodyContentPropertyItem(string $rule): array
122122
$type = $this->getAttributeType($rule);
123123

124124
return [
125-
'type' => $type,
125+
'type' => $type,
126126
'nullable' => str_contains($rule, 'nullable'),
127-
'format' => $this->attributeIsFile($rule) ? 'binary' : $type,
127+
'format' => $this->attributeIsFile($rule) ? 'binary' : $type,
128128
];
129129
}
130130

tests/Controllers/LaravelRequestDocsControllerTest.php

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,15 @@ public function testAbleFetchAllMethods()
2727

2828
$docs = collect($response->json());
2929

30-
$this->assertSame([
31-
Request::METHOD_DELETE,
32-
Request::METHOD_GET,
33-
Request::METHOD_HEAD,
34-
Request::METHOD_PATCH,
35-
Request::METHOD_POST,
36-
Request::METHOD_PUT,
37-
],
30+
$this->assertSame(
31+
[
32+
Request::METHOD_DELETE,
33+
Request::METHOD_GET,
34+
Request::METHOD_HEAD,
35+
Request::METHOD_PATCH,
36+
Request::METHOD_POST,
37+
Request::METHOD_PUT,
38+
],
3839
$docs->pluck('http_method')
3940
->flatten()
4041
->unique()

0 commit comments

Comments
 (0)