From 9176974ccd1305e0d752ac867cdd9f6e883affb4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Tue, 5 Dec 2023 10:13:01 +0100 Subject: [PATCH 1/8] Address issues with more recent PHPStan versions I ignored some of the issues because they have to do with user input, and I'm not 100% sure I can assert Symfony options or arguments are going to be strings or int all the time. --- .../Compiler/ProviderCompilerPass.php | 6 +++++- Processor/Retry/RetryProcessorConfigurator.php | 2 ++ phpstan.neon.dist | 12 ++++++++---- 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/DependencyInjection/Compiler/ProviderCompilerPass.php b/DependencyInjection/Compiler/ProviderCompilerPass.php index f70d7f6..153652f 100644 --- a/DependencyInjection/Compiler/ProviderCompilerPass.php +++ b/DependencyInjection/Compiler/ProviderCompilerPass.php @@ -28,7 +28,9 @@ public function process(ContainerBuilder $container): void } } - list($provider, $connections) = $container->getParameter('swarrot.provider_config'); + /** @var array{string, array} $providerConfig */ + $providerConfig = $container->getParameter('swarrot.provider_config'); + list($provider, $connections) = $providerConfig; if (!isset($providersIds[$provider])) { throw new \InvalidArgumentException(sprintf('Invalid provider "%s"', $provider)); @@ -36,6 +38,8 @@ public function process(ContainerBuilder $container): void $id = $providersIds[$provider]; $definition = $container->getDefinition($id); + + /** @var class-string $className */ $className = $container->getParameterBag()->resolveValue($definition->getClass()); $reflection = new \ReflectionClass($className); diff --git a/Processor/Retry/RetryProcessorConfigurator.php b/Processor/Retry/RetryProcessorConfigurator.php index 0d58bc6..415528e 100644 --- a/Processor/Retry/RetryProcessorConfigurator.php +++ b/Processor/Retry/RetryProcessorConfigurator.php @@ -35,6 +35,7 @@ public function __construct(string $processorClass, FactoryInterface $factory, L public function getProcessorArguments(array $options): array { $exchange = $this->getExtra('retry_exchange', 'retry'); + assert(is_string($exchange)); return [ $this->processorClass, @@ -68,6 +69,7 @@ public function resolveOptions(InputInterface $input): array $this->enabled = !$input->getOption('no-retry'); $key = $this->getExtra('retry_routing_key_pattern', 'retry_%attempt%s'); + assert(is_string($key)); return [ 'retry_key_pattern' => str_replace('%queue%', (string) $input->getArgument('queue'), $key), diff --git a/phpstan.neon.dist b/phpstan.neon.dist index b047f23..f56bc2a 100644 --- a/phpstan.neon.dist +++ b/phpstan.neon.dist @@ -4,7 +4,7 @@ parameters: checkMissingIterableValueType: false paths: - . - excludes_analyse: + excludePaths: - Tests - vendor - Event/SymfonyEvent.php @@ -14,7 +14,11 @@ parameters: message: "#^Else branch is unreachable because previous condition is always true\\.$#" count: 1 path: Broker/Publisher.php + - - message: "#^Call to an undefined method Symfony\\\\Component\\\\Config\\\\Definition\\\\Builder\\\\NodeDefinition::fixXmlConfig\\(\\)\\.$#" - count: 1 - path: DependencyInjection/Configuration.php + message: '#^Cannot cast mixed to.*#' + paths: + - Command/SwarrotCommand.php + - Processor/MaxExecutionTime/MaxExecutionTimeProcessorConfigurator.php + - Processor/MaxMessages/MaxMessagesProcessorConfigurator.php + - Processor/Retry/RetryProcessorConfigurator.php From c580cee18e096ff6aca1d193a1bba8be7dd01acb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Tue, 5 Dec 2023 10:22:33 +0100 Subject: [PATCH 2/8] Ignore PHPUnit's result cache --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 33ac913..2d04231 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ vendor/ bin/phpunit +.phpunit.result.cache composer.lock bin/doctrine-dbal From 04461780192016f7e5b2741b4b4a2a369e341c97 Mon Sep 17 00:00:00 2001 From: Ulrich Lusseau <1121867+metfan@users.noreply.github.com> Date: Tue, 1 Aug 2023 17:06:44 +0200 Subject: [PATCH 3/8] Fix flex plugin for github action --- .github/workflows/unit.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/unit.yml b/.github/workflows/unit.yml index 9d01456..025d423 100644 --- a/.github/workflows/unit.yml +++ b/.github/workflows/unit.yml @@ -41,7 +41,9 @@ jobs: run: docker restart ${{ job.services.rabbitmq.id }} - name: Install Symfony Flex - run: composer global require --no-progress --no-scripts --no-plugins symfony/flex + run: | + composer global config --no-plugins allow-plugins.symfony/flex true + composer global require --no-progress --no-scripts symfony/flex - name: Install the dependencies env: From 29dab8eed82ac02b83797b094328d7058b3f4bf9 Mon Sep 17 00:00:00 2001 From: Ulrich Lusseau <1121867+metfan@users.noreply.github.com> Date: Wed, 16 Aug 2023 16:58:02 +0200 Subject: [PATCH 4/8] Apply php-cs-fixer change --- Broker/AmqpLibFactory.php | 9 --------- Broker/BlackholePublisher.php | 3 --- Broker/PeclFactory.php | 9 --------- Command/SwarrotCommand.php | 6 ------ DataCollector/SwarrotDataCollector.php | 5 ----- .../Compiler/ProviderCompilerPass.php | 3 --- DependencyInjection/Configuration.php | 3 --- DependencyInjection/SwarrotExtension.php | 6 ------ Processor/Ack/AckProcessorConfigurator.php | 9 --------- .../Doctrine/ConnectionProcessorConfigurator.php | 14 +------------- .../ObjectManagerProcessorConfigurator.php | 11 +---------- .../ExceptionCatcherProcessorConfigurator.php | 9 --------- .../Insomniac/InsomniacProcessorConfigurator.php | 9 --------- .../InstantRetryProcessorConfigurator.php | 9 --------- .../MaxExecutionTimeProcessorConfigurator.php | 9 --------- .../MaxMessagesProcessorConfigurator.php | 9 --------- .../MemoryLimitProcessorConfigurator.php | 9 --------- Processor/ProcessorConfiguratorExtrasAware.php | 5 ----- Processor/Retry/RetryProcessorConfigurator.php | 9 --------- .../ServicesResetterProcessorConfigurator.php | 9 --------- .../SignalHandlerProcessorConfigurator.php | 9 --------- 21 files changed, 2 insertions(+), 162 deletions(-) diff --git a/Broker/AmqpLibFactory.php b/Broker/AmqpLibFactory.php index fb1e772..c428094 100644 --- a/Broker/AmqpLibFactory.php +++ b/Broker/AmqpLibFactory.php @@ -23,9 +23,6 @@ class AmqpLibFactory implements FactoryInterface /** @var array */ protected $messagePublishers = []; - /** - * {@inheritdoc} - */ public function addConnection(string $name, array $connection): void { if (!empty($connection['url'])) { @@ -36,9 +33,6 @@ public function addConnection(string $name, array $connection): void $this->connections[$name] = $connection; } - /** - * {@inheritdoc} - */ public function getMessageProvider(string $name, string $connection): MessageProviderInterface { if (!isset($this->messageProviders[$connection][$name])) { @@ -54,9 +48,6 @@ public function getMessageProvider(string $name, string $connection): MessagePro return $this->messageProviders[$connection][$name]; } - /** - * {@inheritdoc} - */ public function getMessagePublisher(string $name, string $connection): MessagePublisherInterface { if (!isset($this->messagePublishers[$connection][$name])) { diff --git a/Broker/BlackholePublisher.php b/Broker/BlackholePublisher.php index 95ac139..3bfb9f2 100644 --- a/Broker/BlackholePublisher.php +++ b/Broker/BlackholePublisher.php @@ -6,9 +6,6 @@ class BlackholePublisher extends Publisher { - /** - * {@inheritdoc} - */ public function publish(string $messageType, Message $message, array $overridenConfig = []): void { } diff --git a/Broker/PeclFactory.php b/Broker/PeclFactory.php index 98ed69b..34b75a2 100644 --- a/Broker/PeclFactory.php +++ b/Broker/PeclFactory.php @@ -40,9 +40,6 @@ public function __construct(LoggerInterface $logger = null, bool $publisherConfi $this->timeout = $timeout; } - /** - * {@inheritdoc} - */ public function addConnection(string $name, array $connection): void { if (!empty($connection['url'])) { @@ -53,9 +50,6 @@ public function addConnection(string $name, array $connection): void $this->connections[$name] = $connection; } - /** - * {@inheritdoc} - */ public function getMessageProvider(string $name, string $connection): MessageProviderInterface { if (!isset($this->messageProviders[$connection][$name])) { @@ -71,9 +65,6 @@ public function getMessageProvider(string $name, string $connection): MessagePro return $this->messageProviders[$connection][$name]; } - /** - * {@inheritdoc} - */ public function getMessagePublisher(string $name, string $connection): MessagePublisherInterface { if (!isset($this->messagePublishers[$connection][$name])) { diff --git a/Command/SwarrotCommand.php b/Command/SwarrotCommand.php index 2115316..3159c11 100644 --- a/Command/SwarrotCommand.php +++ b/Command/SwarrotCommand.php @@ -58,9 +58,6 @@ public function __construct( parent::__construct(); } - /** - * {@inheritdoc} - */ protected function configure(): void { $defaultPollInterval = isset($this->extras['poll_interval']) ? $this->extras['poll_interval'] : 500000; @@ -98,9 +95,6 @@ protected function configure(): void } } - /** - * {@inheritdoc} - */ protected function execute(InputInterface $input, OutputInterface $output): int { $options = $this->getOptions($input); diff --git a/DataCollector/SwarrotDataCollector.php b/DataCollector/SwarrotDataCollector.php index 9aee356..e3ef48f 100644 --- a/DataCollector/SwarrotDataCollector.php +++ b/DataCollector/SwarrotDataCollector.php @@ -11,8 +11,6 @@ class SwarrotDataCollector extends DataCollector { /** - * {@inheritdoc} - * * @param \Throwable|\Exception $exception */ public function collect(Request $request, Response $response, \Throwable $exception = null): void @@ -43,9 +41,6 @@ public function getNbMessages(): int return count($this->data); } - /** - * {@inheritdoc} - */ public function getName(): string { return 'swarrot'; diff --git a/DependencyInjection/Compiler/ProviderCompilerPass.php b/DependencyInjection/Compiler/ProviderCompilerPass.php index 153652f..fd8b4d4 100644 --- a/DependencyInjection/Compiler/ProviderCompilerPass.php +++ b/DependencyInjection/Compiler/ProviderCompilerPass.php @@ -8,9 +8,6 @@ class ProviderCompilerPass implements CompilerPassInterface { - /** - * {@inheritdoc} - */ public function process(ContainerBuilder $container): void { if ($container->has('swarrot.factory.default') || !$container->hasParameter('swarrot.provider_config')) { diff --git a/DependencyInjection/Configuration.php b/DependencyInjection/Configuration.php index f0b38ad..80e63d7 100644 --- a/DependencyInjection/Configuration.php +++ b/DependencyInjection/Configuration.php @@ -26,9 +26,6 @@ public function __construct(bool $debug) $this->debug = $debug; } - /** - * {@inheritdoc} - */ public function getConfigTreeBuilder(): TreeBuilder { $treeBuilder = new TreeBuilder('swarrot'); diff --git a/DependencyInjection/SwarrotExtension.php b/DependencyInjection/SwarrotExtension.php index 7e70d99..69e095f 100644 --- a/DependencyInjection/SwarrotExtension.php +++ b/DependencyInjection/SwarrotExtension.php @@ -14,9 +14,6 @@ */ class SwarrotExtension extends Extension { - /** - * {@inheritdoc} - */ public function load(array $configs, ContainerBuilder $container): void { $config = $this->processConfiguration($this->getConfiguration($configs, $container), $configs); @@ -66,9 +63,6 @@ public function load(array $configs, ContainerBuilder $container): void } } - /** - * {@inheritdoc} - */ public function getConfiguration(array $configs, ContainerBuilder $container): Configuration { return new Configuration((bool) $container->getParameter('kernel.debug')); diff --git a/Processor/Ack/AckProcessorConfigurator.php b/Processor/Ack/AckProcessorConfigurator.php index 22fabf2..fada036 100644 --- a/Processor/Ack/AckProcessorConfigurator.php +++ b/Processor/Ack/AckProcessorConfigurator.php @@ -29,9 +29,6 @@ public function __construct(string $processorClass, FactoryInterface $factory, L $this->logger = $logger; } - /** - * {@inheritdoc} - */ public function getProcessorArguments(array $options): array { return [ @@ -41,9 +38,6 @@ public function getProcessorArguments(array $options): array ]; } - /** - * {@inheritdoc} - */ public function getCommandOptions(): array { return [ @@ -52,9 +46,6 @@ public function getCommandOptions(): array ]; } - /** - * {@inheritdoc} - */ public function resolveOptions(InputInterface $input): array { $this->enabled = !$input->getOption('no-ack'); diff --git a/Processor/Doctrine/ConnectionProcessorConfigurator.php b/Processor/Doctrine/ConnectionProcessorConfigurator.php index cbb836b..6e79ddd 100644 --- a/Processor/Doctrine/ConnectionProcessorConfigurator.php +++ b/Processor/Doctrine/ConnectionProcessorConfigurator.php @@ -14,21 +14,15 @@ class ConnectionProcessorConfigurator implements ProcessorConfiguratorInterface /** @var string */ private $processorClass; - /** @var mixed */ + private $connections; - /** - * @param mixed $connections - */ public function __construct(string $processorClass, $connections) { $this->processorClass = $processorClass; $this->connections = $connections; } - /** - * {@inheritdoc} - */ public function getProcessorArguments(array $options): array { return [ @@ -37,17 +31,11 @@ public function getProcessorArguments(array $options): array ]; } - /** - * {@inheritdoc} - */ public function getCommandOptions(): array { return []; } - /** - * {@inheritdoc} - */ public function resolveOptions(InputInterface $input): array { return $this->getExtras(); diff --git a/Processor/Doctrine/ObjectManagerProcessorConfigurator.php b/Processor/Doctrine/ObjectManagerProcessorConfigurator.php index 9703d35..d03a204 100644 --- a/Processor/Doctrine/ObjectManagerProcessorConfigurator.php +++ b/Processor/Doctrine/ObjectManagerProcessorConfigurator.php @@ -16,7 +16,7 @@ class ObjectManagerProcessorConfigurator implements ProcessorConfiguratorInterfa /** @var string */ private $processorClass; - /** @var mixed */ + private $managerRegistry; public function __construct(string $processorClass, ManagerRegistry $managerRegistry) @@ -25,9 +25,6 @@ public function __construct(string $processorClass, ManagerRegistry $managerRegi $this->managerRegistry = $managerRegistry; } - /** - * {@inheritdoc} - */ public function getProcessorArguments(array $options): array { return [ @@ -36,9 +33,6 @@ public function getProcessorArguments(array $options): array ]; } - /** - * {@inheritdoc} - */ public function getCommandOptions(): array { return [ @@ -46,9 +40,6 @@ public function getCommandOptions(): array ]; } - /** - * {@inheritdoc} - */ public function resolveOptions(InputInterface $input): array { $this->enabled = !$input->getOption('no-reset'); diff --git a/Processor/ExceptionCatcher/ExceptionCatcherProcessorConfigurator.php b/Processor/ExceptionCatcher/ExceptionCatcherProcessorConfigurator.php index c30a8a7..1b19fde 100644 --- a/Processor/ExceptionCatcher/ExceptionCatcherProcessorConfigurator.php +++ b/Processor/ExceptionCatcher/ExceptionCatcherProcessorConfigurator.php @@ -25,9 +25,6 @@ public function __construct(string $processorClass, LoggerInterface $logger) $this->logger = $logger; } - /** - * {@inheritdoc} - */ public function getProcessorArguments(array $options): array { return [ @@ -36,9 +33,6 @@ public function getProcessorArguments(array $options): array ]; } - /** - * {@inheritdoc} - */ public function getCommandOptions(): array { return [ @@ -46,9 +40,6 @@ public function getCommandOptions(): array ]; } - /** - * {@inheritdoc} - */ public function resolveOptions(InputInterface $input): array { $this->enabled = !$input->getOption('no-catch'); diff --git a/Processor/Insomniac/InsomniacProcessorConfigurator.php b/Processor/Insomniac/InsomniacProcessorConfigurator.php index 60d6e20..b816d3a 100644 --- a/Processor/Insomniac/InsomniacProcessorConfigurator.php +++ b/Processor/Insomniac/InsomniacProcessorConfigurator.php @@ -21,9 +21,6 @@ public function __construct(LoggerInterface $logger) $this->logger = $logger; } - /** - * {@inheritdoc} - */ public function getProcessorArguments(array $options): array { return [ @@ -32,17 +29,11 @@ public function getProcessorArguments(array $options): array ]; } - /** - * {@inheritdoc} - */ public function getCommandOptions(): array { return []; } - /** - * {@inheritdoc} - */ public function resolveOptions(InputInterface $input): array { return $this->getExtras(); diff --git a/Processor/InstantRetry/InstantRetryProcessorConfigurator.php b/Processor/InstantRetry/InstantRetryProcessorConfigurator.php index 55e744d..574b191 100644 --- a/Processor/InstantRetry/InstantRetryProcessorConfigurator.php +++ b/Processor/InstantRetry/InstantRetryProcessorConfigurator.php @@ -21,9 +21,6 @@ public function __construct(LoggerInterface $logger) $this->logger = $logger; } - /** - * {@inheritdoc} - */ public function getProcessorArguments(array $options): array { return [ @@ -32,17 +29,11 @@ public function getProcessorArguments(array $options): array ]; } - /** - * {@inheritdoc} - */ public function getCommandOptions(): array { return []; } - /** - * {@inheritdoc} - */ public function resolveOptions(InputInterface $input): array { return $this->getExtras(); diff --git a/Processor/MaxExecutionTime/MaxExecutionTimeProcessorConfigurator.php b/Processor/MaxExecutionTime/MaxExecutionTimeProcessorConfigurator.php index 1244fb7..96aa57f 100644 --- a/Processor/MaxExecutionTime/MaxExecutionTimeProcessorConfigurator.php +++ b/Processor/MaxExecutionTime/MaxExecutionTimeProcessorConfigurator.php @@ -25,9 +25,6 @@ public function __construct(string $processorClass, LoggerInterface $logger) $this->logger = $logger; } - /** - * {@inheritdoc} - */ public function getProcessorArguments(array $options): array { return [ @@ -36,9 +33,6 @@ public function getProcessorArguments(array $options): array ]; } - /** - * {@inheritdoc} - */ public function getCommandOptions(): array { return [ @@ -52,9 +46,6 @@ public function getCommandOptions(): array ]; } - /** - * {@inheritdoc} - */ public function resolveOptions(InputInterface $input): array { return [ diff --git a/Processor/MaxMessages/MaxMessagesProcessorConfigurator.php b/Processor/MaxMessages/MaxMessagesProcessorConfigurator.php index 27be14a..8a9cba2 100644 --- a/Processor/MaxMessages/MaxMessagesProcessorConfigurator.php +++ b/Processor/MaxMessages/MaxMessagesProcessorConfigurator.php @@ -25,9 +25,6 @@ public function __construct(string $processorClass, LoggerInterface $logger) $this->logger = $logger; } - /** - * {@inheritdoc} - */ public function getProcessorArguments(array $options): array { return [ @@ -36,9 +33,6 @@ public function getProcessorArguments(array $options): array ]; } - /** - * {@inheritdoc} - */ public function getCommandOptions(): array { return [ @@ -52,9 +46,6 @@ public function getCommandOptions(): array ]; } - /** - * {@inheritdoc} - */ public function resolveOptions(InputInterface $input): array { return [ diff --git a/Processor/MemoryLimit/MemoryLimitProcessorConfigurator.php b/Processor/MemoryLimit/MemoryLimitProcessorConfigurator.php index 7898469..9f6c576 100644 --- a/Processor/MemoryLimit/MemoryLimitProcessorConfigurator.php +++ b/Processor/MemoryLimit/MemoryLimitProcessorConfigurator.php @@ -21,9 +21,6 @@ public function __construct(LoggerInterface $logger) $this->logger = $logger; } - /** - * {@inheritdoc} - */ public function getProcessorArguments(array $options): array { return [ @@ -32,17 +29,11 @@ public function getProcessorArguments(array $options): array ]; } - /** - * {@inheritdoc} - */ public function getCommandOptions(): array { return []; } - /** - * {@inheritdoc} - */ public function resolveOptions(InputInterface $input): array { return $this->getExtras(); diff --git a/Processor/ProcessorConfiguratorExtrasAware.php b/Processor/ProcessorConfiguratorExtrasAware.php index 9b7b9b9..f06f511 100644 --- a/Processor/ProcessorConfiguratorExtrasAware.php +++ b/Processor/ProcessorConfiguratorExtrasAware.php @@ -17,11 +17,6 @@ public function getExtras(): array return $this->extras; } - /** - * @param mixed $default - * - * @return mixed - */ protected function getExtra(string $name, $default = null) { return isset($this->extras[$name]) ? $this->extras[$name] : $default; diff --git a/Processor/Retry/RetryProcessorConfigurator.php b/Processor/Retry/RetryProcessorConfigurator.php index 415528e..5ccb453 100644 --- a/Processor/Retry/RetryProcessorConfigurator.php +++ b/Processor/Retry/RetryProcessorConfigurator.php @@ -29,9 +29,6 @@ public function __construct(string $processorClass, FactoryInterface $factory, L $this->logger = $logger; } - /** - * {@inheritdoc} - */ public function getProcessorArguments(array $options): array { $exchange = $this->getExtra('retry_exchange', 'retry'); @@ -44,9 +41,6 @@ public function getProcessorArguments(array $options): array ]; } - /** - * {@inheritdoc} - */ public function getCommandOptions(): array { return [ @@ -61,9 +55,6 @@ public function getCommandOptions(): array ]; } - /** - * {@inheritdoc} - */ public function resolveOptions(InputInterface $input): array { $this->enabled = !$input->getOption('no-retry'); diff --git a/Processor/ServicesResetter/ServicesResetterProcessorConfigurator.php b/Processor/ServicesResetter/ServicesResetterProcessorConfigurator.php index e21921d..63e58d9 100644 --- a/Processor/ServicesResetter/ServicesResetterProcessorConfigurator.php +++ b/Processor/ServicesResetter/ServicesResetterProcessorConfigurator.php @@ -30,9 +30,6 @@ public function __construct(string $processorClass, ResetInterface $servicesRese $this->servicesResetter = $servicesResetter; } - /** - * {@inheritdoc} - */ public function getProcessorArguments(array $options): array { return [ @@ -41,9 +38,6 @@ public function getProcessorArguments(array $options): array ]; } - /** - * {@inheritdoc} - */ public function getCommandOptions(): array { return [ @@ -51,9 +45,6 @@ public function getCommandOptions(): array ]; } - /** - * {@inheritdoc} - */ public function resolveOptions(InputInterface $input): array { $this->enabled = !$input->getOption('no-reset'); diff --git a/Processor/SignalHandler/SignalHandlerProcessorConfigurator.php b/Processor/SignalHandler/SignalHandlerProcessorConfigurator.php index db015fc..66de290 100644 --- a/Processor/SignalHandler/SignalHandlerProcessorConfigurator.php +++ b/Processor/SignalHandler/SignalHandlerProcessorConfigurator.php @@ -24,9 +24,6 @@ public function __construct(string $processorClass, LoggerInterface $logger) $this->logger = $logger; } - /** - * {@inheritdoc} - */ public function getProcessorArguments(array $options): array { return [ @@ -35,17 +32,11 @@ public function getProcessorArguments(array $options): array ]; } - /** - * {@inheritdoc} - */ public function getCommandOptions(): array { return []; } - /** - * {@inheritdoc} - */ public function resolveOptions(InputInterface $input): array { return $this->getExtras(); From e3d107e2c7618e1bb6004b3dd4c9a3019d0162f7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Tue, 5 Dec 2023 10:35:10 +0100 Subject: [PATCH 5/8] Address coding standard issue --- Tests/Command/SwarrotCommandTest.php | 1 + 1 file changed, 1 insertion(+) diff --git a/Tests/Command/SwarrotCommandTest.php b/Tests/Command/SwarrotCommandTest.php index ead9d82..2aee89a 100644 --- a/Tests/Command/SwarrotCommandTest.php +++ b/Tests/Command/SwarrotCommandTest.php @@ -138,6 +138,7 @@ class TestFinalProcessor implements ProcessorInterface public function process(Message $message, array $options): bool { $this->processCallOptions = $options; + // return false to stop the consumer. return false; } From acb6a094c9ff272e30192d3a2a812ef76104e333 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Tue, 5 Dec 2023 10:57:36 +0100 Subject: [PATCH 6/8] Address more PHPStan issues --- Processor/Doctrine/ConnectionProcessorConfigurator.php | 5 +++++ Processor/ProcessorConfiguratorExtrasAware.php | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/Processor/Doctrine/ConnectionProcessorConfigurator.php b/Processor/Doctrine/ConnectionProcessorConfigurator.php index 6e79ddd..5698537 100644 --- a/Processor/Doctrine/ConnectionProcessorConfigurator.php +++ b/Processor/Doctrine/ConnectionProcessorConfigurator.php @@ -2,6 +2,7 @@ namespace Swarrot\SwarrotBundle\Processor\Doctrine; +use Doctrine\DBAL\Connection; use Swarrot\SwarrotBundle\Processor\ProcessorConfiguratorEnableAware; use Swarrot\SwarrotBundle\Processor\ProcessorConfiguratorExtrasAware; use Swarrot\SwarrotBundle\Processor\ProcessorConfiguratorInterface; @@ -15,8 +16,12 @@ class ConnectionProcessorConfigurator implements ProcessorConfiguratorInterface /** @var string */ private $processorClass; + /** @var list */ private $connections; + /** + * @param list $connections + */ public function __construct(string $processorClass, $connections) { $this->processorClass = $processorClass; diff --git a/Processor/ProcessorConfiguratorExtrasAware.php b/Processor/ProcessorConfiguratorExtrasAware.php index f06f511..9b7b9b9 100644 --- a/Processor/ProcessorConfiguratorExtrasAware.php +++ b/Processor/ProcessorConfiguratorExtrasAware.php @@ -17,6 +17,11 @@ public function getExtras(): array return $this->extras; } + /** + * @param mixed $default + * + * @return mixed + */ protected function getExtra(string $name, $default = null) { return isset($this->extras[$name]) ? $this->extras[$name] : $default; From edb8064ab70cd8e11b9a511458f28359cfac8166 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Tue, 5 Dec 2023 11:00:31 +0100 Subject: [PATCH 7/8] Avoid odolbeau/swarrot-phpqa It seems to run an ancient version of PHPStan. --- .github/workflows/static.yml | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/.github/workflows/static.yml b/.github/workflows/static.yml index 225508e..4c4ac8c 100644 --- a/.github/workflows/static.yml +++ b/.github/workflows/static.yml @@ -14,8 +14,17 @@ jobs: phpstan: runs-on: ubuntu-latest steps: - - uses: actions/checkout@master - - name: Run PHPStan - uses: docker://odolbeau/swarrot-phpqa:latest + - name: "Checkout code" + uses: "actions/checkout@master" + + - name: "Install PHP" + uses: "shivammathur/setup-php@v2" with: - args: phpstan analyze + coverage: "none" + php-version: "8.3" + + - name: "Install dependencies with Composer" + uses: "ramsey/composer-install@v2" + + - name: "Run a static analysis with phpstan/phpstan" + run: "vendor/bin/phpstan analyse" From d44635402ce53ee051ba036fd81a3287b1ca0b9c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Tue, 5 Dec 2023 11:08:37 +0100 Subject: [PATCH 8/8] Fine tune php-cs-fixer to allow mixed --- .php-cs-fixer.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.php-cs-fixer.php b/.php-cs-fixer.php index 4a6ac7a..4a7a273 100644 --- a/.php-cs-fixer.php +++ b/.php-cs-fixer.php @@ -13,6 +13,9 @@ ->setRules([ '@Symfony' => true, 'array_syntax' => ['syntax' => 'short'], + 'no_superfluous_phpdoc_tags' => [ + 'allow_mixed' => true, # PHPStan will complain about missing types otherwise + ], ]) ->setFinder($finder) ;