Skip to content

Commit 0b6d61a

Browse files
committed
Upgraded to PHP 8, including parameter and return types
1 parent 97ef073 commit 0b6d61a

19 files changed

+1443
-1148
lines changed

.github/workflows/build.yml

Lines changed: 5 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,10 @@ jobs:
2828
- uses: actions/checkout@v6
2929
with:
3030
persist-credentials: false
31-
- name: Set up PHP 7.4
31+
- name: Set up PHP 8.0
3232
uses: shivammathur/setup-php@v2
3333
with:
34-
php-version: '7.4'
34+
php-version: '8.0'
3535
coverage: xdebug
3636
tools: phpstan
3737
- name: Cache Composer packages
@@ -53,10 +53,10 @@ jobs:
5353
- uses: actions/checkout@v6
5454
with:
5555
persist-credentials: false
56-
- name: Set up PHP 7.4
56+
- name: Set up PHP 8.0
5757
uses: shivammathur/setup-php@v2
5858
with:
59-
php-version: '7.4'
59+
php-version: '8.0'
6060
tools: phpcs
6161
- name: Cache Composer packages
6262
id: composer-cache
@@ -83,8 +83,7 @@ jobs:
8383
password: ${{ secrets.dockerhub_password }}
8484
strategy:
8585
matrix:
86-
# PHP Unit 4.x is needed for PHP 5.4 but is not supported on PHP 8.x
87-
php: [5.4, 5.6, 7.0, 7.4]
86+
php: [8.0, 8.1, 8.2, 8.3, 8.4]
8887
fail-fast: false
8988
steps:
9089
- uses: actions/checkout@v6
@@ -108,76 +107,3 @@ jobs:
108107
run: |
109108
echo '{}' | jq '.http.upload.skip |= false | .http.upload.httpBinUrl |= "http://localhost:8080"' > tests/config.json
110109
vendor/bin/phpunit tests
111-
112-
test-php8:
113-
runs-on: ubuntu-latest
114-
strategy:
115-
matrix:
116-
php: [8.0, 8.1, 8.2, 8.3, 8.4]
117-
fail-fast: false
118-
steps:
119-
- uses: actions/checkout@v6
120-
with:
121-
persist-credentials: false
122-
fetch-depth: 0
123-
- name: Rebase PHP8 branch
124-
env:
125-
USER_EMAIL: ${{ github.event.pusher.email }}
126-
USER_NAME: ${{ github.event.pusher.name }}
127-
REBASE_TARGET: ${{ github.head_ref || github.ref_name }}
128-
run: |
129-
git config user.email "$USER_EMAIL"
130-
git config user.name "$USER_NAME"
131-
git pull
132-
git checkout php8
133-
git rebase "$REBASE_TARGET" php8
134-
git status
135-
echo 'diff origin/php8:'
136-
git diff origin/php8
137-
echo 'diff current:'
138-
git diff "$REBASE_TARGET"
139-
- uses: shivammathur/setup-php@v2
140-
with:
141-
php-version: ${{matrix.php}}
142-
coverage: xdebug
143-
- name: Cache Composer packages
144-
id: composer-cache
145-
uses: actions/cache@v4
146-
with:
147-
path: vendor
148-
key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }}
149-
restore-keys: |
150-
${{ runner.os }}-php8-
151-
- name: Install dependencies
152-
run: composer install -q --no-ansi --no-interaction --no-scripts --no-progress --prefer-dist
153-
- name: PHP Unit
154-
run: |
155-
echo '{}' | jq '.http.upload.skip |= true' > tests/config.json
156-
vendor/bin/phpunit tests
157-
158-
rebase-php8:
159-
runs-on: ubuntu-latest
160-
needs: test-php8
161-
if: github.ref_name == 'master'
162-
permissions:
163-
contents: write
164-
steps:
165-
- uses: actions/checkout@v6
166-
with:
167-
ref: php8
168-
fetch-depth: 0
169-
- name: Rebase PHP8 branch
170-
env:
171-
USER_EMAIL: ${{ github.event.pusher.email }}
172-
USER_NAME: ${{ github.event.pusher.name }}
173-
run: |
174-
git config user.email "$USER_EMAIL"
175-
git config user.name "$USER_NAME"
176-
git pull
177-
git rebase origin/master php8
178-
git status
179-
echo 'diff origin/php8:'
180-
git diff origin/php8
181-
echo 'diff master:'
182-
git diff origin/master
183-
git push --force-with-lease

