Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PHP 8 Support #2017

Merged
merged 9 commits into from
Dec 22, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions .github/apply-phpunit-patches.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/sh

# Script used from php-webdriver/php-webdriver

# All commands below must no fail
set -e

# Be in the root dir
cd "$(dirname "$0")/../"

find tests/ -type f -print0 | xargs -0 sed -i 's/function setUp(): void/function setUp()/g';

# Drop the listener from the config file
sed -i '/<listeners>/,+2d' phpunit.xml.dist;

# Return back to original dir
cd - > /dev/null
4 changes: 1 addition & 3 deletions .github/sync-repo-settings.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,13 @@ branchProtectionRules:
- pattern: master
isAdminEnforced: true
requiredStatusCheckContexts:
- 'PHP 5.4 Unit Test'
- 'PHP 5.4 Unit Test (with `--prefer-lowest`)'
- 'PHP 5.5 Unit Test'
- 'PHP 5.6 Unit Test'
- 'PHP 7.0 Unit Test'
- 'PHP 7.1 Unit Test'
- 'PHP 7.2 Unit Test'
- 'PHP 7.3 Unit Test'
- 'PHP 7.4 Unit Test'
- 'PHP 8.0 Unit Test'
- 'PHP Style Check'
- 'cla/google'
requiredApprovingReviewCount: 1
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/asset-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
strategy:
matrix:
operating-system: [ ubuntu-latest ]
php: [ "5.4", "5.6", "7.0", "7.4" ]
php: [ "5.6", "7.0", "7.4", "8.0" ]

name: Upload Release Assets
steps:
Expand Down
74 changes: 8 additions & 66 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -1,18 +1,15 @@
name: Test Suite
on:
push:
branches:
- master
pull_request:
on: [push, pull_request]

jobs:
test:
runs-on: ${{matrix.operating-system}}
runs-on: ${{ matrix.operating-system }}
strategy:
fail-fast: false
matrix:
operating-system: [ ubuntu-latest ]
php: [ "5.6", "7.0", "7.1", "7.2", "7.3", "7.4" ]
name: PHP ${{matrix.php }} Unit Test
php: [ "5.6", "7.0", "7.1", "7.2", "7.3", "7.4", "8.0" ]
name: PHP ${{ matrix.php }} Unit Test
steps:
- uses: actions/checkout@v2
- name: Setup PHP
Expand All @@ -25,64 +22,9 @@ jobs:
timeout_minutes: 10
max_attempts: 3
command: composer install
- name: Run Script
run: vendor/bin/phpunit

test_php55:
runs-on: ubuntu-latest
name: PHP 5.5 Unit Test
steps:
- uses: actions/checkout@v2
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 5.5
- name: Install Dependencies
uses: nick-invision/retry@v1
with:
timeout_minutes: 10
max_attempts: 3
command: composer install
- name: Run Script
run: vendor/bin/phpunit

test_php54:
runs-on: ubuntu-latest
name: PHP 5.4 Unit Test
steps:
- uses: actions/checkout@v2
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 5.4
- name: Remove cache library
run: composer remove --dev --no-update cache/filesystem-adapter
- name: Install Dependencies
uses: nick-invision/retry@v1
with:
timeout_minutes: 10
max_attempts: 3
command: composer update
- name: Run Script
run: vendor/bin/phpunit

test_php54_lowest:
runs-on: ubuntu-latest
name: "PHP 5.4 Unit Test (with `--prefer-lowest`)"
steps:
- uses: actions/checkout@v2
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 5.4
- name: Remove cache library
run: composer remove --dev --no-update cache/filesystem-adapter
- name: Install Dependencies
uses: nick-invision/retry@v1
with:
timeout_minutes: 10
max_attempts: 3
command: composer update --prefer-lowest
- if: ${{ matrix.php == '5.6' || matrix.php == '7.0' || matrix.php == '7.1' }}
name: Run PHPUnit Patches
run: sh .github/apply-phpunit-patches.sh
- name: Run Script
run: vendor/bin/phpunit

Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@ The Google API Client Library enables you to work with Google APIs such as Gmail

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.

**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.
**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.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you're missing a note for the last version that supports PHP 5.4 / 5.5


## Google Cloud Platform

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.

