Skip to content

Commit 8e4556a

Browse files
committed
Fix styling
1 parent 5df8fd5 commit 8e4556a

37 files changed

+104
-77
lines changed

.github/workflows/test.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ jobs:
5454
run: phpstan analyse --level=4 --error-format=checkstyle src/ | cs2pr
5555

5656
- name: PHPCS
57-
run: phpcs --standard=PSR12 --ignore=\*/Tests/\*,\*Minifier.php --exclude=PSR1.Methods.CamelCapsMethodName,Generic.Files.LineLength src/ | cs2pr
57+
run: phpcs --standard=tests/phpcs.xml --ignore=\*Minifier.php src/ | cs2pr
5858

5959
- name: Upload coverage result
6060
uses: actions/upload-artifact@v1

composer.lock

+20-31
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/PHPDraft/Core/Autoloader.php

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
23
declare(strict_types=1);
34

45
/**

src/PHPDraft/In/ApibFileParser.php

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
<?php
2-
declare(strict_types=1);
1+
<?php declare(strict_types=1);
32

43
/**
54
* This file contains the ApibFileParser.

src/PHPDraft/In/Tests/ApibFileParserTest.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -93,10 +93,10 @@ public function testParseBasic(): void
9393
$full_property->setAccessible(true);
9494

9595
$text = "FORMAT: 1A\nHOST: https://owner-api.teslamotors.com\n";
96-
$text .="EXTRA_HOSTS: https://test.owner-api.teslamotors.com\nSOMETHING: INFO\n\n";
96+
$text .= "EXTRA_HOSTS: https://test.owner-api.teslamotors.com\nSOMETHING: INFO\n\n";
9797
$text .= "# Tesla Model S JSON API\nThis is unofficial documentation of the";
98-
$text .=" Tesla Model S JSON API used by the iOS and Android apps. It features";
99-
$text .=" functionality to monitor and control the Model S remotely.\n\nTEST";
98+
$text .= " Tesla Model S JSON API used by the iOS and Android apps. It features";
99+
$text .= " functionality to monitor and control the Model S remotely.\n\nTEST";
100100
$text .= "\n\n# Hello\nThis is a test.\nhello";
101101

102102
$this->assertSame($text, $full_property->getValue($this->class));

src/PHPDraft/Model/Category.php

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
23
declare(strict_types=1);
34

45
/**

src/PHPDraft/Model/Comparable.php

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
23
declare(strict_types=1);
34

45
/**

src/PHPDraft/Model/Elements/ArrayStructureElement.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
23
declare(strict_types=1);
34

45
/**
@@ -42,7 +43,7 @@ public function parse(?object $object, array &$dependencies): StructureElement
4243
}
4344

4445
$key = $sub_item->element ?? 'any';
45-
$value = $sub_item->content ?? NULL;
46+
$value = $sub_item->content ?? null;
4647
$this->value[] = [$value => $key];
4748
}
4849

src/PHPDraft/Model/Elements/BasicStructureElement.php

+6-5
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
23
declare(strict_types=1);
34

45
/**
@@ -112,7 +113,7 @@ protected function parse_common(object $object, array &$dependencies): void
112113
$this->description = htmlentities($object->meta->description);
113114
}
114115
if ($this->description !== null) {
115-
$encoded = htmlentities($this->description, ENT_COMPAT, null, FALSE);
116+
$encoded = htmlentities($this->description, ENT_COMPAT, null, false);
116117
$this->description = MarkdownExtra::defaultTransform($encoded);
117118
}
118119

@@ -133,7 +134,7 @@ protected function parse_common(object $object, array &$dependencies): void
133134
$this->status = join(', ', $object->attributes->typeAttributes);
134135
}
135136

136-
if (!in_array($this->type, self::DEFAULTS) && $this->type !== NULL) {
137+
if (!in_array($this->type, self::DEFAULTS) && $this->type !== null) {
137138
$dependencies[] = $this->type;
138139
}
139140
}
@@ -162,18 +163,18 @@ protected function get_element_as_html($element): string
162163
*
163164
* @return string
164165
*/
165-
public function string_value($flat = FALSE)
166+
public function string_value($flat = false)
166167
{
167168
if (is_array($this->value)) {
168169
$value_key = rand(0, count($this->value));
169-
if (is_subclass_of($this->value[$value_key], StructureElement::class) && $flat === FALSE) {
170+
if (is_subclass_of($this->value[$value_key], StructureElement::class) && $flat === false) {
170171
return $this->value[$value_key]->string_value($flat);
171172
}
172173

173174
return $this->value[$value_key];
174175
}
175176

176-
if (is_subclass_of($this->value, BasicStructureElement::class) && $flat === TRUE) {
177+
if (is_subclass_of($this->value, BasicStructureElement::class) && $flat === true) {
177178
return is_array($this->value->value) ? array_keys($this->value->value)[0] : $this->value->value;
178179
}
179180
return $this->value;

src/PHPDraft/Model/Elements/EnumStructureElement.php

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
23
declare(strict_types=1);
34

45
/**
@@ -27,8 +28,8 @@ public function parse(?object $object, array &$dependencies): StructureElement
2728

2829
$this->parse_common($object, $dependencies);
2930

30-
$this->key = $this->key ?? $object->content->content ?? NULL;
31-
$this->type = $this->type ?? $object->content->element ?? NULL;
31+
$this->key = $this->key ?? $object->content->content ?? null;
32+
$this->type = $this->type ?? $object->content->element ?? null;
3233

3334
if (!isset($object->content) && !isset($object->attributes)) {
3435
$this->value = $this->key;

src/PHPDraft/Model/Elements/ObjectStructureElement.php

+11-5
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
23
declare(strict_types=1);
34

45
/**
@@ -23,7 +24,10 @@ class ObjectStructureElement extends BasicStructureElement
2324
* Unset object function.
2425
* @internal Only for tests
2526
*/
26-
public function __clearForTest(){$this->object = NULL;}
27+
public function __clearForTest()
28+
{
29+
$this->object = null;
30+
}
2731

2832
/**
2933
* Parse a JSON object to a data structure.
@@ -58,7 +62,9 @@ public function parse(?object $object, array &$dependencies): StructureElement
5862
$this->value = $object->content->value->content;
5963
} elseif (isset($object->content->value->attributes->samples)) {
6064
$this->value = array_reduce($object->content->value->attributes->samples->content, function ($carry, $item) {
61-
if ($carry === NULL) {return "$item->content ($item->element)"; }
65+
if ($carry === null) {
66+
return "$item->content ($item->element)";
67+
}
6268
return "$carry | $item->content ($item->element)";
6369
});
6470
} else {
@@ -106,7 +112,7 @@ protected function new_instance(): StructureElement
106112
* Parse content formed as an array.
107113
*
108114
* @param object $object APIB content
109-
* @param array $dependencies Object dependencies
115+
* @param array $dependencies Object dependencies
110116
*
111117
* @return void
112118
*/
@@ -130,7 +136,7 @@ protected function parse_array_content(object $object, array &$dependencies): vo
130136
*/
131137
public function __toString(): string
132138
{
133-
$options = array_merge(self::DEFAULTS,['member', 'select', 'option', 'ref', 'T', 'hrefVariables']);
139+
$options = array_merge(self::DEFAULTS, ['member', 'select', 'option', 'ref', 'T', 'hrefVariables']);
134140
if (!empty($this->element) && !in_array($this->element, $options)) {
135141
$this->description = '<p>Inherits from <a href="#object-' . strtolower($this->element) . '">' . $this->element . '</a></p>' . $this->description;
136142
}
@@ -195,7 +201,7 @@ public function __toString(): string
195201
*/
196202
protected function construct_string_return(string $value): string
197203
{
198-
if ($this->type === NULL) {
204+
if ($this->type === null) {
199205
return $value;
200206
}
201207

src/PHPDraft/Model/Elements/RequestBodyElement.php

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
23
declare(strict_types=1);
34

45
/**

src/PHPDraft/Model/Elements/StructureElement.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
23
declare(strict_types=1);
34

45
/**
@@ -45,5 +46,5 @@ public function __toString(): string;
4546
*
4647
* @return string
4748
*/
48-
public function string_value($flat = FALSE);
49+
public function string_value($flat = false);
4950
}

src/PHPDraft/Model/Elements/Tests/ArrayStructureElementTest.php

+8-8
Original file line numberDiff line numberDiff line change
@@ -57,23 +57,23 @@ public function parseObjectProvider(): array
5757
{
5858
$return = [];
5959
$base1 = new ArrayStructureElement();
60-
$base1->key = NULL;
60+
$base1->key = null;
6161
$base1->value = [['Swift' => 'string'], ['Objective-C' => 'string']];
62-
$base1->status = NULL;
62+
$base1->status = null;
6363
$base1->element = 'array';
64-
$base1->type = NULL;
64+
$base1->type = null;
6565
$base1->is_variable = false;
66-
$base1->description = NULL;
66+
$base1->description = null;
6767
$base1->deps = [];
6868

6969
$base2 = new ArrayStructureElement();
70-
$base2->key = NULL;
70+
$base2->key = null;
7171
$base2->value = [['item' => 'string'], ['another item' => 'string']];
72-
$base2->status = NULL;
72+
$base2->status = null;
7373
$base2->element = 'array';
7474
$base2->type = 'Some simple array';
7575
$base2->is_variable = false;
76-
$base2->description = NULL;
76+
$base2->description = null;
7777
$base2->deps = ['Some simple array'];
7878

7979
$base3 = new ArrayStructureElement();
@@ -177,7 +177,7 @@ public function testToStringWithArray(): void
177177
*/
178178
public function testToStringWithComplexArray(): void
179179
{
180-
$this->class->value = [['type'=>'Bike'], ['stuff'=>'car']];
180+
$this->class->value = [['type' => 'Bike'], ['stuff' => 'car']];
181181
$return = $this->class->__toString();
182182
$this->assertSame('<ul class="list-group mdl-list"><li class="list-group-item mdl-list__item"><a class="code" title="Bike" href="#object-bike">Bike</a> - <span class="example-value pull-right">type</span></li><li class="list-group-item mdl-list__item"><a class="code" title="car" href="#object-car">car</a> - <span class="example-value pull-right">stuff</span></li></ul>', $return);
183183
}

src/PHPDraft/Model/Elements/Tests/BasicStructureElementTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ public function testParseCommonDeps(): void
9595
$answer = new ObjectStructureElement();
9696
$answer->key = 'key';
9797
$answer->type = 'cat';
98-
$answer->description = NULL;
98+
$answer->description = null;
9999

100100
$method = $this->reflection->getMethod('parse_common');
101101
$method->setAccessible(true);

0 commit comments

Comments
 (0)