Skip to content

feat(MPM-708/): drop php7.4 support #75

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 3 commits into from
Dec 30, 2022
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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ The [documentation](https://arnaud.le-blanc.net/php-rdkafka/phpdoc/book.rdkafka.
can help out to understand the internals of this library.

## Requirements
- php: ^7.3|^8.0
- php: ^8.0
- ext-rdkafka: >=4.0.0
- librdkafka: >=0.11.6 (if you use `<librdkafka:1.x` please define your own error callback)

Expand Down
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,20 @@
"rdkafka"
],
"require": {
"php": "^7.3|^8.0",
"php": "^8.0",
"ext-rdkafka": "^4.0|^5.0|^6.0",
"ext-json": "*"
},
"require-dev": {
"phpunit/phpunit": "^9.4",
"squizlabs/php_codesniffer": "^3.5.4",
"phpstan/phpstan": "^0.12",
"phpstan/phpstan": "^1.8",
"php-mock/php-mock-phpunit": "^2.6",
"kwn/php-rdkafka-stubs": "^2.0.0",
"rregeer/phpunit-coverage-check": "^0.3.1",
"johnkary/phpunit-speedtrap": "^3.1",
"flix-tech/avro-serde-php": "^1.4",
"infection/infection": "^0.22"
"infection/infection": "^0.26"
},
"autoload": {
"psr-4": {
Expand Down
4 changes: 2 additions & 2 deletions docker/dev/php/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM php:7.4-cli-alpine3.16
FROM php:8.0-cli-alpine3.16

ARG HOST_USER_ID
ARG HOST_USER
Expand Down Expand Up @@ -28,7 +28,7 @@ RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/bin -

# PHP: Install php extensions
RUN pecl channel-update pecl.php.net && \
pecl install rdkafka-6.0.1 pcov && \
pecl install rdkafka-6.0.3 pcov && \
docker-php-ext-install pcntl && \
php-ext-enable rdkafka pcntl pcov

Expand Down
4 changes: 2 additions & 2 deletions src/Message/AbstractKafkaMessage.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ abstract class AbstractKafkaMessage implements KafkaMessageInterface
protected $partition;

/**
* @var string[]|null
* @var array<string, int|string>|null
*/
protected $headers;

Expand Down Expand Up @@ -64,7 +64,7 @@ public function getPartition(): int
}

/**
* @return string[]|null
* @return array<string, int|string>|null
*/
public function getHeaders(): ?array
{
Expand Down
14 changes: 11 additions & 3 deletions tests/Unit/Conf/KafkaConfigurationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,6 @@ public function configValuesProvider(): array
[ -0.99999, '-0.99999' ],
[ true, 'true' ],
[ false, 'false' ],
[ null, '' ],
[ '', '' ],
[ ' ', ' ' ],
[ [], null ],
[ new stdClass(), null ],
Expand All @@ -104,7 +102,7 @@ public function testConfigValues($inputValue, $expectedValue): void

$config = $kafkaConfiguration->getConfiguration();

if(null === $expectedValue) {
if (null === $expectedValue) {
self::assertArrayNotHasKey('group.id', $config);
return;
}
Expand All @@ -115,4 +113,14 @@ public function testConfigValues($inputValue, $expectedValue): void
self::assertArrayHasKey('default_topic_conf', $config);
self::assertIsString($config['default_topic_conf']);
}

public function testMethodVisibility(): void
{
$reflectionClass = new \ReflectionClass(KafkaConfiguration::class);

$methodInitializedConfig = $reflectionClass->getMethod('initializeConfig');
$methodInitializedConfig->setAccessible(true);

$this->assertTrue($methodInitializedConfig->isProtected());
}
}
16 changes: 14 additions & 2 deletions tests/Unit/Consumer/KafkaHighLevelConsumerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Jobcloud\Kafka\Tests\Unit\Kafka\Consumer;

use Jobcloud\Kafka\Consumer\AbstractKafkaConsumer;
use Jobcloud\Kafka\Consumer\KafkaHighLevelConsumer;
use Jobcloud\Kafka\Consumer\TopicSubscriptionInterface;
use Jobcloud\Kafka\Exception\KafkaConsumerConsumeException;
Expand Down Expand Up @@ -465,7 +466,7 @@ public function testKafkaConsumeWithDecode(): void
$message->partition = '9';
$message->offset = '501';
$message->timestamp = '500';
$message->headers = 'header';
$message->headers = ['key' => 'value'];
$message->err = RD_KAFKA_RESP_ERR_NO_ERROR;

$topics = [new TopicSubscription('testTopic')];
Expand All @@ -491,7 +492,7 @@ function (KafkaConsumerMessageInterface $message) {
self::assertEquals(9, $message->getPartition());
self::assertEquals(501, $message->getOffset());
self::assertEquals(500, $message->getTimestamp());
self::assertEquals(['header'], $message->getHeaders());
self::assertEquals(['key' => 'value'], $message->getHeaders());

return true;
}
Expand All @@ -512,6 +513,7 @@ public function testKafkaConsumeWithoutDecode(): void
$message->partition = 9;
$message->offset = 501;
$message->timestamp = 500;
$message->headers = ['key' => 'value'];
$message->err = RD_KAFKA_RESP_ERR_NO_ERROR;

$topics = [new TopicSubscription('testTopic')];
Expand Down Expand Up @@ -663,6 +665,16 @@ public function testGetTopicSubscriptionsReturnsTopicSubscriptions(): void
self::assertSame($topicSubscriptionsMock, $kafkaConsumer->getTopicSubscriptions());
}

