Skip to content

Remove symfony console $defaultName deprecation #491

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 4 commits into from
Jul 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
6 changes: 2 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,12 @@ jobs:
strategy:
fail-fast: false
matrix:
php: [ '7.2', '7.3', '7.4', '8.0', '8.1' ]
php: ['8.0', '8.1', '8.2']
strategy: [ 'highest' ]
sf_version: ['']
include:
- php: 7.4
- php: 8.0
strategy: 'lowest'
- php: 7.3
sf_version: '4.*'

steps:
- name: Checkout code
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/static.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '7.4'
php-version: '8.0'
coverage: none

- name: Download dependencies
Expand Down Expand Up @@ -63,7 +63,7 @@ jobs:
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '7.4'
php-version: '8.0'
coverage: none

- name: Download dependencies
Expand Down
12 changes: 6 additions & 6 deletions Catalogue/CatalogueManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,12 @@ public function getMessages(string $locale, string $domain): array
/**
* @param array $config {
*
* @var string $domain
* @var string $locale
* @var bool $isNew
* @var bool $isObsolete
* @var bool $isApproved
* }
* @var string $domain
* @var string $locale
* @var bool $isNew
* @var bool $isObsolete
* @var bool $isApproved
* }
*
* @return CatalogueMessage[]
*/
Expand Down
4 changes: 2 additions & 2 deletions Catalogue/Operation/ReplaceOperation.php
Original file line number Diff line number Diff line change
Expand Up @@ -150,12 +150,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 Down
2 changes: 1 addition & 1 deletion Command/BundleTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ trait BundleTrait
private function configureBundleDirs(InputInterface $input, Configuration $config): void
{
if ($bundleName = $input->getOption('bundle')) {
if (0 === strpos($bundleName, '@')) {
if (str_starts_with($bundleName, '@')) {
if (false === $pos = strpos($bundleName, '/')) {
$bundleName = substr($bundleName, 1);
} else {
Expand Down
7 changes: 4 additions & 3 deletions Command/CheckMissingCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

namespace Translation\Bundle\Command;

use Symfony\Component\Console\Attribute\AsCommand;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
Expand All @@ -17,10 +18,11 @@
use Translation\Bundle\Service\ConfigurationManager;
use Translation\Bundle\Service\Importer;

#[AsCommand(
name: 'translation:check-missing'
)]
final class CheckMissingCommand extends Command
{
protected static $defaultName = 'translation:check-missing';

/**
* @var ConfigurationManager
*/
Expand Down Expand Up @@ -58,7 +60,6 @@ public function __construct(
protected function configure(): void
{
$this
->setName(self::$defaultName)
->setDescription('Check that all translations for a given locale are extracted.')
->addArgument('locale', InputArgument::REQUIRED, 'The locale to check')
->addArgument('configuration', InputArgument::OPTIONAL, 'The configuration to use', 'default');
Expand Down
7 changes: 4 additions & 3 deletions Command/DeleteEmptyCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

namespace Translation\Bundle\Command;

use Symfony\Component\Console\Attribute\AsCommand;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Helper\ProgressBar;
use Symfony\Component\Console\Input\InputArgument;
Expand All @@ -26,13 +27,14 @@
/**
* @author Tobias Nyholm <tobias.nyholm@gmail.com>
*/
#[AsCommand(
name: 'translation:delete-empty'
)]
class DeleteEmptyCommand extends Command
{
use BundleTrait;
use StorageTrait;

protected static $defaultName = 'translation:delete-empty';

/**
* @var ConfigurationManager
*/
Expand Down Expand Up @@ -64,7 +66,6 @@ public function __construct(
protected function configure(): void
{
$this
->setName(self::$defaultName)
->setDescription('Delete all translations currently empty.')
->addArgument('configuration', InputArgument::OPTIONAL, 'The configuration to use', 'default')
->addArgument('locale', InputArgument::OPTIONAL, 'The locale to use. If omitted, we use all configured locales.', null)
Expand Down
7 changes: 4 additions & 3 deletions Command/DeleteObsoleteCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

namespace Translation\Bundle\Command;

use Symfony\Component\Console\Attribute\AsCommand;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Helper\ProgressBar;
use Symfony\Component\Console\Input\InputArgument;
Expand All @@ -26,13 +27,14 @@
/**
* @author Tobias Nyholm <tobias.nyholm@gmail.com>
*/
#[AsCommand(
name: 'translation:delete-obsolete'
)]
class DeleteObsoleteCommand extends Command
{
use BundleTrait;
use StorageTrait;

protected static $defaultName = 'translation:delete-obsolete';

/**
* @var ConfigurationManager
*/
Expand Down Expand Up @@ -64,7 +66,6 @@ public function __construct(
protected function configure(): void
{
$this
->setName(self::$defaultName)
->setDescription('Delete all translations marked as obsolete.')
->addArgument('configuration', InputArgument::OPTIONAL, 'The configuration to use', 'default')
->addArgument('locale', InputArgument::OPTIONAL, 'The locale to use. If omitted, we use all configured locales.', null)
Expand Down
9 changes: 5 additions & 4 deletions Command/DownloadCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

namespace Translation\Bundle\Command;

use Symfony\Component\Console\Attribute\AsCommand;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
Expand All @@ -26,13 +27,14 @@
/**
* @author Tobias Nyholm <tobias.nyholm@gmail.com>
*/
#[AsCommand(
name: 'translation:download'
)]
class DownloadCommand extends Command
{
use BundleTrait;
use StorageTrait;

protected static $defaultName = 'translation:download';

private $configurationManager;
private $cacheCleaner;
private $catalogueWriter;
Expand All @@ -54,7 +56,6 @@ public function __construct(
protected function configure(): void
{
$this
->setName(self::$defaultName)
->setDescription('Replace local messages with messages from remote')
->setHelp(<<<EOT
The <info>%command.name%</info> will erase all your local translations and replace them with translations downloaded from the remote.
Expand Down Expand Up @@ -138,7 +139,7 @@ public function cleanParameters(array $raw)

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

Expand Down
7 changes: 4 additions & 3 deletions Command/ExtractCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

namespace Translation\Bundle\Command;

use Symfony\Component\Console\Attribute\AsCommand;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
Expand All @@ -29,12 +30,13 @@
/**
* @author Tobias Nyholm <tobias.nyholm@gmail.com>
*/
#[AsCommand(
name: 'translation:extract'
)]
class ExtractCommand extends Command
{
use BundleTrait;

protected static $defaultName = 'translation:extract';

/**
* @var CatalogueFetcher
*/
Expand Down Expand Up @@ -79,7 +81,6 @@ public function __construct(
protected function configure(): void
{
$this
->setName(self::$defaultName)
->setDescription('Extract translations from source code.')
->addArgument('configuration', InputArgument::OPTIONAL, 'The configuration to use', 'default')
->addArgument('locale', InputArgument::OPTIONAL, 'The locale to use. If omitted, we use all configured locales.', false)
Expand Down
7 changes: 4 additions & 3 deletions Command/StatusCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

namespace Translation\Bundle\Command;

use Symfony\Component\Console\Attribute\AsCommand;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
Expand All @@ -24,12 +25,13 @@
/**
* @author Tobias Nyholm <tobias.nyholm@gmail.com>
*/
#[AsCommand(
name: 'translation:status'
)]
class StatusCommand extends Command
{
use BundleTrait;

protected static $defaultName = 'translation:status';

/**
* @var CatalogueCounter
*/
Expand Down Expand Up @@ -60,7 +62,6 @@ public function __construct(
protected function configure(): void
{
$this
->setName(self::$defaultName)
->setDescription('Show status about your translations.')
->addArgument('configuration', InputArgument::OPTIONAL, 'The configuration to use', 'default')
->addArgument('locale', InputArgument::OPTIONAL, 'The locale to use. If omitted, we use all configured locales.', false)
Expand Down
9 changes: 5 additions & 4 deletions Command/SyncCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

namespace Translation\Bundle\Command;

use Symfony\Component\Console\Attribute\AsCommand;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
Expand All @@ -22,12 +23,13 @@
/**
* @author Tobias Nyholm <tobias.nyholm@gmail.com>
*/
#[AsCommand(
name: 'translation:sync'
)]
class SyncCommand extends Command
{
use StorageTrait;

protected static $defaultName = 'translation:sync';

public function __construct(StorageManager $storageManager)
{
$this->storageManager = $storageManager;
Expand All @@ -38,7 +40,6 @@ public function __construct(StorageManager $storageManager)
protected function configure(): void
{
$this
->setName(self::$defaultName)
->setDescription('Sync the translations with the remote storage')
->addArgument('configuration', InputArgument::OPTIONAL, 'The configuration to use', 'default')
->addArgument('direction', InputArgument::OPTIONAL, 'Use "down" if local changes should be overwritten, otherwise "up"', 'down')
Expand Down Expand Up @@ -78,7 +79,7 @@ public function cleanParameters(array $raw)

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

Expand Down
2 changes: 1 addition & 1 deletion Controller/WebUIController.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public function __construct(
/**
* Show a dashboard for the configuration.
*/
public function indexAction(?string $configName = null): Response
public function indexAction(string $configName = null): Response
{
if (!$this->isWebUIEnabled) {
return new Response('You are not allowed here. Check your config.', Response::HTTP_BAD_REQUEST);
Expand Down
3 changes: 0 additions & 3 deletions DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,6 @@ public function __construct(ContainerBuilder $container)
$this->container = $container;
}

/**
* {@inheritdoc}
*/
public function getConfigTreeBuilder(): TreeBuilder
{
$treeBuilder = new TreeBuilder('translation');
Expand Down
9 changes: 0 additions & 9 deletions DependencyInjection/TranslationExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,6 @@
*/
class TranslationExtension extends Extension
{
/**
* {@inheritdoc}
*/
public function load(array $configs, ContainerBuilder $container): void
{
$container->setParameter('extractor_vendor_dir', $this->getExtractorVendorDirectory());
Expand Down Expand Up @@ -224,17 +221,11 @@ private function enableFallbackAutoTranslator(ContainerBuilder $container, array
$container->setParameter('php_translation.translator_service.api_key', $config['fallback_translation']['api_key']);
}

/**
* {@inheritdoc}
*/
public function getAlias(): string
{
return 'translation';
}

/**
* {@inheritdoc}
*/
public function getConfiguration(array $config, ContainerBuilder $container): Configuration
{
return new Configuration($container);
Expand Down
5 changes: 1 addition & 4 deletions EditInPlace/Activator.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ final class Activator implements ActivatorInterface
/**
* @var Session|null
*/
private $session = null;
private $session;

public function __construct(RequestStack $requestStack)
{
Expand Down Expand Up @@ -81,9 +81,6 @@ public function deactivate(): void
}
}

/**
* {@inheritdoc}
*/
public function checkRequest(Request $request = null): bool
{
if (null === $this->getSession() || !$this->getSession()->has(self::KEY)) {
Expand Down
2 changes: 1 addition & 1 deletion Service/CacheClearer.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public function __construct(string $kernelCacheDir, $translator, Filesystem $fil
*
* @param string|null $locale optional filter to clear only one locale
*/
public function clearAndWarmUp(?string $locale = null): void
public function clearAndWarmUp(string $locale = null): void
{
$translationDir = sprintf('%s/translations', $this->kernelCacheDir);

Expand Down
Loading