Skip to content

Commit f1fb9ab

Browse files
committed
PHP CS fixer configuration, adding some params for removing extra blank lines and spaces
1 parent 34540b4 commit f1fb9ab

36 files changed

+37
-152
lines changed

.php-cs-fixer.dist.php

Lines changed: 34 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,41 @@
33
$finder = (new PhpCsFixer\Finder())
44
->in(__DIR__ . "/src")
55
;
6+
$rules = [
7+
'@PER-CS2.0' => true,
8+
'@PHP83Migration' => true,
9+
'class_attributes_separation' => [
10+
'elements' => [
11+
'const' => 'one',
12+
'method' => 'one',
13+
'property' => 'one',
14+
'trait_import' => 'none',
15+
],
16+
],
17+
'no_extra_blank_lines' => [
18+
'tokens' => [
19+
'extra',
20+
'throw',
21+
'use',
22+
],
23+
],
24+
'no_blank_lines_after_class_opening' => true,
25+
'no_blank_lines_after_phpdoc' => true,
26+
'no_closing_tag' => true,
27+
'no_empty_phpdoc' => true,
28+
'no_empty_statement' => true,
629

30+
31+
//'strict_param' => true,
32+
'array_indentation' => true,
33+
'array_syntax' => ['syntax' => 'short'],
34+
'binary_operator_spaces' => [
35+
'default' => 'single_space',
36+
'operators' => ['=>' => null],
37+
],
38+
'whitespace_after_comma_in_array' => true,
39+
];
740
return (new PhpCsFixer\Config())
8-
->setRules([
9-
'@PER-CS2.0' => true,
10-
'@PHP83Migration' => true,
11-
//'strict_param' => true,
12-
'array_syntax' => ['syntax' => 'short'],
13-
])
41+
->setRules($rules)
1442
->setFinder($finder)
1543
;

src/Data/AssetData.php

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

55
namespace Storyblok\ManagementApi\Data;
66

7-
use Storyblok\ManagementApi\StoryblokUtils;
8-
97
class AssetData extends StoryblokData
108
{
119
/*
@@ -25,7 +23,6 @@ public function id(): string
2523
return $this->getString('id', "");
2624
}
2725

28-
2926
public function filenameCDN(): string
3027
{
3128
return str_replace(
@@ -50,7 +47,6 @@ public function contentLength(): int|null
5047
return $this->getInt('content_length');
5148
}
5249

53-
5450
public function createdAt(): null|string
5551
{
5652
return $this->getFormattedDateTime('created_at', "", format: "Y-m-d");
@@ -60,5 +56,4 @@ public function updatedAt(): null|string
6056
{
6157
return $this->getFormattedDateTime('updated_at', "", format: "Y-m-d");
6258
}
63-
6459
}

src/Data/AssetsData.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,11 @@ public static function make(array $data = []): self
2020
return new self($data);
2121
}
2222

23-
2423
/**
2524
* @param array<string, array<mixed>> $data
2625
*/
2726
public static function makeFromResponse(array $data): self
2827
{
2928
return new self($data["assets"] ?? []);
3029
}
31-
3230
}

src/Data/IterableDataTrait.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,5 +84,4 @@ public function forEach(callable $callback): self
8484
return new StoryblokData($result);
8585

8686
}
87-
8887
}

src/Data/SpaceData.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ public function createdAt(): null|string
4848
return $this->getFormattedDateTime('created_at', "", format: "Y-m-d");
4949
}
5050

51-
5251
public function planDescription(): null|string
5352
{
5453
return StoryblokUtils::getPlanDescription($this->getString('plan_level'));

src/Data/SpacesData.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,8 @@ public static function make(array $data = []): self
1818
return new self($data);
1919
}
2020

21-
22-
23-
2421
public function howManySpaces(): int
2522
{
2623
return $this->count();
2724
}
28-
2925
}

src/Data/StoriesData.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ public static function make(array $data = []): self
2020
return new self($data);
2121
}
2222

23-
2423
/**
2524
* @param array<string, array<mixed>> $data
2625
*/
@@ -29,10 +28,8 @@ public static function makeFromResponse(array $data = []): self
2928
return new self($data["stories"] ?? []);
3029
}
3130

32-
3331
public function howManyStories(): int
3432
{
3533
return $this->count();
3634
}
37-
3835
}

src/Data/StoryData.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,6 @@ public function updatedAt(): null|string
6767
return $this->getFormattedDateTime('updated_at', "", format: "Y-m-d");
6868
}
6969

70-
7170
public function setContentType(string $componentName): self
7271
{
7372
$this->defaultContentType = $componentName;

src/Data/StoryblokData.php

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,11 @@ public function toArray(): array
4848
return $this->data;
4949
}
5050

51-
5251
public function toJson(): string|false
5352
{
5453
return json_encode($this->data, JSON_PRETTY_PRINT);
5554
}
5655

57-
5856
/**
5957
* Retrieves a value from the data by key. Supports dot notation for nested keys.
6058
*
@@ -93,7 +91,6 @@ public function get(mixed $key, mixed $defaultValue = null, string $charNestedKe
9391

9492
}
9593

96-
9794
return $this->returnData($this->data[$key], $raw) ?? $defaultValue;
9895

9996
}
@@ -156,8 +153,7 @@ public function getFormattedDateTime(
156153
string $charNestedKey = ".",
157154
string $format = "Y-m-d H:i:s",
158155
): string|null {
159-
$value = $this->getString($key, "", $charNestedKey);
160-
156+
$value = $this->getString($key, "", $charNestedKey);
161157

162158
if ($value === "") {
163159
return "";
@@ -172,7 +168,6 @@ public function getFormattedDateTime(
172168
return $date->format($format);
173169
}
174170

175-
176171
/**
177172
* Sets a value for a specific key in the data.
178173
* Supports dot notation for nested keys.
@@ -213,7 +208,6 @@ public function set(int|string $key, mixed $value, string $charNestedKey = "."):
213208
return $this;
214209
}
215210

216-
217211
/**
218212
* Returns data in the desired format.
219213
* Can be raw or converted to StoryblokData.
@@ -240,8 +234,6 @@ protected function returnData(mixed $value, bool $raw = false): mixed
240234
return new StoryblokData($value);
241235
}
242236

243-
244-
245237
if ($value instanceof StoryblokData) {
246238
return $value;
247239
}
@@ -250,7 +242,6 @@ protected function returnData(mixed $value, bool $raw = false): mixed
250242

251243
}
252244

253-
254245
/**
255246
* Returns the class name of the current data class.
256247
* This is useful when you extend the StoryblokData
@@ -263,7 +254,6 @@ public function getDataClass(): string
263254
return self::class;
264255
}
265256

266-
267257
/**
268258
* @deprecated
269259
* Retrieves a nested value from the data and casts it into StoryblokData if applicable.

src/Data/TagData.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,4 @@ public function tagOnStories(): int|null
3434
{
3535
return $this->getInt('tag_on_stories', 0);
3636
}
37-
38-
3937
}

0 commit comments

Comments
 (0)