Skip to content

Commit 960109f

Browse files
authored
Merge pull request #23 from sts-gaming-group/dev
Merge dev to master
2 parents 76a5f8a + 005fad9 commit 960109f

File tree

6 files changed

+41
-40
lines changed

6 files changed

+41
-40
lines changed

composer.json

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,14 @@
1010
}
1111
],
1212
"require": {
13-
"php": ">=7.4",
13+
"php": ">=8.1.0",
1414
"ext-rdkafka": "*",
1515
"ext-json": "*",
16-
"symfony/config": "^4.3.3|^5.0|^6.0|^7.0",
17-
"symfony/dependency-injection": "^4.3.3|^5.2|^6.0|^7.0",
18-
"symfony/http-kernel": "^4.3|^5.2.1|^6.0|^7.0",
19-
"symfony/console": "^4.0|^5.2.0|^6.0|^7.0",
20-
"symfony/options-resolver": "~4.3|^5.2|^6.0|^7.0",
16+
"symfony/config": "^6.4|^7.0",
17+
"symfony/dependency-injection": "^6.4|^7.0",
18+
"symfony/http-kernel": "^6.4|^7.0",
19+
"symfony/console": "^6.4|^7.0",
20+
"symfony/options-resolver": "^6.4|^7.0",
2121
"flix-tech/avro-serde-php": "^2.0"
2222
},
2323
"autoload": {
@@ -31,14 +31,14 @@
3131
}
3232
},
3333
"require-dev": {
34-
"symfony/phpunit-bridge": "^5.2|^6.0|^7.0",
35-
"symfony/dotenv": "5.2.*|^6.0|^7.0",
34+
"symfony/phpunit-bridge": "^6.4|^7.0",
35+
"symfony/dotenv": "^6.4|^7.0",
3636
"phpstan/phpstan": "^0.12.75|^1.12",
3737
"phpstan/phpstan-symfony": "^0.12.18|^1.4",
3838
"phpstan/phpstan-phpunit": "^0.12.17|^1.4",
3939
"squizlabs/php_codesniffer": "^3.5",
4040
"phpstan/extension-installer": "^1.1",
41-
"symfony/framework-bundle": "^5.2|^6.0|^7.0",
42-
"symfony/event-dispatcher": "^5.2|^6.0|^7.0"
41+
"symfony/framework-bundle": "^6.4|^7.0",
42+
"symfony/event-dispatcher": "^6.4|^7.0"
4343
}
4444
}

src/Command/ConsumeCommand.php

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,22 @@
1111
use StsGamingGroup\KafkaBundle\Configuration\ConfigurationResolver;
1212
use StsGamingGroup\KafkaBundle\Configuration\RawConfiguration;
1313
use StsGamingGroup\KafkaBundle\Traits\AddConfigurationsToCommandTrait;
14+
use Symfony\Component\Console\Attribute\AsCommand;
1415
use Symfony\Component\Console\Command\Command;
1516
use Symfony\Component\Console\Input\InputArgument;
1617
use Symfony\Component\Console\Input\InputInterface;
1718
use Symfony\Component\Console\Input\InputOption;
1819
use Symfony\Component\Console\Output\OutputInterface;
1920

21+
#[AsCommand(
22+
name: 'kafka:consumers:consume',
23+
description: 'Starts consuming messages from kafka using class implementing '.ConsumerInterface::class
24+
)]
2025
class ConsumeCommand extends Command
2126
{
2227
use AddConfigurationsToCommandTrait;
2328
use DescribeTrait;
2429

25-
protected static $defaultName = 'kafka:consumers:consume';
26-
2730
private RawConfiguration $rawConfiguration;
2831
private ConsumerProvider $consumerProvider;
2932
private ConsumerClient $consumerClient;
@@ -45,14 +48,9 @@ public function __construct(
4548

4649
protected function configure(): void
4750
{
48-
$this->setDescription(
49-
sprintf(
50-
'Starts consuming messages from kafka using class implementing %s.',
51-
ConsumerInterface::class
52-
)
53-
)
54-
->addArgument('name', InputArgument::REQUIRED, 'Name of the registered consumer.')
55-
->addOption('describe', null, InputOption::VALUE_NONE, 'Describes consumer');
51+
$this
52+
->addArgument(name: 'name', mode: InputArgument::REQUIRED, description: 'Name of the registered consumer.')
53+
->addOption(name: 'describe', mode: InputOption::VALUE_NONE, description: 'Describes consumer');
5654

5755
$this->addConfigurations($this->rawConfiguration);
5856
}
@@ -64,11 +62,11 @@ protected function execute(InputInterface $input, OutputInterface $output): int
6462
if ($input->getOption('describe')) {
6563
$this->describe($this->configurationResolver->resolve($consumer, $input), $output, $consumer);
6664

67-
return 0;
65+
return self::SUCCESS;
6866
}
6967

7068
$this->consumerClient->consume($consumer, $input);
7169

72-
return 0;
70+
return self::SUCCESS;
7371
}
7472
}