public function testMethodVisibility(): void
{
$reflectionClass = new \ReflectionClass(AbstractKafkaConsumer::class);

$methodGetConsumerMessage = $reflectionClass->getMethod('getConsumerMessage');
$methodGetConsumerMessage->setAccessible(true);

$this->assertTrue($methodGetConsumerMessage->isProtected());
}

/**
* @param int $partitionId
* @return RdKafkaMetadataPartition|MockObject
Expand Down
3 changes: 2 additions & 1 deletion tests/Unit/Consumer/KafkaLowLevelConsumerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public function testConsumeWithTopicSubscriptionWithNoPartitionsIsSuccessful():
$rdKafkaMessageMock->partition = 0;
$rdKafkaMessageMock->offset = 1;
$rdKafkaMessageMock->timestamp = 1;
$rdKafkaMessageMock->headers = null;
$rdKafkaMessageMock->headers = ['key' => 'value'];
$rdKafkaMessageMock
->expects(self::never())
->method('errstr');
Expand Down Expand Up @@ -250,6 +250,7 @@ public function testConsumeThrowsExceptionIfConsumedMessageHasNoTopicAndErrorCod
$rdKafkaMessageMock->partition = 1;
$rdKafkaMessageMock->offset = 103;
$rdKafkaMessageMock->topic_name = null;
$rdKafkaMessageMock->headers = [];
$rdKafkaMessageMock
->expects(self::once())
->method('errstr')
Expand Down
4 changes: 1 addition & 3 deletions tests/Unit/Message/Encoder/AvroEncoderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,11 @@

use FlixTech\AvroSerializer\Objects\RecordSerializer;
use Jobcloud\Kafka\Exception\AvroEncoderException;
use Jobcloud\Kafka\Message\Encoder\AvroEncoderInterface;
use Jobcloud\Kafka\Message\KafkaAvroSchemaInterface;
use Jobcloud\Kafka\Message\KafkaProducerMessageInterface;
use Jobcloud\Kafka\Message\Encoder\AvroEncoder;
use Jobcloud\Kafka\Message\Registry\AvroSchemaRegistryInterface;
use PHPStan\Testing\TestCase;
use \AvroSchema;
use PHPUnit\Framework\TestCase;

/**
* @covers \Jobcloud\Kafka\Message\Encoder\AvroEncoder
Expand Down