Skip to content

Commit 4c438a1

Browse files
Added support for PHP 8.1 (#29)
Signed-off-by: Graham Campbell <[email protected]>
1 parent 636e657 commit 4c438a1

File tree

8 files changed

+41
-35
lines changed

8 files changed

+41
-35
lines changed

.github/workflows/tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212

1313
strategy:
1414
matrix:
15-
php: ['7.4', '8.0']
15+
php: ['7.4', '8.0', '8.1']
1616

1717
steps:
1818
- name: Checkout Code

composer.json

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,27 +21,28 @@
2121
}
2222
},
2323
"require": {
24-
"php": ">=7.4",
24+
"php": "^7.4 || ^8.0",
2525
"ext-json": "*",
2626
"ext-pcre": "*",
2727
"symfony/polyfill-php80": "^1.17"
2828
},
2929
"require-dev": {
30-
"nunomaduro/collision": "^5.2",
31-
"phpunit/phpunit": "^9.5",
32-
"squizlabs/php_codesniffer": "^3.5"
30+
"phpunit/phpunit": "^9.5 || ^10.0",
31+
"squizlabs/php_codesniffer": "^3.6"
3332
},
3433
"scripts": {
3534
"lint": "./vendor/bin/phpcs --standard=PSR12 ./src ./tests",
3635
"lint-fix": "./vendor/bin/phpcbf --standard=PSR12 ./src ./tests",
3736
"tests": "./vendor/bin/phpunit",
3837
"tests-build": [
3938
"DOCKER_BUILDKIT=1 docker build -t cloudevents/sdk-php:7.4-tests -f hack/7.4.Dockerfile hack",
40-
"DOCKER_BUILDKIT=1 docker build -t cloudevents/sdk-php:8.0-tests -f hack/8.0.Dockerfile hack"
39+
"DOCKER_BUILDKIT=1 docker build -t cloudevents/sdk-php:8.0-tests -f hack/8.0.Dockerfile hack",
40+
"DOCKER_BUILDKIT=1 docker build -t cloudevents/sdk-php:8.1-tests -f hack/8.1.Dockerfile hack"
4141
],
4242
"tests-docker": [
4343
"docker run -it -v $(pwd):/var/www cloudevents/sdk-php:7.4-tests --coverage-html=coverage",
44-
"docker run -it -v $(pwd):/var/www cloudevents/sdk-php:8.0-tests"
44+
"docker run -it -v $(pwd):/var/www cloudevents/sdk-php:8.0-tests",
45+
"docker run -it -v $(pwd):/var/www cloudevents/sdk-php:8.1-tests"
4546
]
4647
},
4748
"scripts-descriptions": {
@@ -52,11 +53,14 @@
5253
"tests-docker": "Run tests within supported PHP version containers"
5354
},
5455
"config": {
56+
"preferred-install": "dist",
5557
"sort-packages": true
5658
},
5759
"extra": {
5860
"branch-alias": {
5961
"dev-master": "1.0-dev"
6062
}
61-
}
63+
},
64+
"minimum-stability": "dev",
65+
"prefer-stable": true
6266
}

hack/8.0.Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ LABEL org.opencontainers.image.url="https://github.com/cloudevents/sdk-php/tree/
77
org.opencontainers.image.title="PHP 8.0" \
88
org.opencontainers.image.description="PHP 8.0 test environment for cloudevents/sdk-php"
99

10-
COPY --chown=www-data:www-data install-composer-2.0.8 /usr/local/bin/install-composer
10+
COPY --chown=www-data:www-data install-composer /usr/local/bin/install-composer
1111
RUN chmod +x /usr/local/bin/install-composer \
1212
&& /usr/local/bin/install-composer \
1313
&& rm /usr/local/bin/install-composer

hack/8.1.Dockerfile

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
FROM php:8.1.0beta1-alpine
2+
3+
LABEL org.opencontainers.image.url="https://github.com/cloudevents/sdk-php/tree/master/hack/8.1.Dockerfile" \
4+
org.opencontainers.image.documentation="https://github.com/cloudevents/sdk-php/tree/master/hack/README.md" \
5+
org.opencontainers.image.source="https://github.com/cloudevents/sdk-php" \
6+
org.opencontainers.image.vendor="CloudEvent" \
7+
org.opencontainers.image.title="PHP 8.1" \
8+
org.opencontainers.image.description="PHP 8.1 test environment for cloudevents/sdk-php"
9+
10+
COPY --chown=www-data:www-data install-composer /usr/local/bin/install-composer
11+
RUN chmod +x /usr/local/bin/install-composer \
12+
&& /usr/local/bin/install-composer \
13+
&& rm /usr/local/bin/install-composer
14+
15+
RUN apk update \
16+
&& apk --no-cache upgrade \
17+
&& apk add --no-cache bash ca-certificates git libzip-dev \
18+
&& rm -rf /var/www/html /tmp/pear \
19+
&& chown -R www-data:www-data /var/www
20+
21+
WORKDIR /var/www
22+
ENTRYPOINT ["/var/www/vendor/bin/phpunit"]

hack/install-composer

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,6 @@
11
#!/bin/sh
22

3-
EXPECTED_CHECKSUM="$(wget -q -O - https://composer.github.io/installer.sig)"
43
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
5-
ACTUAL_CHECKSUM="$(php -r "echo hash_file('sha384', 'composer-setup.php');")"
6-
7-
if [ "$EXPECTED_CHECKSUM" != "$ACTUAL_CHECKSUM" ]
8-
then
9-
>&2 echo 'ERROR: Invalid installer checksum'
10-
rm composer-setup.php
11-
exit 1
12-
fi
13-
4+
php -r "if (hash_file('sha384', 'composer-setup.php') === '756890a4488ce9024fc62c56153228907f1545c228516cbf63f885e036d37e9a59d27d63f46af1d4d07ee0f76181c7d3') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;" \
145
php composer-setup.php --install-dir=/usr/local/bin --filename=composer --quiet
15-
RESULT=$?
16-
rm composer-setup.php
17-
exit $RESULT
6+
php -r "unlink('composer-setup.php');" \

hack/install-composer-2.0.8

Lines changed: 0 additions & 6 deletions
This file was deleted.

phpunit.xml.dist

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,20 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
33
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.5/phpunit.xsd"
4+
beStrictAboutCoversAnnotation="true"
5+
beStrictAboutOutputDuringTests="true"
46
bootstrap="vendor/autoload.php"
57
cacheResultFile=".phpunit.cache/test-results"
68
executionOrder="depends,defects"
7-
forceCoversAnnotation="true"
8-
beStrictAboutCoversAnnotation="true"
9-
beStrictAboutOutputDuringTests="true"
10-
beStrictAboutTodoAnnotatedTests="true"
119
failOnRisky="true"
1210
failOnWarning="true"
13-
printerClass="NunoMaduro\Collision\Adapters\Phpunit\Printer"
11+
forceCoversAnnotation="true"
1412
verbose="true">
1513
<testsuites>
1614
<testsuite name="default">
1715
<directory suffix="Test.php">tests</directory>
1816
</testsuite>
1917
</testsuites>
20-
2118
<coverage cacheDirectory=".phpunit.cache/code-coverage"
2219
processUncoveredFiles="true">
2320
<include>

tests/CloudEvents/Serializers/Formatters/FormatterTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
use ValueError;
99

1010
/**
11-
* @coversDefaultClass \CloudEvents\Serializers\Formmaters\Formatter
11+
* @coversDefaultClass \CloudEvents\Serializers\Formatters\Formatter
1212
*/
1313
class FormatterTest extends TestCase
1414
{

0 commit comments

Comments
 (0)