Skip to content

Commit 5de652b

Browse files
dradisicbajdzun
andauthored
feat(CDA-1558): upgrade to PHP 8.4 with syntax and replace PECL with PIE (#31)
* feat(CDA-1558): upgrade to PHP 8.4 with syntax and replace PECL with PIE * chore(CDA-1558): update PHP image, pie and composer versions in Dockerfile * Remove .gitkeep * chore(CDA-1558): update infection dependency --------- Co-authored-by: Marko <marko.jovanovic@jobcloud.ch>
1 parent 80fe7ef commit 5de652b

19 files changed

Lines changed: 198 additions & 251 deletions

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,4 @@ composer.lock
88
# Builds & caches
99
/build/
1010
.phpunit.result.cache
11+
.phpunit.cache

Makefile

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
.PHONY: clean code-style coverage help test test-unit test-integration static-analysis infection-testing install-dependencies update-dependencies
1+
.PHONY: clean code-style coverage help test test-unit static-analysis infection-testing install-dependencies update-dependencies
22
.DEFAULT_GOAL := test
33

44
PHPUNIT = ./vendor/bin/phpunit -c ./phpunit.xml
55
PHPSTAN = ./vendor/bin/phpstan --no-progress
6-
PHPCS = ./vendor/bin/phpcs --extensions=php -v
6+
PHPCS = ./vendor/bin/phpcs --extensions=php
77
PHPCBF = ./vendor/bin/phpcbf
88
INFECTION = ./vendor/bin/infection
9-
COVCHK = ./vendor/bin/coverage-check
9+
COVCHK = ./vendor/bin/coverage-check
1010

1111
clean:
1212
rm -rf ./build ./vendor
@@ -27,9 +27,6 @@ test:
2727
test-unit:
2828
${PHPUNIT} --testsuite=Unit
2929

30-
test-integration:
31-
${PHPUNIT} --testsuite=Integration
32-
3330
static-analysis:
3431
mkdir -p build/logs/phpstan
3532
${PHPSTAN} analyse
@@ -51,14 +48,13 @@ help:
5148
# make <target> [OPTION=value]
5249
#
5350
# Targets:
54-
# clean Cleans the coverage and the vendor directory
55-
# code-style Check codestyle using phpcs
56-
# coverage Generate code coverage (html, clover)
57-
# help You're looking at it!
58-
# test (default) Run all the tests with phpunit
59-
# test-unit Run all the tests with phpunit
60-
# test-integration Run all the tests with phpunit
61-
# static-analysis Run static analysis using phpstan
62-
# infection-testing Run infection/mutation testing
63-
# install-dependencies Run composerupdate
51+
# clean Cleans the coverage and the vendor directory
52+
# code-style Check code style using phpcs
53+
# coverage Generate code coverage (html, clover)
54+
# help You're looking at it!
55+
# test (default) Run all the tests with phpunit
56+
# test-unit Run all the tests with phpunit
57+
# static-analysis Run static analysis using phpstan
58+
# infection-testing Run infection/mutation testing
59+
# install-dependencies Run composer install
6460
# update-dependencies Run composer update

composer.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,21 +20,21 @@
2020
}
2121
],
2222
"require": {
23-
"php": "^8.0",
23+
"php": "^8.4",
2424
"ext-json": "*",
2525
"psr/http-client": "^1.0.1",
2626
"psr/http-message": "^1.0.1 || ^2.0.0"
2727
},
2828
"require-dev": {
29-
"infection/infection": "^0.26.6",
29+
"infection/infection": "^0.32",
3030
"kriswallsmith/buzz": "^1.2.1",
3131
"nyholm/psr7": "^1.5.1",
3232
"php-mock/php-mock-phpunit": "^2.6.0",
33-
"phpstan/phpstan": "^1.7.15",
34-
"phpunit/phpunit": "^9.5.21",
33+
"phpstan/phpstan": "^2.1",
34+
"phpunit/phpunit": "^12.5",
3535
"pimple/pimple": "^3.5.0",
3636
"rregeer/phpunit-coverage-check": "^0.3.1",
37-
"squizlabs/php_codesniffer": "^3.7.1"
37+
"squizlabs/php_codesniffer": "^4.0"
3838
},
3939
"config": {
4040
"sort-packages": true,

docker/dev/php/Dockerfile

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
1-
FROM php:8.1-cli-alpine3.17
1+
FROM public.ecr.aws/docker/library/php:8.4-cli-alpine3.23
2+
3+
# PIE: Install PIE binary
4+
COPY --from=ghcr.io/php/pie:1.3.1-bin /pie /usr/bin/pie
5+
6+
# COMPOSER: install binary
7+
COPY --from=composer:2.9 /usr/bin/composer /usr/bin/composer
28

39
ARG USER_ID
410

@@ -9,6 +15,9 @@ COPY files/php /phpIni
915
RUN apk --no-cache upgrade && \
1016
apk --no-cache add bash git sudo autoconf gcc g++ make make shadow
1117

18+
# PIE: Install PECL extensions
19+
RUN pie install pecl/pcov
20+
1221
# Set host user id if given, to avoid permission conflicts in dev
1322
RUN if [ -n "$USER_ID" ] && [ "$USER_ID" -lt 60001 ]; then \
1423
usermod -u ${USER_ID} -o www-data; \
@@ -20,14 +29,6 @@ RUN usermod -s /bin/bash www-data && \
2029
# USER: copy home
2130
COPY --chown=www-data:www-data files/user-home /home/www-data
2231

23-
# PHP: Install php extensions
24-
RUN pecl channel-update pecl.php.net && \
25-
pecl install pcov && \
26-
php-ext-enable pcov
27-
28-
# COMPOSER: install binary
29-
COPY --from=composer:2.6 /usr/bin/composer /usr/bin/composer
30-
3132
USER www-data
3233

3334
WORKDIR /var/www/html

docker/docker-compose.ci.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
version: '3.2'
2-
31
services:
42
php:
53
hostname: kafka-schema-registry-client-php

docker/docker-compose.dev.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
version: '3.2'
2-
31
services:
42
php:
53
hostname: kafka-schema-registry-client-php

phpcs.xml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,16 @@
11
<?xml version="1.0"?>
2-
<ruleset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="PHP_CodeSniffer" xsi:noNamespaceSchemaLocation="phpcs.xsd">
2+
<ruleset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
name="PHP_CodeSniffer"
4+
xsi:noNamespaceSchemaLocation="https://schema.phpcodesniffer.com/4.0/phpcs.xsd">
35
<file>src</file>
46
<file>tests</file>
57
<rule ref="PSR12"/>
8+
9+
<arg name="encoding" value="UTF-8"/>
10+
<arg name="basepath" value="."/>
11+
<arg name="extensions" value="php"/>
12+
<arg name="colors"/>
13+
<arg value="p"/>
614
<arg name="report-gitblame"/>
715
<arg name="report-full"/>
816
<arg name="report-junit" value="./build/logs/phpcs/junit.xml"/>

phpstan.neon

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
parameters:
2-
paths:
3-
- src
4-
level: 8
2+
level: 8
3+
paths: [ src ]

phpunit.xml

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,16 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3-
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd"
3+
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/12.5/phpunit.xsd"
44
backupGlobals="false"
5-
backupStaticAttributes="false"
5+
backupStaticProperties="false"
66
colors="true"
7-
convertErrorsToExceptions="true"
8-
convertNoticesToExceptions="true"
9-
convertWarningsToExceptions="true"
107
processIsolation="false"
118
stopOnFailure="false"
129
bootstrap="vendor/autoload.php"
1310
executionOrder="random"
14-
resolveDependencies="true">
11+
resolveDependencies="true"
12+
cacheDirectory=".phpunit.cache">
1513
<coverage>
16-
<include>
17-
<directory>src</directory>
18-
</include>
1914
<report>
2015
<clover outputFile="build/logs/phpunit/coverage/coverage.xml"/>
2116
<html outputDirectory="build/logs/phpunit/coverage"/>
@@ -39,4 +34,9 @@
3934
<logging>
4035
<junit outputFile="build/logs/phpunit/junit.xml"/>
4136
</logging>
37+
<source>
38+
<include>
39+
<directory>src</directory>
40+
</include>
41+
</source>
4242
</phpunit>

src/HttpClient.php

Lines changed: 7 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -11,50 +11,14 @@
1111

1212
class HttpClient implements HttpClientInterface
1313
{
14-
/**
15-
* @var ClientInterface
16-
*/
17-
private $client;
18-
19-
/**
20-
* @var string
21-
*/
22-
private $baseUrl;
23-
24-
/**
25-
* @var string|null
26-
*/
27-
private $username;
28-
29-
/**
30-
* @var string|null
31-
*/
32-
private $password;
33-
34-
/**
35-
* @var RequestFactoryInterface
36-
*/
37-
private $requestFactory;
38-
39-
/**
40-
* @var ErrorHandlerInterface
41-
*/
42-
private $errorHandler;
43-
4414
public function __construct(
45-
ClientInterface $client,
46-
RequestFactoryInterface $requestFactory,
47-
ErrorHandlerInterface $errorHandler,
48-
string $baseUrl,
49-
?string $username = null,
50-
?string $password = null
15+
private readonly ClientInterface $client,
16+
private readonly RequestFactoryInterface $requestFactory,
17+
private readonly ErrorHandlerInterface $errorHandler,
18+
private readonly string $baseUrl,
19+
private readonly ?string $username = null,
20+
private readonly ?string $password = null
5121
) {
52-
$this->client = $client;
53-
$this->baseUrl = $baseUrl;
54-
$this->username = $username;
55-
$this->password = $password;
56-
$this->requestFactory = $requestFactory;
57-
$this->errorHandler = $errorHandler;
5822
}
5923

6024
/**
@@ -98,12 +62,11 @@ private function createRequest(
9862
/**
9963
* @param array<string,mixed> $body
10064
* @param array<string,mixed> $queryParams
101-
* @return mixed
10265
* @throws ClientExceptionInterface
10366
* @throws SchemaRegistryExceptionInterface
10467
* @throws JsonException
10568
*/
106-
public function call(string $method, string $uri, array $body = [], array $queryParams = [])
69+
public function call(string $method, string $uri, array $body = [], array $queryParams = []): mixed
10770
{
10871
$request = $this->createRequest($method, $uri, $body, $queryParams);
10972

0 commit comments

Comments
 (0)