From a6126f54c03bbaa62056b08d464c615e3483554f Mon Sep 17 00:00:00 2001 From: bocharsky-bw Date: Thu, 11 Apr 2024 12:58:22 +0200 Subject: [PATCH 1/5] Bump PHP to 8.1 in composer.json --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 5cd088c..1b3b714 100644 --- a/composer.json +++ b/composer.json @@ -10,7 +10,7 @@ } ], "require": { - "php": "^8.0", + "php": "^8.1", "symfony/framework-bundle": "^5.3 || ^6.0", "symfony/validator": "^5.3 || ^6.0", "symfony/translation": "^5.3 || ^6.0", From 22a98b60a0cd2311496d74e98601dd54f7e16204 Mon Sep 17 00:00:00 2001 From: bocharsky-bw Date: Thu, 11 Apr 2024 13:06:32 +0200 Subject: [PATCH 2/5] Use PHP 8.1 on SA CI too --- .github/workflows/static.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/static.yml b/.github/workflows/static.yml index aea0eba..ea6822a 100644 --- a/.github/workflows/static.yml +++ b/.github/workflows/static.yml @@ -22,7 +22,7 @@ jobs: - name: Setup PHP uses: shivammathur/setup-php@v2 with: - php-version: '8.0' + php-version: '8.1' coverage: none - name: Download dependencies @@ -63,7 +63,7 @@ jobs: - name: Setup PHP uses: shivammathur/setup-php@v2 with: - php-version: '8.0' + php-version: '8.1' coverage: none - name: Download dependencies From f5541f2f455beb551c84199d829216d7f202e7ef Mon Sep 17 00:00:00 2001 From: bocharsky-bw Date: Thu, 13 Jun 2024 13:03:38 +0200 Subject: [PATCH 3/5] Rebuild CI From 31c50f8ec2aa16915750720d49f7b177d2a4cc3b Mon Sep 17 00:00:00 2001 From: bocharsky-bw Date: Thu, 13 Jun 2024 14:09:21 +0200 Subject: [PATCH 4/5] Fix PHPStan --- Catalogue/CatalogueManager.php | 20 ++++++----- Command/DeleteEmptyCommand.php | 2 ++ Command/DeleteObsoleteCommand.php | 2 ++ Service/Importer.php | 10 +++--- composer.json | 3 +- phpstan-baseline.neon | 56 ++++++++++++++++++------------- 6 files changed, 54 insertions(+), 39 deletions(-) diff --git a/Catalogue/CatalogueManager.php b/Catalogue/CatalogueManager.php index 09a50d5..a861abe 100644 --- a/Catalogue/CatalogueManager.php +++ b/Catalogue/CatalogueManager.php @@ -66,27 +66,29 @@ 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 - * } - * - * @return CatalogueMessage[] + * @return CatalogueMessage[] Contains: + * - string $domain + * - string $locale + * - bool $isNew + * - bool $isObsolete + * - bool $isApproved */ public function findMessages(array $config = []): array { + /** @var string $inputDomain */ $inputDomain = $config['domain'] ?? null; + /** @var bool $isNew */ $isNew = $config['isNew'] ?? null; + /** @var bool $isObsolete */ $isObsolete = $config['isObsolete'] ?? null; + /** @var bool $isApproved */ $isApproved = $config['isApproved'] ?? null; $isEmpty = $config['isEmpty'] ?? null; $messages = []; $catalogues = []; if (isset($config['locale'])) { + /** @var string $locale */ $locale = $config['locale']; if (isset($this->catalogues[$locale])) { $catalogues = [$locale => $this->catalogues[$locale]]; diff --git a/Command/DeleteEmptyCommand.php b/Command/DeleteEmptyCommand.php index 75f290c..dd4bc23 100644 --- a/Command/DeleteEmptyCommand.php +++ b/Command/DeleteEmptyCommand.php @@ -14,6 +14,7 @@ use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Helper\ProgressBar; +use Symfony\Component\Console\Helper\QuestionHelper; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; @@ -96,6 +97,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int } if ($input->isInteractive()) { + /** @var QuestionHelper $helper */ $helper = $this->getHelper('question'); $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)) { diff --git a/Command/DeleteObsoleteCommand.php b/Command/DeleteObsoleteCommand.php index 74a04f7..c0ecc0c 100644 --- a/Command/DeleteObsoleteCommand.php +++ b/Command/DeleteObsoleteCommand.php @@ -14,6 +14,7 @@ use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Helper\ProgressBar; +use Symfony\Component\Console\Helper\QuestionHelper; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; @@ -97,6 +98,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int } if ($input->isInteractive()) { + /** @var QuestionHelper $helper */ $helper = $this->getHelper('question'); $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)) { diff --git a/Service/Importer.php b/Service/Importer.php index 46436d3..e89423c 100644 --- a/Service/Importer.php +++ b/Service/Importer.php @@ -60,12 +60,10 @@ public function __construct(Extractor $extractor, Environment $twig, string $def /** * @param MessageCatalogue[] $catalogues - * @param array $config { - * - * @var array $blacklist_domains Blacklist the domains we should exclude. Cannot be used with whitelist. - * @var array $whitelist_domains Whitelist the domains we should include. Cannot be used with blacklist. - * @var string $project_root The project root will be removed from the source location. - * } + * @param array $config Configuration options: + * - array $blacklist_domains Domains to be excluded. Cannot be used with whitelist. + * - array $whitelist_domains Domains to be included. Cannot be used with blacklist. + * - string $project_root The project root that will be removed from the source location. */ public function extractToCatalogues(Finder $finder, array $catalogues, array $config = []): ImportResult { diff --git a/composer.json b/composer.json index 1b3b714..944f7ae 100644 --- a/composer.json +++ b/composer.json @@ -38,7 +38,8 @@ "matthiasnoback/symfony-dependency-injection-test": "^4.1", "matthiasnoback/symfony-config-test": "^4.1", "nyholm/psr7": "^1.1", - "nyholm/symfony-bundle-test": "^2.0" + "nyholm/symfony-bundle-test": "^2.0", + "phpstan/phpstan": "^1.11" }, "suggest": { "php-http/httplug-bundle": "To easier configure your httplug clients." diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index 30f3877..4f276f1 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -26,12 +26,12 @@ parameters: path: Command/StatusCommand.php - - message: "#^Call to an undefined method Symfony\\\\Component\\\\Config\\\\Definition\\\\Builder\\\\TreeBuilder\\:\\:root\\(\\)\\.$#" + message: "#^Call to an undefined method Symfony\\\\Component\\\\Config\\\\Definition\\\\Builder\\\\NodeDefinition\\:\\:fixXmlConfig\\(\\)\\.$#" count: 1 path: DependencyInjection/Configuration.php - - message: "#^Call to an undefined method Symfony\\\\Component\\\\Config\\\\Definition\\\\Builder\\\\NodeDefinition\\:\\:fixXmlConfig\\(\\)\\.$#" + message: "#^Call to an undefined method Symfony\\\\Component\\\\Config\\\\Definition\\\\Builder\\\\NodeParentInterface\\:\\:booleanNode\\(\\)\\.$#" count: 1 path: DependencyInjection/Configuration.php @@ -41,7 +41,7 @@ parameters: path: DependencyInjection/Configuration.php - - message: "#^Call to an undefined method Symfony\\\\Component\\\\Config\\\\Definition\\\\Builder\\\\NodeParentInterface\\:\\:booleanNode\\(\\)\\.$#" + message: "#^Call to an undefined method Symfony\\\\Component\\\\Config\\\\Definition\\\\Builder\\\\TreeBuilder\\:\\:root\\(\\)\\.$#" count: 1 path: DependencyInjection/Configuration.php @@ -51,22 +51,22 @@ parameters: path: Service/CacheClearer.php - - message: "#^Property Translation\\\\Bundle\\\\Translator\\\\EditInPlaceTranslator\\:\\:\\$translator has unknown class Symfony\\\\Component\\\\Translation\\\\TranslatorInterface as its type\\.$#" + message: "#^Call to method getCatalogue\\(\\) on an unknown class Symfony\\\\Component\\\\Translation\\\\TranslatorInterface\\.$#" count: 1 path: Translator/EditInPlaceTranslator.php - - message: "#^Parameter \\$translator of method Translation\\\\Bundle\\\\Translator\\\\EditInPlaceTranslator\\:\\:__construct\\(\\) has invalid typehint type Symfony\\\\Component\\\\Translation\\\\TranslatorInterface\\.$#" + message: "#^Call to method getCatalogues\\(\\) on an unknown class Symfony\\\\Component\\\\Translation\\\\TranslatorInterface\\.$#" count: 1 path: Translator/EditInPlaceTranslator.php - - message: "#^Class Symfony\\\\Component\\\\Translation\\\\TranslatorInterface not found\\.$#" - count: 1 + message: "#^Call to method getLocale\\(\\) on an unknown class Symfony\\\\Component\\\\Translation\\\\TranslatorInterface\\.$#" + count: 2 path: Translator/EditInPlaceTranslator.php - - message: "#^Call to method getCatalogue\\(\\) on an unknown class Symfony\\\\Component\\\\Translation\\\\TranslatorInterface\\.$#" + message: "#^Call to method setLocale\\(\\) on an unknown class Symfony\\\\Component\\\\Translation\\\\TranslatorInterface\\.$#" count: 1 path: Translator/EditInPlaceTranslator.php @@ -76,32 +76,42 @@ parameters: path: Translator/EditInPlaceTranslator.php - - message: "#^Call to method getLocale\\(\\) on an unknown class Symfony\\\\Component\\\\Translation\\\\TranslatorInterface\\.$#" - count: 2 + message: "#^Call to method transChoice\\(\\) on an unknown class Symfony\\\\Component\\\\Translation\\\\TranslatorInterface\\.$#" + count: 1 path: Translator/EditInPlaceTranslator.php - - message: "#^Call to method transChoice\\(\\) on an unknown class Symfony\\\\Component\\\\Translation\\\\TranslatorInterface\\.$#" + message: "#^Class Symfony\\\\Component\\\\Translation\\\\TranslatorInterface not found\\.$#" count: 1 path: Translator/EditInPlaceTranslator.php - - message: "#^Call to method setLocale\\(\\) on an unknown class Symfony\\\\Component\\\\Translation\\\\TranslatorInterface\\.$#" + message: "#^Parameter \\$translator of method Translation\\\\Bundle\\\\Translator\\\\EditInPlaceTranslator\\:\\:__construct\\(\\) has invalid type Symfony\\\\Component\\\\Translation\\\\TranslatorInterface\\.$#" count: 1 path: Translator/EditInPlaceTranslator.php - - message: "#^Property Translation\\\\Bundle\\\\Translator\\\\FallbackTranslator\\:\\:\\$symfonyTranslator has unknown class Symfony\\\\Component\\\\Translation\\\\TranslatorInterface as its type\\.$#" + message: "#^Property Translation\\\\Bundle\\\\Translator\\\\EditInPlaceTranslator\\:\\:\\$translator has unknown class Symfony\\\\Component\\\\Translation\\\\TranslatorInterface as its type\\.$#" + count: 1 + path: Translator/EditInPlaceTranslator.php + + - + message: "#^Call to method getCatalogue\\(\\) on an unknown class Symfony\\\\Component\\\\Translation\\\\TranslatorInterface\\.$#" count: 1 path: Translator/FallbackTranslator.php - - message: "#^Parameter \\$symfonyTranslator of method Translation\\\\Bundle\\\\Translator\\\\FallbackTranslator\\:\\:__construct\\(\\) has invalid typehint type Symfony\\\\Component\\\\Translation\\\\TranslatorInterface\\.$#" + message: "#^Call to method getCatalogues\\(\\) on an unknown class Symfony\\\\Component\\\\Translation\\\\TranslatorInterface\\.$#" count: 1 path: Translator/FallbackTranslator.php - - message: "#^Class Symfony\\\\Component\\\\Translation\\\\TranslatorInterface not found\\.$#" + message: "#^Call to method getLocale\\(\\) on an unknown class Symfony\\\\Component\\\\Translation\\\\TranslatorInterface\\.$#" + count: 1 + path: Translator/FallbackTranslator.php + + - + message: "#^Call to method setLocale\\(\\) on an unknown class Symfony\\\\Component\\\\Translation\\\\TranslatorInterface\\.$#" count: 1 path: Translator/FallbackTranslator.php @@ -116,29 +126,29 @@ parameters: path: Translator/FallbackTranslator.php - - message: "#^Call to method setLocale\\(\\) on an unknown class Symfony\\\\Component\\\\Translation\\\\TranslatorInterface\\.$#" + message: "#^Class Symfony\\\\Component\\\\Translation\\\\TranslatorInterface not found\\.$#" count: 1 path: Translator/FallbackTranslator.php - - message: "#^Call to method getLocale\\(\\) on an unknown class Symfony\\\\Component\\\\Translation\\\\TranslatorInterface\\.$#" + message: "#^Parameter \\$symfonyTranslator of method Translation\\\\Bundle\\\\Translator\\\\FallbackTranslator\\:\\:__construct\\(\\) has invalid type Symfony\\\\Component\\\\Translation\\\\TranslatorInterface\\.$#" count: 1 path: Translator/FallbackTranslator.php - - message: "#^Call to method getCatalogue\\(\\) on an unknown class Symfony\\\\Component\\\\Translation\\\\TranslatorInterface\\.$#" + message: "#^Property Translation\\\\Bundle\\\\Translator\\\\FallbackTranslator\\:\\:\\$symfonyTranslator has unknown class Symfony\\\\Component\\\\Translation\\\\TranslatorInterface as its type\\.$#" count: 1 path: Translator/FallbackTranslator.php - - message: "#^Class Symfony\\\\Component\\\\Translation\\\\TranslatorInterface not found\\.$#" - count: 1 + message: "#^Call to an undefined method Symfony\\\\Component\\\\Translation\\\\TranslatorBagInterface\\|Symfony\\\\Contracts\\\\Translation\\\\TranslatorInterface\\:\\:transChoice\\(\\)\\.$#" + count: 2 path: Twig/TranslationExtension.php - - message: "#^Call to an undefined method Symfony\\\\Component\\\\Translation\\\\TranslatorBagInterface\\|Symfony\\\\Contracts\\\\Translation\\\\TranslatorInterface\\:\\:transChoice\\(\\)\\.$#" - count: 2 + message: "#^Class Symfony\\\\Component\\\\Translation\\\\TranslatorInterface not found\\.$#" + count: 1 path: Twig/TranslationExtension.php - excludes_analyse: + excludePaths: - Translator/TranslatorInterface.php From c42146852879dd660fccbffda08c4bb029dc554e Mon Sep 17 00:00:00 2001 From: bocharsky-bw Date: Thu, 13 Jun 2024 14:10:20 +0200 Subject: [PATCH 5/5] Apply PHP CS Fixer changes --- Catalogue/CatalogueManager.php | 11 ++++++----- Service/Importer.php | 8 ++++---- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/Catalogue/CatalogueManager.php b/Catalogue/CatalogueManager.php index a861abe..e9ce5aa 100644 --- a/Catalogue/CatalogueManager.php +++ b/Catalogue/CatalogueManager.php @@ -66,12 +66,13 @@ public function getMessages(string $locale, string $domain): array /** * @param array $config { + * * @return CatalogueMessage[] Contains: - * - string $domain - * - string $locale - * - bool $isNew - * - bool $isObsolete - * - bool $isApproved + * - string $domain + * - string $locale + * - bool $isNew + * - bool $isObsolete + * - bool $isApproved */ public function findMessages(array $config = []): array { diff --git a/Service/Importer.php b/Service/Importer.php index e89423c..530ca8a 100644 --- a/Service/Importer.php +++ b/Service/Importer.php @@ -60,10 +60,10 @@ public function __construct(Extractor $extractor, Environment $twig, string $def /** * @param MessageCatalogue[] $catalogues - * @param array $config Configuration options: - * - array $blacklist_domains Domains to be excluded. Cannot be used with whitelist. - * - array $whitelist_domains Domains to be included. Cannot be used with blacklist. - * - string $project_root The project root that will be removed from the source location. + * @param array $config Configuration options: + * - array $blacklist_domains Domains to be excluded. Cannot be used with whitelist. + * - array $whitelist_domains Domains to be included. Cannot be used with blacklist. + * - string $project_root The project root that will be removed from the source location. */ public function extractToCatalogues(Finder $finder, array $catalogues, array $config = []): ImportResult {