Skip to content

Commit 1486680

Browse files
authored
feat: php 8 support (#2017)
1 parent 81696e6 commit 1486680

File tree

16 files changed

+44
-91
lines changed

16 files changed

+44
-91
lines changed

.github/apply-phpunit-patches.sh

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/bin/sh
2+
3+
# Script used from php-webdriver/php-webdriver
4+
5+
# All commands below must no fail
6+
set -e
7+
8+
# Be in the root dir
9+
cd "$(dirname "$0")/../"
10+
11+
find tests/ -type f -print0 | xargs -0 sed -i 's/function setUp(): void/function setUp()/g';
12+
13+
# Drop the listener from the config file
14+
sed -i '/<listeners>/,+2d' phpunit.xml.dist;
15+
16+
# Return back to original dir
17+
cd - > /dev/null

.github/sync-repo-settings.yaml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,13 @@ branchProtectionRules:
55
- pattern: master
66
isAdminEnforced: true
77
requiredStatusCheckContexts:
8-
- 'PHP 5.4 Unit Test'
9-
- 'PHP 5.4 Unit Test (with `--prefer-lowest`)'
10-
- 'PHP 5.5 Unit Test'
118
- 'PHP 5.6 Unit Test'
129
- 'PHP 7.0 Unit Test'
1310
- 'PHP 7.1 Unit Test'
1411
- 'PHP 7.2 Unit Test'
1512
- 'PHP 7.3 Unit Test'
1613
- 'PHP 7.4 Unit Test'
14+
- 'PHP 8.0 Unit Test'
1715
- 'PHP Style Check'
1816
- 'cla/google'
1917
requiredApprovingReviewCount: 1

.github/workflows/asset-release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ jobs:
1010
strategy:
1111
matrix:
1212
operating-system: [ ubuntu-latest ]
13-
php: [ "5.4", "5.6", "7.0", "7.4" ]
13+
php: [ "5.6", "7.0", "7.4", "8.0" ]
1414

1515
name: Upload Release Assets
1616
steps:

.github/workflows/tests.yml

Lines changed: 8 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,15 @@
11
name: Test Suite
2-
on:
3-
push:
4-
branches:
5-
- master
6-
pull_request:
2+
on: [push, pull_request]
73

84
jobs:
95
test:
10-
runs-on: ${{matrix.operating-system}}
6+
runs-on: ${{ matrix.operating-system }}
117
strategy:
8+
fail-fast: false
129
matrix:
1310
operating-system: [ ubuntu-latest ]
14-
php: [ "5.6", "7.0", "7.1", "7.2", "7.3", "7.4" ]
15-
name: PHP ${{matrix.php }} Unit Test
11+
php: [ "5.6", "7.0", "7.1", "7.2", "7.3", "7.4", "8.0" ]
12+
name: PHP ${{ matrix.php }} Unit Test
1613
steps:
1714
- uses: actions/checkout@v2
1815
- name: Setup PHP
@@ -25,64 +22,9 @@ jobs:
2522
timeout_minutes: 10
2623
max_attempts: 3
2724
command: composer install
28-
- name: Run Script
29-
run: vendor/bin/phpunit
30-
31-
test_php55:
32-
runs-on: ubuntu-latest
33-
name: PHP 5.5 Unit Test
34-
steps:
35-
- uses: actions/checkout@v2
36-
- name: Setup PHP
37-
uses: shivammathur/setup-php@v2
38-
with:
39-
php-version: 5.5
40-
- name: Install Dependencies
41-
uses: nick-invision/retry@v1
42-
with:
43-
timeout_minutes: 10
44-
max_attempts: 3
45-
command: composer install
46-
- name: Run Script
47-
run: vendor/bin/phpunit
48-
49-
test_php54:
50-
runs-on: ubuntu-latest
51-
name: PHP 5.4 Unit Test
52-
steps:
53-
- uses: actions/checkout@v2
54-
- name: Setup PHP
55-
uses: shivammathur/setup-php@v2
56-
with:
57-
php-version: 5.4
58-
- name: Remove cache library
59-
run: composer remove --dev --no-update cache/filesystem-adapter
60-
- name: Install Dependencies
61-
uses: nick-invision/retry@v1
62-
with:
63-
timeout_minutes: 10
64-
max_attempts: 3
65-
command: composer update
66-
- name: Run Script
67-
run: vendor/bin/phpunit
68-
69-
test_php54_lowest:
70-
runs-on: ubuntu-latest
71-
name: "PHP 5.4 Unit Test (with `--prefer-lowest`)"
72-
steps:
73-
- uses: actions/checkout@v2
74-
- name: Setup PHP
75-
uses: shivammathur/setup-php@v2
76-
with:
77-
php-version: 5.4
78-
- name: Remove cache library
79-
run: composer remove --dev --no-update cache/filesystem-adapter
80-
- name: Install Dependencies
81-
uses: nick-invision/retry@v1
82-
with:
83-
timeout_minutes: 10
84-
max_attempts: 3
85-
command: composer update --prefer-lowest
25+
- if: ${{ matrix.php == '5.6' || matrix.php == '7.0' || matrix.php == '7.1' }}
26+
name: Run PHPUnit Patches
27+
run: sh .github/apply-phpunit-patches.sh
8628
- name: Run Script
8729
run: vendor/bin/phpunit
8830

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,14 @@ The Google API Client Library enables you to work with Google APIs such as Gmail
1111

1212
These client libraries are officially supported by Google. However, the libraries are considered complete and are in maintenance mode. This means that we will address critical bugs and security issues but will not add any new features.
1313

14-
**NOTE** The actively maintained (v2) version of this client requires PHP 5.4 or above. If you require support for PHP 5.2 or 5.3, use the v1 branch.
14+
**NOTE** The actively maintained (v2) version of this client requires PHP 5.6 or above. If you require support for PHP 5.2 or 5.3, use the v1 branch.
1515

1616
## Google Cloud Platform
1717

1818
For Google Cloud Platform APIs such as Datastore, Cloud Storage or Pub/Sub, we recommend using [GoogleCloudPlatform/google-cloud-php](https://github.com/googleapis/google-cloud-php) which is under active development.
1919

2020
## Requirements ##
21-
* [PHP 5.4.0 or higher](https://www.php.net/)
21+
* [PHP 5.6.0 or higher](https://www.php.net/)
2222

2323
## Developer Documentation ##
2424

UPGRADING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ $client->revokeToken($token);
244244
$client->isAccessTokenExpired();
245245
```
246246

247-
## PHP 5.4 is now the minimum supported PHP version
247+
## PHP 5.6 is now the minimum supported PHP version
248248

249249
This was previously `PHP 5.2`. If you still need to use PHP 5.2, please continue to use
250250
the [v1-master](https://github.com/google/google-api-php-client/tree/v1-master) branch.

composer.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"homepage": "http://developers.google.com/api-client-library/php",
77
"license": "Apache-2.0",
88
"require": {
9-
"php": ">=5.4",
9+
"php": "^5.6|^7.0|^8.0",
1010
"google/auth": "^1.10",
1111
"google/apiclient-services": "~0.13",
1212
"firebase/php-jwt": "~2.0||~3.0||~4.0||~5.0",
@@ -16,11 +16,11 @@
1616
"guzzlehttp/psr7": "^1.2"
1717
},
1818
"require-dev": {
19-
"phpunit/phpunit": "^4.8.36|^5.0",
19+
"phpunit/phpunit": "^5.0||^8.5",
2020
"squizlabs/php_codesniffer": "~2.3",
2121
"symfony/dom-crawler": "~2.1",
2222
"symfony/css-selector": "~2.1",
23-
"cache/filesystem-adapter": "^0.3.2",
23+
"cache/filesystem-adapter": "^0.3.2|^1.1",
2424
"phpcompatibility/php-compatibility": "^9.2",
2525
"dealerdirect/phpcodesniffer-composer-installer": "^0.7",
2626
"composer/composer": "^1.10"

docs/install.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ This page contains information about installing the Google APIs Client Library f
44

55
## Requirements
66

7-
* PHP version 5.4 or greater.
7+
* PHP version 5.6 or greater.
88

99
## Obtaining the client library
1010

docs/oauth-web.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ To run any of the code samples in this document, you'll need a Google account, a
5050

5151
To run the PHP code samples in this document, you'll need:
5252

53-
* PHP 5.4 or greater with the command-line interface (CLI) and JSON extension installed.
53+
* PHP 5.6 or greater with the command-line interface (CLI) and JSON extension installed.
5454
* The [Composer](https://getcomposer.org/) dependency management tool.
5555
* The Google APIs Client Library for PHP:
5656
```sh
@@ -315,7 +315,7 @@ To run this example:
315315
```
316316
317317
4. Create the files `index.php` and `oauth2callback.php` with the content below.
318-
5. Run the example with a web server configured to serve PHP. If you use PHP 5.4 or newer, you can use PHP's built-in test web server:
318+
5. Run the example with a web server configured to serve PHP. If you use PHP 5.6 or newer, you can use PHP's built-in test web server:
319319

320320
```sh
321321
php -S localhost:8080 ~/php-oauth2-example

phpcs.xml.dist

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,6 @@
1010
<!-- PHP code MUST use only UTF-8 without BOM. -->
1111
<rule ref="Generic.Files.ByteOrderMark"/>
1212

13-
<!-- Check for cross-version support for PHP 5.4 and higher. -->
14-
<rule ref="PHPCompatibility">
15-
<config name="testVersion" value="5.4-"/>
16-
</rule>
17-
1813
<!-- Check for duplicated class names -->
1914
<rule ref="Generic.Classes.DuplicateClassName" />
2015

0 commit comments

Comments
 (0)