Skip to content

Update master branch #2

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 21 commits into from
Nov 24, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
e8cdfeb
Fix broken tests (#458)
bocharsky-bw Jan 20, 2022
92f3de5
register visitor tag also for TranslateAnnotationVisitor and Knp visi…
Guite Jan 20, 2022
d9d71b1
Prepare release v0.12.4 (#456)
bocharsky-bw Jan 20, 2022
85806a7
refac: remove AbstractController from EditInPlaceController (#459)
gimler Jan 20, 2022
874cf43
Stop extending AbstractController to fix some deprecations (#460)
bocharsky-bw Jan 24, 2022
d47279e
Use autowiring for SymfonyProfilerController (#461)
bocharsky-bw Jan 24, 2022
004c8f4
Fix Cannot autowire service "php_translation.data_collector" error in…
axi Jan 24, 2022
75047fd
Fix yaml identation to 4 spaces (#462)
bocharsky-bw Jan 25, 2022
2c3a0c2
Add testing on the newest PHP 8.1 to the CI config (#465)
bocharsky-bw Jan 28, 2022
b946f06
Allow Symfony 6 (#464)
bocharsky-bw Jan 28, 2022
ea84216
Fix for deprecated session service in Symfony 6 (#468)
robbedg Feb 4, 2022
255a9f6
Fix return type and implement getCatalogues() (#470)
bocharsky-bw Feb 14, 2022
830cc04
Use a different image for PHP CS Fixer to get latest and upgrade conf…
bocharsky-bw Feb 14, 2022
02bcf0e
Prepare release v0.12.5 (#469)
bocharsky-bw Feb 14, 2022
ccfd60e
Some minor tweaks in README (#472)
bocharsky-bw Feb 15, 2022
1c0519e
fix: used finder->exclude instead of notPath for excludedDirs (#474)
seizan8 Apr 4, 2022
1a83e47
Prepare 0.12.6 (#475)
bocharsky-bw Apr 6, 2022
692900e
fix: check if session if available (#478)
robbedg Sep 2, 2022
123dfd2
Update Changelog.md
bocharsky-bw Sep 2, 2022
4bdd4cf
Fix code styles (#479)
bocharsky-bw Sep 3, 2022
4051a5b
Upgrade the SymfonyBundleTest (#481)
bocharsky-bw Sep 9, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
strategy:
fail-fast: false
matrix:
php: [ '7.2', '7.3', '7.4', '8.0' ]
php: [ '7.2', '7.3', '7.4', '8.0', '8.1' ]
strategy: [ 'highest' ]
sf_version: ['']
include:
Expand Down Expand Up @@ -43,4 +43,3 @@ jobs:

- name: Run tests
run: ./vendor/bin/simple-phpunit

34 changes: 6 additions & 28 deletions .github/workflows/static.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,35 +38,13 @@ jobs:

php-cs-fixer:
name: PHP-CS-Fixer
runs-on: Ubuntu-20.04

runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Cache PhpCsFixer
uses: actions/cache@v2
with:
path: .github/.cache/php-cs-fixer/
key: php-cs-fixer-${{ github.sha }}
restore-keys: php-cs-fixer-

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '7.4'
coverage: none

- name: Download dependencies
uses: ramsey/composer-install@v1
with:
composer-options: --no-interaction --prefer-dist --optimize-autoloader

- name: Download PHP CS Fixer
run: composer bin php-cs-fixer update --no-interaction --no-progress

- name: Execute PHP CS Fixer
run: vendor/bin/php-cs-fixer fix --diff-format udiff --dry-run
- uses: actions/checkout@v2
- name: PHP-CS-Fixer
uses: docker://oskarstark/php-cs-fixer-ga
with:
args: --diff --dry-run

psalm:
name: Psalm
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@
/phpunit.xml
/vendor/
.php_cs.cache
.php-cs-fixer.cache
.phpunit.result.cache
21 changes: 21 additions & 0 deletions .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php

$finder = PhpCsFixer\Finder::create()
->exclude(__DIR__.'/vendor')
->name('*.php')
->in(__DIR__)
;

$config = new PhpCsFixer\Config();
return $config->setRules([
'@Symfony' => true,
'@Symfony:risky' => true,
'array_syntax' => ['syntax' => 'short'],
'native_function_invocation' => true,
'ordered_imports' => true,
'declare_strict_types' => false,
'single_import_per_statement' => false,
])
->setRiskyAllowed(true)
->setFinder($finder)
;
22 changes: 0 additions & 22 deletions .php_cs

This file was deleted.

2 changes: 1 addition & 1 deletion Catalogue/CatalogueFetcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public function getCatalogues(Configuration $config, array $locales = []): array
foreach ($locales as $locale) {
$currentCatalogue = new MessageCatalogue($locale);
foreach ($dirs as $path) {
if (\is_dir($path)) {
if (is_dir($path)) {
$this->reader->read($path, $currentCatalogue);
}
}
Expand Down
4 changes: 2 additions & 2 deletions Catalogue/CatalogueManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public function load(array $catalogues): void
public function getDomains(): array
{
/** @var MessageCatalogueInterface $c */
$c = \reset($this->catalogues);
$c = reset($this->catalogues);

return $c->getDomains();
}
Expand Down Expand Up @@ -107,7 +107,7 @@ public function findMessages(array $config = []): array
}
}

$messages = \array_filter($messages, static function (CatalogueMessage $m) use ($isNew, $isObsolete, $isApproved, $isEmpty) {
$messages = array_filter($messages, static function (CatalogueMessage $m) use ($isNew, $isObsolete, $isApproved, $isEmpty) {
if (null !== $isNew && $m->isNew() !== $isNew) {
return false;
}
Expand Down
8 changes: 4 additions & 4 deletions Catalogue/Operation/ReplaceOperation.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ protected function processDomain($domain): void
'new' => [],
'obsolete' => [],
];
if (\defined(\sprintf('%s::INTL_DOMAIN_SUFFIX', MessageCatalogueInterface::class))) {
if (\defined(sprintf('%s::INTL_DOMAIN_SUFFIX', MessageCatalogueInterface::class))) {
$intlDomain = $domain.MessageCatalogueInterface::INTL_DOMAIN_SUFFIX;
} else {
$intlDomain = $domain;
Expand Down Expand Up @@ -140,12 +140,12 @@ private function doMergeMetadata(array $source, array $target): array
// If both arrays, do recursive call
$source[$key] = $this->doMergeMetadata($source[$key], $value);
}
// Else, use value form $source
// Else, use value form $source
} else {
// Add new value
$source[$key] = $value;
}
// if sequential
// if sequential
} elseif (!\in_array($value, $source, true)) {
$source[] = $value;
}
Expand All @@ -160,6 +160,6 @@ public function isArrayAssociative(array $arr): bool
return false;
}

return \array_keys($arr) !== \range(0, \count($arr) - 1);
return array_keys($arr) !== range(0, \count($arr) - 1);
}
}
54 changes: 54 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,60 @@

The change log describes what is "Added", "Removed", "Changed" or "Fixed" between each release.

## 0.12.7

### Fixed

* fix: check if session is available by @robbedg in https://github.com/php-translation/symfony-bundle/pull/478

## 0.12.6

### Fixed

* fix: used finder->exclude instead of notPath for excludedDirs by @seizan8 in https://github.com/php-translation/symfony-bundle/pull/474

## 0.12.5

### Added

* Add testing on the newest PHP 8.1 to the CI config by @bocharsky-bw in https://github.com/php-translation/symfony-bundle/pull/465
* Allow Symfony 6 by @bocharsky-bw in https://github.com/php-translation/symfony-bundle/pull/464

### Removed

* refac: remove AbstractController from EditInPlaceController by @gimler in https://github.com/php-translation/symfony-bundle/pull/459
* Stop extending AbstractController to fix some deprecations by @bocharsky-bw in https://github.com/php-translation/symfony-bundle/pull/460

### Changed

* Use autowiring for SymfonyProfilerController by @bocharsky-bw in https://github.com/php-translation/symfony-bundle/pull/461
* Use a different image for PHP CS Fixer to get latest and upgrade config #471

### Fixed

* Fix Cannot autowire service "php_translation.data_collector" error in… by @axi in https://github.com/php-translation/symfony-bundle/pull/463
* Fix yaml indentation to 4 spaces by @bocharsky-bw in https://github.com/php-translation/symfony-bundle/pull/462
* Fix for deprecated session service in Symfony 6 by @robbedg in https://github.com/php-translation/symfony-bundle/pull/468
* Fix return type and implement getCatalogues() https://github.com/php-translation/symfony-bundle/pull/470

## 0.12.4

### Fixed

- Fix extractor parameters #438
- Make Profiler service an optional argument for SymfonyProfilerController #440
- Update ExtractCommand.php #435
- Fix tests on Symfony 5.3 #443
- Suppress getMasterRequest() deprecation message #444
- Suppress deprecations on deprecating legacy services #445
- Fix PHPUnit deprecations #447
- Fix broken tests #458
- Register visitor tag also for TranslateAnnotationVisitor and Knp visitors #451

### Removed

- Drop SensioLabs (Symfony) insight badge #441

## 0.12.3

### Fixed
Expand Down
8 changes: 4 additions & 4 deletions Command/BundleTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ trait BundleTrait
private function configureBundleDirs(InputInterface $input, Configuration $config): void
{
if ($bundleName = $input->getOption('bundle')) {
if (0 === \strpos($bundleName, '@')) {
if (false === $pos = \strpos($bundleName, '/')) {
$bundleName = \substr($bundleName, 1);
if (0 === strpos($bundleName, '@')) {
if (false === $pos = strpos($bundleName, '/')) {
$bundleName = substr($bundleName, 1);
} else {
$bundleName = \substr($bundleName, 1, $pos - 2);
$bundleName = substr($bundleName, 1, $pos - 2);
}
}

Expand Down
6 changes: 3 additions & 3 deletions Command/CheckMissingCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
$io = new SymfonyStyle($input, $output);

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

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

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

return 1;
Expand Down Expand Up @@ -132,7 +132,7 @@ private function countEmptyTranslations(MessageCatalogueInterface $catalogue): i
$total = 0;

foreach ($catalogue->getDomains() as $domain) {
$emptyTranslations = \array_filter(
$emptyTranslations = array_filter(
$catalogue->all($domain),
function (string $message = null): bool {
return null === $message || '' === $message;
Expand Down
4 changes: 2 additions & 2 deletions Command/DeleteEmptyCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int

if ($input->isInteractive()) {
$helper = $this->getHelper('question');
$question = new ConfirmationQuestion(\sprintf('You are about to remove %d translations. Do you wish to continue? (y/N) ', $messageCount), false);
$question = new ConfirmationQuestion(sprintf('You are about to remove %d translations. Do you wish to continue? (y/N) ', $messageCount), false);
if (!$helper->ask($input, $output, $question)) {
return 0;
}
Expand All @@ -109,7 +109,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
foreach ($messages as $message) {
$storage->delete($message->getLocale(), $message->getDomain(), $message->getKey());
if ($output->getVerbosity() > OutputInterface::VERBOSITY_NORMAL) {
$output->writeln(\sprintf(
$output->writeln(sprintf(
'Deleted empty message "<info>%s</info>" from domain "<info>%s</info>" and locale "<info>%s</info>"',
$message->getKey(),
$message->getDomain(),
Expand Down
4 changes: 2 additions & 2 deletions Command/DeleteObsoleteCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int

if ($input->isInteractive()) {
$helper = $this->getHelper('question');
$question = new ConfirmationQuestion(\sprintf('You are about to remove %d translations. Do you wish to continue? (y/N) ', $messageCount), false);
$question = new ConfirmationQuestion(sprintf('You are about to remove %d translations. Do you wish to continue? (y/N) ', $messageCount), false);
if (!$helper->ask($input, $output, $question)) {
return 0;
}
Expand All @@ -110,7 +110,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
foreach ($messages as $message) {
$storage->delete($message->getLocale(), $message->getDomain(), $message->getKey());
if ($output->getVerbosity() > OutputInterface::VERBOSITY_NORMAL) {
$output->writeln(\sprintf(
$output->writeln(sprintf(
'Deleted obsolete message "<info>%s</info>" from domain "<info>%s</info>" and locale "<info>%s</info>"',
$message->getKey(),
$message->getDomain(),
Expand Down
12 changes: 6 additions & 6 deletions Command/DownloadCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
$message = 'The --cache option is deprecated as it\'s now the default behaviour of this command.';

$io->note($message);
@\trigger_error($message, \E_USER_DEPRECATED);
@trigger_error($message, \E_USER_DEPRECATED);
}

$configName = $input->getArgument('configuration');
Expand Down Expand Up @@ -117,19 +117,19 @@ protected function execute(InputInterface $input, OutputInterface $output): int
*/
private function hashDirectory(string $directory)
{
if (!\is_dir($directory)) {
if (!is_dir($directory)) {
return false;
}

$finder = new Finder();
$finder->files()->in($directory)->notName('/~$/')->sortByName();

$hash = \hash_init('md5');
$hash = hash_init('md5');
foreach ($finder as $file) {
\hash_update_file($hash, $file->getRealPath());
hash_update_file($hash, $file->getRealPath());
}

return \hash_final($hash);
return hash_final($hash);
}

public function cleanParameters(array $raw)
Expand All @@ -138,7 +138,7 @@ public function cleanParameters(array $raw)

foreach ($raw as $string) {
// Assert $string looks like "foo:bar"
list($key, $value) = \explode(':', $string, 2);
list($key, $value) = explode(':', $string, 2);
$config[$key][] = $value;
}

Expand Down
4 changes: 2 additions & 2 deletions Command/ExtractCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
/** @var Error $error */
foreach ($errors as $error) {
$io->error(
\sprintf("%s\nLine: %s\nMessage: %s", $error->getPath(), $error->getLine(), $error->getMessage())
sprintf("%s\nLine: %s\nMessage: %s", $error->getPath(), $error->getLine(), $error->getMessage())
);
}
}
Expand All @@ -143,7 +143,7 @@ private function getConfiguredFinder(Configuration $config): Finder
$finder->in($config->getDirs());

foreach ($config->getExcludedDirs() as $exclude) {
$finder->notPath($exclude);
$finder->exclude($exclude);
}

foreach ($config->getExcludedNames() as $exclude) {
Expand Down
2 changes: 1 addition & 1 deletion Command/StatusCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
}

if ($input->getOption('json')) {
$output->writeln(\json_encode($stats));
$output->writeln(json_encode($stats));

return 0;
}
Expand Down
2 changes: 1 addition & 1 deletion Command/StorageTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ private function getStorage($configName): StorageService
if (null === $storage = $this->storageManager->getStorage($configName)) {
$availableStorages = $this->storageManager->getNames();

throw new \InvalidArgumentException(\sprintf('Unknown storage "%s". Available storages are "%s".', $configName, \implode('", "', $availableStorages)));
throw new \InvalidArgumentException(sprintf('Unknown storage "%s". Available storages are "%s".', $configName, implode('", "', $availableStorages)));
}

return $storage;
Expand Down
Loading