src/Command/ConsumersDescribeCommand.php

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,20 @@
77
use StsGamingGroup\KafkaBundle\Client\Consumer\ConsumerProvider;
88
use StsGamingGroup\KafkaBundle\Command\Traits\DescribeTrait;
99
use StsGamingGroup\KafkaBundle\Configuration\ConfigurationResolver;
10+
use Symfony\Component\Console\Attribute\AsCommand;
1011
use Symfony\Component\Console\Command\Command;
1112
use Symfony\Component\Console\Input\InputInterface;
1213
use Symfony\Component\Console\Input\InputOption;
1314
use Symfony\Component\Console\Output\OutputInterface;
1415

16+
#[AsCommand(
17+
name: 'kafka:consumers:describe',
18+
description: 'Show consumers configuration.'
19+
)]
1520
class ConsumersDescribeCommand extends Command
1621
{
1722
use DescribeTrait;
1823

19-
protected static $defaultName = 'kafka:consumers:describe';
20-
2124
private ConsumerProvider $consumerProvider;
2225
private ConfigurationResolver $configurationResolver;
2326

@@ -33,9 +36,11 @@ public function __construct(
3336

3437
protected function configure(): void
3538
{
36-
$this
37-
->setDescription('Show consumers configuration.')
38-
->addOption('name', null, InputOption::VALUE_REQUIRED, 'Shows specific consumer configuration.');
39+
$this->addOption(
40+
name: 'name',
41+
mode: InputOption::VALUE_REQUIRED,
42+
description: 'Shows specific consumer configuration.'
43+
);
3944
}
4045

4146
protected function execute(InputInterface $input, OutputInterface $output): int
@@ -47,6 +52,6 @@ protected function execute(InputInterface $input, OutputInterface $output): int
4752
$this->describe($this->configurationResolver->resolve($consumer), $output, $consumer);
4853
}
4954

50-
return 0;
55+
return self::SUCCESS;
5156
}
5257
}

src/Command/ProducersDescribeCommand.php

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,19 @@
77
use StsGamingGroup\KafkaBundle\Client\Producer\ProducerProvider;
88
use StsGamingGroup\KafkaBundle\Command\Traits\DescribeTrait;
99
use StsGamingGroup\KafkaBundle\Configuration\ConfigurationResolver;
10+
use Symfony\Component\Console\Attribute\AsCommand;
1011
use Symfony\Component\Console\Command\Command;
1112
use Symfony\Component\Console\Input\InputInterface;
1213
use Symfony\Component\Console\Output\OutputInterface;
1314

15+
#[AsCommand(
16+
name: 'kafka:producers:describe',
17+
description: 'Show producers configuration.'
18+
)]
1419
class ProducersDescribeCommand extends Command
1520
{
1621
use DescribeTrait;
1722

18-
protected static $defaultName = 'kafka:producers:describe';
19-
2023
private ProducerProvider $producerProvider;
2124
private ConfigurationResolver $configurationResolver;
2225

@@ -30,11 +33,6 @@ public function __construct(
3033
parent::__construct();
3134
}
3235

33-
protected function configure(): void
34-
{
35-
$this->setDescription('Show producers configuration.');
36-
}
37-
3836
protected function execute(InputInterface $input, OutputInterface $output): int
3937
{
4038
$producers = $this->producerProvider->getProducers();
@@ -43,6 +41,6 @@ protected function execute(InputInterface $input, OutputInterface $output): int
4341
$this->describe($this->configurationResolver->resolve($producer), $output, $producer);
4442
}
4543

46-
return 0;
44+
return self::SUCCESS;
4745
}
4846
}

tests/Unit/Client/Consumer/ConsumerProviderTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public function testMultipleConsumersFound(): void
4747
->addConsumer($this->consumerTwo);
4848

4949
$this->expectException(InvalidConsumerException::class);
50-
$this->expectErrorMessageMatches('/Multiple consumers/');
50+
$this->expectExceptionMessageMatches('/Multiple consumers/');
5151
$this->consumerProvider->provide('consumer_2');
5252
}
5353

@@ -62,7 +62,7 @@ public function testNoConsumerFound(): void
6262
->addConsumer($this->consumerTwo);
6363

6464
$this->expectException(InvalidConsumerException::class);
65-
$this->expectErrorMessageMatches('/no matching consumer/');
65+
$this->expectExceptionMessageMatches('/no matching consumer/');
6666
$this->consumerProvider->provide('consumer_3');
6767
}
6868
}

tests/Unit/Configuration/ConfigurationResolverTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ public function testInputValueInvalid(): void
157157
$resolver = new ConfigurationResolver($rawConfiguration, $this->yamlConfig);
158158

159159
$this->expectException(InvalidConfigurationException::class);
160-
$this->expectDeprecationMessageMatches('/configuration_one/');
160+
$this->expectExceptionMessageMatches('/configuration_one/');
161161

162162
$resolver->resolve(DummyConsumerOne::class, $this->input);
163163
}
@@ -205,7 +205,7 @@ public function testYamlConfigInvalid(): void
205205
$resolver = new ConfigurationResolver($rawConfiguration, $this->yamlConfig);
206206

207207
$this->expectException(InvalidConfigurationException::class);
208-
$this->expectDeprecationMessageMatches('/group_id/');
208+
$this->expectExceptionMessageMatches('/group_id/');
209209

210210
$resolver->resolve(DummyConsumerOne::class);
211211
}

0 commit comments

Comments
 (0)