## Requirements ##
* [PHP 5.4.0 or higher](https://www.php.net/)
* [PHP 5.6.0 or higher](https://www.php.net/)

## Developer Documentation ##

Expand Down
2 changes: 1 addition & 1 deletion UPGRADING.md
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ $client->revokeToken($token);
$client->isAccessTokenExpired();
```

## PHP 5.4 is now the minimum supported PHP version
## PHP 5.6 is now the minimum supported PHP version

This was previously `PHP 5.2`. If you still need to use PHP 5.2, please continue to use
the [v1-master](https://github.com/google/google-api-php-client/tree/v1-master) branch.
Expand Down
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"homepage": "http://developers.google.com/api-client-library/php",
"license": "Apache-2.0",
"require": {
"php": ">=5.4",
"php": "^5.6|^7.0|^8.0",
"google/auth": "^1.10",
"google/apiclient-services": "~0.13",
"firebase/php-jwt": "~2.0||~3.0||~4.0||~5.0",
Expand All @@ -16,11 +16,11 @@
"guzzlehttp/psr7": "^1.2"
},
"require-dev": {
"phpunit/phpunit": "^4.8.36|^5.0",
"phpunit/phpunit": "^5.0||^8.5",
"squizlabs/php_codesniffer": "~2.3",
"symfony/dom-crawler": "~2.1",
"symfony/css-selector": "~2.1",
"cache/filesystem-adapter": "^0.3.2",
"cache/filesystem-adapter": "^0.3.2|^1.1",
"phpcompatibility/php-compatibility": "^9.2",
"dealerdirect/phpcodesniffer-composer-installer": "^0.7",
"composer/composer": "^1.10"
Expand Down
2 changes: 1 addition & 1 deletion docs/install.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ This page contains information about installing the Google APIs Client Library f

## Requirements

* PHP version 5.4 or greater.
* PHP version 5.6 or greater.

## Obtaining the client library

Expand Down
4 changes: 2 additions & 2 deletions docs/oauth-web.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ To run any of the code samples in this document, you'll need a Google account, a

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

* PHP 5.4 or greater with the command-line interface (CLI) and JSON extension installed.
* PHP 5.6 or greater with the command-line interface (CLI) and JSON extension installed.
* The [Composer](https://getcomposer.org/) dependency management tool.
* The Google APIs Client Library for PHP:
```sh
Expand Down Expand Up @@ -315,7 +315,7 @@ To run this example:
```

4. Create the files `index.php` and `oauth2callback.php` with the content below.
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:
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:

```sh
php -S localhost:8080 ~/php-oauth2-example
Expand Down
5 changes: 0 additions & 5 deletions phpcs.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,6 @@
<!-- PHP code MUST use only UTF-8 without BOM. -->
<rule ref="Generic.Files.ByteOrderMark"/>

<!-- Check for cross-version support for PHP 5.4 and higher. -->
<rule ref="PHPCompatibility">
<config name="testVersion" value="5.4-"/>
</rule>

<!-- Check for duplicated class names -->
<rule ref="Generic.Classes.DuplicateClassName" />

Expand Down
2 changes: 1 addition & 1 deletion tests/Google/Http/RESTTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class Google_HTTP_RESTTest extends BaseTest
*/
private $rest;

public function setUp()
public function setUp(): void
{
$this->rest = new Google_Http_REST();
$this->request = new Request('GET', '/');
Expand Down
2 changes: 1 addition & 1 deletion tests/Google/Service/AdSenseTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
class Google_Service_AdSenseTest extends BaseTest
{
public $adsense;
public function setUp()
public function setUp(): void
{
$this->checkToken();
$this->adsense = new Google_Service_AdSense($this->getClient());
Expand Down
2 changes: 1 addition & 1 deletion tests/Google/Service/ResourceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class Google_Service_ResourceTest extends BaseTest
private $client;
private $service;

public function setUp()
public function setUp(): void
{
$this->client = $this->prophesize("Google_Client");

Expand Down
2 changes: 1 addition & 1 deletion tests/Google/Service/TasksTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class Google_Service_TasksTest extends BaseTest
/** @var Google_TasksService */
public $taskService;

public function setUp()
public function setUp(): void
{
$this->checkToken();
$this->taskService = new Google_Service_Tasks($this->getClient());
Expand Down
2 changes: 1 addition & 1 deletion tests/Google/Service/YouTubeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class Google_Service_YouTubeTest extends BaseTest
{
/** @var Google_Service_YouTube */
public $youtube;
public function setUp()
public function setUp(): void
{
$this->checkToken();
$this->youtube = new Google_Service_YouTube($this->getClient());
Expand Down
5 changes: 3 additions & 2 deletions tests/Google/Task/RunnerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class Google_Task_RunnerTest extends BaseTest
private $retryMap;
private $retryConfig;

protected function setUp()
protected function setUp(): void
{
$this->client = new Google_Client();
}
Expand Down Expand Up @@ -288,7 +288,8 @@ public function testCurlTimeouts($config, $minTime)
*/
public function testBadTaskConfig($config, $message)
{
$this->setExpectedException('Google_Task_Exception', $message);
$this->expectException('Google_Task_Exception');
$this->expectExceptionMessage($message);
$this->setRetryConfig($config);

new Google_Task_Runner(
Expand Down