From 6bdec7cc19a0b1bc6c41aa0407aed9362f46a72b Mon Sep 17 00:00:00 2001 From: Graham Campbell Date: Fri, 7 Feb 2025 18:27:19 +0000 Subject: [PATCH 1/4] PHP 8.4 support (#57) Signed-off-by: Graham Campbell --- .github/workflows/static.yml | 6 +++--- .github/workflows/tests.yml | 6 +++--- composer.json | 2 +- psalm-baseline.xml | 9 +++++++++ psalm.xml.dist | 3 +++ src/Exceptions/InvalidAttributeException.php | 4 ++-- src/Exceptions/InvalidPayloadSyntaxException.php | 4 ++-- src/Exceptions/MissingAttributeException.php | 4 ++-- src/Exceptions/UnsupportedContentTypeException.php | 4 ++-- src/Exceptions/UnsupportedSpecVersionException.php | 4 ++-- src/Http/Marshaller.php | 6 +++--- 11 files changed, 32 insertions(+), 20 deletions(-) create mode 100644 psalm-baseline.xml diff --git a/.github/workflows/static.yml b/.github/workflows/static.yml index 4f22379..9d5539c 100644 --- a/.github/workflows/static.yml +++ b/.github/workflows/static.yml @@ -8,7 +8,7 @@ on: jobs: codesniffer: name: PHP CodeSniffer - runs-on: ubuntu-22.04 + runs-on: ubuntu-24.04 steps: - name: Checkout code @@ -24,7 +24,7 @@ jobs: update: true - name: Install Dependencies - uses: nick-invision/retry@v2 + uses: nick-invision/retry@v3 with: timeout_minutes: 5 max_attempts: 5 @@ -51,7 +51,7 @@ jobs: update: true - name: Install Dependencies - uses: nick-invision/retry@v2 + uses: nick-invision/retry@v3 with: timeout_minutes: 5 max_attempts: 5 diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 5e2e15f..0183705 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -8,11 +8,11 @@ on: jobs: tests: name: PHP ${{ matrix.php }} - runs-on: ubuntu-22.04 + runs-on: ubuntu-24.04 strategy: matrix: - php: ['7.4', '8.0', '8.1', '8.2', '8.3'] + php: ['7.4', '8.0', '8.1', '8.2', '8.3', '8.4'] steps: - name: Checkout Code @@ -31,7 +31,7 @@ jobs: run: echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json" - name: Install Dependencies - uses: nick-invision/retry@v2 + uses: nick-invision/retry@v3 with: timeout_minutes: 5 max_attempts: 5 diff --git a/composer.json b/composer.json index cba6b96..658dce4 100644 --- a/composer.json +++ b/composer.json @@ -27,7 +27,7 @@ "guzzlehttp/psr7": "^2.4.3", "php-http/discovery": "^1.15.2", "phpunit/phpunit": "^9.6.3 || ^10.0.12", - "psalm/phar": "5.7.6", + "psalm/phar": "5.26.1", "psr/http-factory": "^1.0.1", "psr/http-message": "^1.0.1", "squizlabs/php_codesniffer": "3.7.2" diff --git a/psalm-baseline.xml b/psalm-baseline.xml new file mode 100644 index 0000000..253f2ed --- /dev/null +++ b/psalm-baseline.xml @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/psalm.xml.dist b/psalm.xml.dist index db645bc..7ee17a8 100644 --- a/psalm.xml.dist +++ b/psalm.xml.dist @@ -5,6 +5,9 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="https://getpsalm.org/schema/config" xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd" + errorBaseline="psalm-baseline.xml" + findUnusedBaselineEntry="true" + findUnusedCode="false" > diff --git a/src/Exceptions/InvalidAttributeException.php b/src/Exceptions/InvalidAttributeException.php index f8f9cac..65efd92 100644 --- a/src/Exceptions/InvalidAttributeException.php +++ b/src/Exceptions/InvalidAttributeException.php @@ -10,9 +10,9 @@ class InvalidAttributeException extends Exception { public function __construct( - string $message = null, + ?string $message = null, int $code = 0, - Throwable $previous = null + ?Throwable $previous = null ) { parent::__construct($message ?? 'Invalid CloudEvent attribute.', $code, $previous); } diff --git a/src/Exceptions/InvalidPayloadSyntaxException.php b/src/Exceptions/InvalidPayloadSyntaxException.php index 970f1c8..9a7ed8f 100644 --- a/src/Exceptions/InvalidPayloadSyntaxException.php +++ b/src/Exceptions/InvalidPayloadSyntaxException.php @@ -10,9 +10,9 @@ class InvalidPayloadSyntaxException extends Exception { public function __construct( - string $message = null, + ?string $message = null, int $code = 0, - Throwable $previous = null + ?Throwable $previous = null ) { parent::__construct($message ?? 'Invalid CloudEvent payload syntax.', $code, $previous); } diff --git a/src/Exceptions/MissingAttributeException.php b/src/Exceptions/MissingAttributeException.php index 7118561..43e8668 100644 --- a/src/Exceptions/MissingAttributeException.php +++ b/src/Exceptions/MissingAttributeException.php @@ -10,9 +10,9 @@ class MissingAttributeException extends Exception { public function __construct( - string $message = null, + ?string $message = null, int $code = 0, - Throwable $previous = null + ?Throwable $previous = null ) { parent::__construct($message ?? 'Missing CloudEvent attribute.', $code, $previous); } diff --git a/src/Exceptions/UnsupportedContentTypeException.php b/src/Exceptions/UnsupportedContentTypeException.php index 0ed9493..bf8fd8c 100644 --- a/src/Exceptions/UnsupportedContentTypeException.php +++ b/src/Exceptions/UnsupportedContentTypeException.php @@ -10,9 +10,9 @@ class UnsupportedContentTypeException extends Exception { public function __construct( - string $message = null, + ?string $message = null, int $code = 0, - Throwable $previous = null + ?Throwable $previous = null ) { parent::__construct($message ?? 'Unsupported CloudEvent content type.', $code, $previous); } diff --git a/src/Exceptions/UnsupportedSpecVersionException.php b/src/Exceptions/UnsupportedSpecVersionException.php index d6578d6..8525523 100644 --- a/src/Exceptions/UnsupportedSpecVersionException.php +++ b/src/Exceptions/UnsupportedSpecVersionException.php @@ -10,9 +10,9 @@ class UnsupportedSpecVersionException extends Exception { public function __construct( - string $message = null, + ?string $message = null, int $code = 0, - Throwable $previous = null + ?Throwable $previous = null ) { parent::__construct($message ?? 'Unsupported CloudEvent spec version.', $code, $previous); } diff --git a/src/Http/Marshaller.php b/src/Http/Marshaller.php index 9aec3d3..48a077a 100644 --- a/src/Http/Marshaller.php +++ b/src/Http/Marshaller.php @@ -43,9 +43,9 @@ public function __construct( } public static function createJsonMarshaller( - RequestFactoryInterface $requestFactory = null, - ResponseFactoryInterface $responseFactory = null, - StreamFactoryInterface $streamFactory = null + ?RequestFactoryInterface $requestFactory = null, + ?ResponseFactoryInterface $responseFactory = null, + ?StreamFactoryInterface $streamFactory = null ): self { return new self( ['serializer' => JsonSerializer::create(), 'type' => 'json'], From 47112b5dc38b72940291b918f8f658cc94c3e2d3 Mon Sep 17 00:00:00 2001 From: John Laswell Date: Fri, 7 Feb 2025 13:29:34 -0500 Subject: [PATCH 2/4] Update MAINTAINERS.md --- MAINTAINERS.md | 1 + 1 file changed, 1 insertion(+) diff --git a/MAINTAINERS.md b/MAINTAINERS.md index b57fc6d..4a5a061 100644 --- a/MAINTAINERS.md +++ b/MAINTAINERS.md @@ -3,3 +3,4 @@ Current active maintainers of this SDK: - [John Laswell](https://github.com/jlaswell) +- [Graham Campbell](https://github.com/grahamcampbell) From 5638f02baa8dc0c984efc986c5770b4f7d1e95f4 Mon Sep 17 00:00:00 2001 From: Graham Campbell Date: Fri, 7 Feb 2025 18:30:01 +0000 Subject: [PATCH 3/4] PHP 8.4 local dev (#58) Signed-off-by: Graham Campbell --- composer.json | 6 ++++-- hack/8.3.Dockerfile | 2 +- hack/8.4.Dockerfile | 22 ++++++++++++++++++++++ 3 files changed, 27 insertions(+), 3 deletions(-) create mode 100644 hack/8.4.Dockerfile diff --git a/composer.json b/composer.json index 658dce4..b6cc4e3 100644 --- a/composer.json +++ b/composer.json @@ -49,14 +49,16 @@ "DOCKER_BUILDKIT=1 docker build -t cloudevents/sdk-php:8.0-tests -f hack/8.0.Dockerfile hack", "DOCKER_BUILDKIT=1 docker build -t cloudevents/sdk-php:8.1-tests -f hack/8.1.Dockerfile hack", "DOCKER_BUILDKIT=1 docker build -t cloudevents/sdk-php:8.2-tests -f hack/8.2.Dockerfile hack", - "DOCKER_BUILDKIT=1 docker build -t cloudevents/sdk-php:8.3-tests -f hack/8.3.Dockerfile hack" + "DOCKER_BUILDKIT=1 docker build -t cloudevents/sdk-php:8.3-tests -f hack/8.3.Dockerfile hack", + "DOCKER_BUILDKIT=1 docker build -t cloudevents/sdk-php:8.4-tests -f hack/8.4.Dockerfile hack" ], "tests-docker": [ "docker run -it -v $(pwd):/var/www cloudevents/sdk-php:7.4-tests --coverage-html=coverage", "docker run -it -v $(pwd):/var/www cloudevents/sdk-php:8.0-tests", "docker run -it -v $(pwd):/var/www cloudevents/sdk-php:8.1-tests", "docker run -it -v $(pwd):/var/www cloudevents/sdk-php:8.2-tests", - "docker run -it -v $(pwd):/var/www cloudevents/sdk-php:8.3-tests" + "docker run -it -v $(pwd):/var/www cloudevents/sdk-php:8.3-tests", + "docker run -it -v $(pwd):/var/www cloudevents/sdk-php:8.4-tests" ] }, "scripts-descriptions": { diff --git a/hack/8.3.Dockerfile b/hack/8.3.Dockerfile index f32111f..e521ba5 100644 --- a/hack/8.3.Dockerfile +++ b/hack/8.3.Dockerfile @@ -1,4 +1,4 @@ -FROM php:8.3-rc-alpine +FROM php:8.3-alpine LABEL org.opencontainers.image.url="https://github.com/cloudevents/sdk-php/tree/main/hack/8.3.Dockerfile" \ org.opencontainers.image.documentation="https://github.com/cloudevents/sdk-php/tree/main/hack/README.md" \ diff --git a/hack/8.4.Dockerfile b/hack/8.4.Dockerfile new file mode 100644 index 0000000..9fcdc49 --- /dev/null +++ b/hack/8.4.Dockerfile @@ -0,0 +1,22 @@ +FROM php:8.4-alpine + +LABEL org.opencontainers.image.url="https://github.com/cloudevents/sdk-php/tree/main/hack/8.4.Dockerfile" \ + org.opencontainers.image.documentation="https://github.com/cloudevents/sdk-php/tree/main/hack/README.md" \ + org.opencontainers.image.source="https://github.com/cloudevents/sdk-php" \ + org.opencontainers.image.vendor="CloudEvent" \ + org.opencontainers.image.title="PHP 8.4" \ + org.opencontainers.image.description="PHP 8.4 test environment for cloudevents/sdk-php" + +COPY --chown=www-data:www-data install-composer /usr/local/bin/install-composer +RUN chmod +x /usr/local/bin/install-composer \ + && /usr/local/bin/install-composer \ + && rm /usr/local/bin/install-composer + +RUN apk update \ + && apk --no-cache upgrade \ + && apk add --no-cache bash ca-certificates git libzip-dev \ + && rm -rf /var/www/html /tmp/pear \ + && chown -R www-data:www-data /var/www + +WORKDIR /var/www +ENTRYPOINT ["/var/www/vendor/bin/phpunit"] From 2d2f14720c83e4ef2b8e17250817b25d59ba055b Mon Sep 17 00:00:00 2001 From: Graham Campbell Date: Fri, 7 Feb 2025 18:31:27 +0000 Subject: [PATCH 4/4] Release 1.2.0 --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index b6cc4e3..3526076 100644 --- a/composer.json +++ b/composer.json @@ -78,7 +78,7 @@ }, "extra": { "branch-alias": { - "dev-main": "1.1-dev" + "dev-main": "1.2-dev" } }, "minimum-stability": "dev",