Skip to content

Commit 8991da1

Browse files
committed
Merge pull request #1207: Apply Spiral Code Style
1 parent 4978235 commit 8991da1

33 files changed

+361
-451
lines changed

composer.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,9 @@
3434
],
3535
"require": {
3636
"php": ">=8.1",
37-
"spiral/core": "^3.14.10",
38-
"spiral/logger": "^3.14.10",
39-
"spiral/tokenizer": "^3.14.10",
37+
"spiral/core": "^3.15",
38+
"spiral/logger": "^3.15",
39+
"spiral/tokenizer": "^3.15",
4040
"symfony/translation": "^5.1 || ^6.0 || ^7.0",
4141
"psr/event-dispatcher": "^1.0"
4242
},

src/Catalogue.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,8 @@ final class Catalogue implements CatalogueInterface
1818
*/
1919
public function __construct(
2020
private readonly string $locale,
21-
private array $data = []
22-
) {
23-
}
21+
private array $data = [],
22+
) {}
2423

2524
public function getLocale(): string
2625
{

src/Catalogue/CatalogueLoader.php

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,8 @@ final class CatalogueLoader implements LoaderInterface
1515
use LoggerTrait;
1616

1717
public function __construct(
18-
private readonly TranslatorConfig $config
19-
) {
20-
}
18+
private readonly TranslatorConfig $config,
19+
) {}
2120

2221
public function hasLocale(string $locale): bool
2322
{
@@ -69,9 +68,9 @@ public function loadCatalogue(string $locale): CatalogueInterface
6968
$this->getLogger()->info(
7069
\sprintf(
7170
"found locale domain file '%s'",
72-
$file->getFilename()
71+
$file->getFilename(),
7372
),
74-
['file' => $file->getFilename()]
73+
['file' => $file->getFilename()],
7574
);
7675

7776
//Per application agreement domain name must present in filename
@@ -81,20 +80,20 @@ public function loadCatalogue(string $locale): CatalogueInterface
8180
$this->getLogger()->warning(
8281
\sprintf(
8382
"unable to load domain file '%s', no loader found",
84-
$file->getFilename()
83+
$file->getFilename(),
8584
),
86-
['file' => $file->getFilename()]
85+
['file' => $file->getFilename()],
8786
);
8887

8988
continue;
9089
}
9190

9291
$catalogue->mergeFrom(
9392
$this->config->getLoader($file->getExtension())->load(
94-
(string)$file,
93+
(string) $file,
9594
$locale,
96-
$domain
97-
)
95+
$domain,
96+
),
9897
);
9998
}
10099

src/Catalogue/CatalogueManager.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ final class CatalogueManager implements CatalogueManagerInterface
2323

2424
public function __construct(
2525
private readonly LoaderInterface $loader,
26-
?CacheInterface $cache = null
26+
?CacheInterface $cache = null,
2727
) {
2828
$this->cache = $cache ?? new NullCache();
2929
}
@@ -34,7 +34,7 @@ public function getLocales(): array
3434
return $this->locales;
3535
}
3636

37-
$this->locales = (array)$this->cache->getLocales();
37+
$this->locales = (array) $this->cache->getLocales();
3838
if ($this->locales === []) {
3939
$this->locales = $this->loader->getLocales();
4040
$this->cache->setLocales($this->locales);
@@ -49,7 +49,7 @@ public function load(string $locale): CatalogueInterface
4949
return $this->catalogues[$locale];
5050
}
5151

52-
$data = (array)$this->cache->loadLocale($locale);
52+
$data = (array) $this->cache->loadLocale($locale);
5353
if (!empty($data)) {
5454
$this->catalogues[$locale] = new Catalogue($locale, $data);
5555
} else {

src/Catalogue/NullCache.php

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

77
final class NullCache implements CacheInterface
88
{
9-
public function setLocales(?array $locales): void
10-
{
11-
}
9+
public function setLocales(?array $locales): void {}
1210

1311
public function getLocales(): ?array
1412
{
1513
return null;
1614
}
1715

18-
public function saveLocale(string $locale, ?array $data): void
19-
{
20-
}
16+
public function saveLocale(string $locale, ?array $data): void {}
2117

2218
public function loadLocale(string $locale): ?array
2319
{

src/Event/LocaleUpdated.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,5 @@ final class LocaleUpdated
88
{
99
public function __construct(
1010
public readonly string $locale,
11-
) {
12-
}
11+
) {}
1312
}

src/Exception/CatalogueException.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,4 @@
77
/**
88
* When catalogue requested for unknown string.
99
*/
10-
class CatalogueException extends TranslatorException
11-
{
12-
}
10+
class CatalogueException extends TranslatorException {}

src/Exception/LocaleException.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ class LocaleException extends TranslatorException
1212
public function __construct(
1313
protected string $locale,
1414
int $code = 0,
15-
?\Throwable $previous = null
15+
?\Throwable $previous = null,
1616
) {
1717
parent::__construct(\sprintf('Undefined locale \'%s\'', $locale), $code, $previous);
1818
}

src/Exception/PluralizationException.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,4 @@
77
/**
88
* When locale contain invalid pluralization string.
99
*/
10-
class PluralizationException extends LocaleException
11-
{
12-
}
10+
class PluralizationException extends LocaleException {}

src/Exception/SourceException.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,4 @@
77
/**
88
* Source related exceptions.
99
*/
10-
class SourceException extends TranslatorException
11-
{
12-
}
10+
class SourceException extends TranslatorException {}

0 commit comments

Comments
 (0)