Skip to content

Commit 830cc04

Browse files
authored
Use a different image for PHP CS Fixer to get latest and upgrade config (#471)
* Use a different image for PHP CS Fixer to get latest and upgrade config * Add new cache file from PHP CS Fixer to gitignore * Brake styles * Add --dry-run and --diff * Revert "Brake styles" This reverts commit 5285d20. * Fix all code styles with the new version of PHP CS Fixer * Fix missing: DomXpath -> DOMXPath * Fix some code styles after master rebase
1 parent 255a9f6 commit 830cc04

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+152
-174
lines changed

.github/workflows/static.yml

Lines changed: 6 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -38,35 +38,13 @@ jobs:
3838

3939
php-cs-fixer:
4040
name: PHP-CS-Fixer
41-
runs-on: Ubuntu-20.04
42-
41+
runs-on: ubuntu-latest
4342
steps:
44-
- name: Checkout code
45-
uses: actions/checkout@v2
46-
47-
- name: Cache PhpCsFixer
48-
uses: actions/cache@v2
49-
with:
50-
path: .github/.cache/php-cs-fixer/
51-
key: php-cs-fixer-${{ github.sha }}
52-
restore-keys: php-cs-fixer-
53-
54-
- name: Setup PHP
55-
uses: shivammathur/setup-php@v2
56-
with:
57-
php-version: '7.4'
58-
coverage: none
59-
60-
- name: Download dependencies
61-
uses: ramsey/composer-install@v1
62-
with:
63-
composer-options: --no-interaction --prefer-dist --optimize-autoloader
64-
65-
- name: Download PHP CS Fixer
66-
run: composer bin php-cs-fixer update --no-interaction --no-progress
67-
68-
- name: Execute PHP CS Fixer
69-
run: vendor/bin/php-cs-fixer fix --diff-format udiff --dry-run
43+
- uses: actions/checkout@v2
44+
- name: PHP-CS-Fixer
45+
uses: docker://oskarstark/php-cs-fixer-ga
46+
with:
47+
args: --diff --dry-run
7048

7149
psalm:
7250
name: Psalm

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,5 @@
55
/phpunit.xml
66
/vendor/
77
.php_cs.cache
8+
.php-cs-fixer.cache
89
.phpunit.result.cache

.php-cs-fixer.dist.php

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?php
2+
3+
$finder = PhpCsFixer\Finder::create()
4+
->exclude(__DIR__.'/vendor')
5+
->name('*.php')
6+
->in(__DIR__)
7+
;
8+
9+
$config = new PhpCsFixer\Config();
10+
return $config->setRules([
11+
'@Symfony' => true,
12+
'@Symfony:risky' => true,
13+
'array_syntax' => ['syntax' => 'short'],
14+
'native_function_invocation' => true,
15+
'ordered_imports' => true,
16+
'declare_strict_types' => false,
17+
'single_import_per_statement' => false,
18+
])
19+
->setRiskyAllowed(true)
20+
->setFinder($finder)
21+
;

.php_cs

Lines changed: 0 additions & 22 deletions
This file was deleted.

Catalogue/CatalogueFetcher.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public function getCatalogues(Configuration $config, array $locales = []): array
4646
foreach ($locales as $locale) {
4747
$currentCatalogue = new MessageCatalogue($locale);
4848
foreach ($dirs as $path) {
49-
if (\is_dir($path)) {
49+
if (is_dir($path)) {
5050
$this->reader->read($path, $currentCatalogue);
5151
}
5252
}

Catalogue/CatalogueManager.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public function load(array $catalogues): void
4242
public function getDomains(): array
4343
{
4444
/** @var MessageCatalogueInterface $c */
45-
$c = \reset($this->catalogues);
45+
$c = reset($this->catalogues);
4646

4747
return $c->getDomains();
4848
}
@@ -107,7 +107,7 @@ public function findMessages(array $config = []): array
107107
}
108108
}
109109

110-
$messages = \array_filter($messages, static function (CatalogueMessage $m) use ($isNew, $isObsolete, $isApproved, $isEmpty) {
110+
$messages = array_filter($messages, static function (CatalogueMessage $m) use ($isNew, $isObsolete, $isApproved, $isEmpty) {
111111
if (null !== $isNew && $m->isNew() !== $isNew) {
112112
return false;
113113
}

Catalogue/Operation/ReplaceOperation.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ protected function processDomain($domain): void
3737
'new' => [],
3838
'obsolete' => [],
3939
];
40-
if (\defined(\sprintf('%s::INTL_DOMAIN_SUFFIX', MessageCatalogueInterface::class))) {
40+
if (\defined(sprintf('%s::INTL_DOMAIN_SUFFIX', MessageCatalogueInterface::class))) {
4141
$intlDomain = $domain.MessageCatalogueInterface::INTL_DOMAIN_SUFFIX;
4242
} else {
4343
$intlDomain = $domain;
@@ -160,6 +160,6 @@ public function isArrayAssociative(array $arr): bool
160160
return false;
161161
}
162162

163-
return \array_keys($arr) !== \range(0, \count($arr) - 1);
163+
return array_keys($arr) !== range(0, \count($arr) - 1);
164164
}
165165
}

Command/BundleTrait.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,11 @@ trait BundleTrait
2020
private function configureBundleDirs(InputInterface $input, Configuration $config): void
2121
{
2222
if ($bundleName = $input->getOption('bundle')) {
23-
if (0 === \strpos($bundleName, '@')) {
24-
if (false === $pos = \strpos($bundleName, '/')) {
25-
$bundleName = \substr($bundleName, 1);
23+
if (0 === strpos($bundleName, '@')) {
24+
if (false === $pos = strpos($bundleName, '/')) {
25+
$bundleName = substr($bundleName, 1);
2626
} else {
27-
$bundleName = \substr($bundleName, 1, $pos - 2);
27+
$bundleName = substr($bundleName, 1, $pos - 2);
2828
}
2929
}
3030

Command/CheckMissingCommand.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
9191
$io = new SymfonyStyle($input, $output);
9292

9393
if ($newMessages > 0) {
94-
$io->error(\sprintf('%d new message(s) have been found, run bin/console translation:extract', $newMessages));
94+
$io->error(sprintf('%d new message(s) have been found, run bin/console translation:extract', $newMessages));
9595

9696
return 1;
9797
}
@@ -100,7 +100,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
100100

101101
if ($emptyTranslations > 0) {
102102
$io->error(
103-
\sprintf('%d messages have empty translations, please provide translations for them', $emptyTranslations)
103+
sprintf('%d messages have empty translations, please provide translations for them', $emptyTranslations)
104104
);
105105

106106
return 1;
@@ -132,7 +132,7 @@ private function countEmptyTranslations(MessageCatalogueInterface $catalogue): i
132132
$total = 0;
133133

134134
foreach ($catalogue->getDomains() as $domain) {
135-
$emptyTranslations = \array_filter(
135+
$emptyTranslations = array_filter(
136136
$catalogue->all($domain),
137137
function (string $message = null): bool {
138138
return null === $message || '' === $message;

Command/DeleteEmptyCommand.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
9696

9797
if ($input->isInteractive()) {
9898
$helper = $this->getHelper('question');
99-
$question = new ConfirmationQuestion(\sprintf('You are about to remove %d translations. Do you wish to continue? (y/N) ', $messageCount), false);
99+
$question = new ConfirmationQuestion(sprintf('You are about to remove %d translations. Do you wish to continue? (y/N) ', $messageCount), false);
100100
if (!$helper->ask($input, $output, $question)) {
101101
return 0;
102102
}
@@ -109,7 +109,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
109109
foreach ($messages as $message) {
110110
$storage->delete($message->getLocale(), $message->getDomain(), $message->getKey());
111111
if ($output->getVerbosity() > OutputInterface::VERBOSITY_NORMAL) {
112-
$output->writeln(\sprintf(
112+
$output->writeln(sprintf(
113113
'Deleted empty message "<info>%s</info>" from domain "<info>%s</info>" and locale "<info>%s</info>"',
114114
$message->getKey(),
115115
$message->getDomain(),

0 commit comments

Comments
 (0)