Skip to content

Commit

Permalink
Merge pull request #227 from greg0ire/address-latest-phpstan
Browse files Browse the repository at this point in the history
Address issues with more recent PHPStan versions
  • Loading branch information
metfan authored Dec 12, 2023
2 parents 8ce754f + d446354 commit 81fb4cf
Show file tree
Hide file tree
Showing 26 changed files with 41 additions and 165 deletions.
17 changes: 13 additions & 4 deletions .github/workflows/static.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
4 changes: 3 additions & 1 deletion .github/workflows/unit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
vendor/
bin/phpunit
.phpunit.result.cache
composer.lock
bin/doctrine-dbal
3 changes: 3 additions & 0 deletions .php-cs-fixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)
;
Expand Down
9 changes: 0 additions & 9 deletions Broker/AmqpLibFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'])) {
Expand All @@ -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])) {
Expand All @@ -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])) {
Expand Down
3 changes: 0 additions & 3 deletions Broker/BlackholePublisher.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@

class BlackholePublisher extends Publisher
{
/**
* {@inheritdoc}
*/
public function publish(string $messageType, Message $message, array $overridenConfig = []): void
{
}
Expand Down
9 changes: 0 additions & 9 deletions Broker/PeclFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'])) {
Expand All @@ -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])) {
Expand All @@ -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])) {
Expand Down
6 changes: 0 additions & 6 deletions Command/SwarrotCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -98,9 +95,6 @@ protected function configure(): void
}
}

/**
* {@inheritdoc}
*/
protected function execute(InputInterface $input, OutputInterface $output): int
{
$options = $this->getOptions($input);
Expand Down
5 changes: 0 additions & 5 deletions DataCollector/SwarrotDataCollector.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@
class SwarrotDataCollector extends DataCollector
{
/**
* {@inheritdoc}
*
* @param \Throwable|\Exception $exception
*/
public function collect(Request $request, Response $response, \Throwable $exception = null): void
Expand Down Expand Up @@ -43,9 +41,6 @@ public function getNbMessages(): int
return count($this->data);
}

/**
* {@inheritdoc}
*/
public function getName(): string
{
return 'swarrot';
Expand Down
9 changes: 5 additions & 4 deletions DependencyInjection/Compiler/ProviderCompilerPass.php
Original file line number Diff line number Diff line change
Expand Up @@ -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')) {
Expand All @@ -28,14 +25,18 @@ public function process(ContainerBuilder $container): void
}
}

list($provider, $connections) = $container->getParameter('swarrot.provider_config');
/** @var array{string, array<string, mixed>} $providerConfig */
$providerConfig = $container->getParameter('swarrot.provider_config');
list($provider, $connections) = $providerConfig;

if (!isset($providersIds[$provider])) {
throw new \InvalidArgumentException(sprintf('Invalid provider "%s"', $provider));
}

$id = $providersIds[$provider];
$definition = $container->getDefinition($id);

/** @var class-string $className */
$className = $container->getParameterBag()->resolveValue($definition->getClass());

$reflection = new \ReflectionClass($className);
Expand Down
3 changes: 0 additions & 3 deletions DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,6 @@ public function __construct(bool $debug)
$this->debug = $debug;
}

/**
* {@inheritdoc}
*/
public function getConfigTreeBuilder(): TreeBuilder
{
$treeBuilder = new TreeBuilder('swarrot');
Expand Down
6 changes: 0 additions & 6 deletions DependencyInjection/SwarrotExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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'));
Expand Down
9 changes: 0 additions & 9 deletions Processor/Ack/AckProcessorConfigurator.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,6 @@ public function __construct(string $processorClass, FactoryInterface $factory, L
$this->logger = $logger;
}

/**
* {@inheritdoc}
*/
public function getProcessorArguments(array $options): array
{
return [
Expand All @@ -41,9 +38,6 @@ public function getProcessorArguments(array $options): array
];
}

/**
* {@inheritdoc}
*/
public function getCommandOptions(): array
{
return [
Expand All @@ -52,9 +46,6 @@ public function getCommandOptions(): array
];
}

/**
* {@inheritdoc}
*/
public function resolveOptions(InputInterface $input): array
{
$this->enabled = !$input->getOption('no-ack');
Expand Down
15 changes: 4 additions & 11 deletions Processor/Doctrine/ConnectionProcessorConfigurator.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -14,21 +15,19 @@ class ConnectionProcessorConfigurator implements ProcessorConfiguratorInterface

/** @var string */
private $processorClass;
/** @var mixed */

/** @var list<Connection> */
private $connections;

/**
* @param mixed $connections
* @param list<Connection> $connections
*/
public function __construct(string $processorClass, $connections)
{
$this->processorClass = $processorClass;
$this->connections = $connections;
}

/**
* {@inheritdoc}
*/
public function getProcessorArguments(array $options): array
{
return [
Expand All @@ -37,17 +36,11 @@ public function getProcessorArguments(array $options): array
];
}

/**
* {@inheritdoc}
*/
public function getCommandOptions(): array
{
return [];
}

/**
* {@inheritdoc}
*/
public function resolveOptions(InputInterface $input): array
{
return $this->getExtras();
Expand Down
11 changes: 1 addition & 10 deletions Processor/Doctrine/ObjectManagerProcessorConfigurator.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class ObjectManagerProcessorConfigurator implements ProcessorConfiguratorInterfa

/** @var string */
private $processorClass;
/** @var mixed */

private $managerRegistry;

public function __construct(string $processorClass, ManagerRegistry $managerRegistry)
Expand All @@ -25,9 +25,6 @@ public function __construct(string $processorClass, ManagerRegistry $managerRegi
$this->managerRegistry = $managerRegistry;
}

/**
* {@inheritdoc}
*/
public function getProcessorArguments(array $options): array
{
return [
Expand All @@ -36,19 +33,13 @@ public function getProcessorArguments(array $options): array
];
}

/**
* {@inheritdoc}
*/
public function getCommandOptions(): array
{
return [
['no-reset', null, InputOption::VALUE_NONE, 'Deactivate object manager reset after processing.'],
];
}

/**
* {@inheritdoc}
*/
public function resolveOptions(InputInterface $input): array
{
$this->enabled = !$input->getOption('no-reset');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,6 @@ public function __construct(string $processorClass, LoggerInterface $logger)
$this->logger = $logger;
}

/**
* {@inheritdoc}
*/
public function getProcessorArguments(array $options): array
{
return [
Expand All @@ -36,19 +33,13 @@ public function getProcessorArguments(array $options): array
];
}

/**
* {@inheritdoc}
*/
public function getCommandOptions(): array
{
return [
['no-catch', 'C', InputOption::VALUE_NONE, 'Deactivate exception catching.'],
];
}

/**
* {@inheritdoc}
*/
public function resolveOptions(InputInterface $input): array
{
$this->enabled = !$input->getOption('no-catch');
Expand Down
9 changes: 0 additions & 9 deletions Processor/Insomniac/InsomniacProcessorConfigurator.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,6 @@ public function __construct(LoggerInterface $logger)
$this->logger = $logger;
}

/**
* {@inheritdoc}
*/
public function getProcessorArguments(array $options): array
{
return [
Expand All @@ -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();
Expand Down
Loading

0 comments on commit 81fb4cf

Please sign in to comment.