.github/workflows/release-site.yml

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,8 @@ jobs:
2828
- uses: actions/checkout@v6
2929
with:
3030
persist-credentials: false
31-
- name: Set up PHP
32-
uses: shivammathur/setup-php@v2
33-
with:
34-
# highest version to support apigen/apigen
35-
php-version: '7.1'
36-
- name: Install apigen
37-
run: composer global require apigen/apigen
3831
- name: Generate API
39-
run: apigen generate -s src -d docs
32+
run: mkdir -p docs && docker run --rm -v "$GITHUB_WORKSPACE/code:/workspace" -w /workspace -u `id -u`:`id -g` apigen/apigen
4033
- uses: actions/upload-artifact@v4
4134
with:
4235
name: docs

.github/workflows/sonarcloud.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,10 @@ jobs:
3131
- uses: actions/checkout@v6
3232
with:
3333
fetch-depth: 0
34-
- name: Set up PHP 7.4
34+
- name: Set up PHP 8.0
3535
uses: shivammathur/setup-php@v2
3636
with:
37-
php-version: '7.4'
37+
php-version: '8.0'
3838
coverage: xdebug
3939
- name: Cache Composer packages
4040
id: composer-cache

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -114,14 +114,14 @@ To send a multipart object with a cURL request, you need to follow some steps:
114114

115115
* Set the request type using `CURLOPT_CUSTOMREQUEST`.
116116
* Set the `CURLOPT_UPLOAD` option to `true`.
117-
* Set the object's `curl_read` method as the `CURLOPT_READFUNCTION`.
117+
* Set the object's `curlRead` method as the `CURLOPT_READFUNCTION`.
118118
* Make sure the `Content-Type` and `Content-Length` headers are set. Note that the `Content-Length` header is optional.
119119

120120
For instance:
121121

122122
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST');
123123
curl_setopt($ch, CURLOPT_UPLOAD, true);
124-
curl_setopt($ch, CURLOPT_READFUNCTION, array($multipart, 'curl_read'));
124+
curl_setopt($ch, CURLOPT_READFUNCTION, array($multipart, 'curlRead'));
125125

126126
$headers = ['Content-Type: ' . $multipart->getContentType()];
127127
$contentLength = $multipart->getContentLength();
@@ -132,6 +132,6 @@ For instance:
132132

133133
## Non-streaming support
134134

135-
If streaming is not possible (e.g. because a string is required, like in the `mail` function), you can buffer a multipart object in-memory by calling the `buffer` method. This method takes an optional buffer size, and returns the buffered contents. The content length will be set accordingly. Note that you should do this before calling `read` (or `curl_read`), otherwise the buffered contents may not contain all desired contents (especially if you're using resources or callables).
135+
If streaming is not possible (e.g. because a string is required, like in the `mail` function), you can buffer a multipart object in-memory by calling the `buffer` method. This method takes an optional buffer size, and returns the buffered contents. The content length will be set accordingly. Note that you should do this before calling `read` (or `curlRead`), otherwise the buffered contents may not contain all desired contents (especially if you're using resources or callables).
136136

137137
`Multipart.__toString()` has been overridden to buffer the multipart object as well, so you can achieve the same by casting a multipart object to `string`. The difference is that `buffer` requires the multipart object to be finished.

composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@
1515
"issues": "https://github.com/robtimus/php-multipart/issues"
1616
},
1717
"require": {
18-
"php": ">=5.4"
18+
"php": ">=8.0"
1919
},
2020
"require-dev": {
21-
"phpunit/phpunit": "~4"
21+
"phpunit/phpunit": "~9"
2222
},
2323
"autoload": {
2424
"psr-4": {

0 commit comments

Comments
 (0)