diff --git a/.github/apply-phpunit-patches.sh b/.github/apply-phpunit-patches.sh new file mode 100644 index 000000000..2584fd243 --- /dev/null +++ b/.github/apply-phpunit-patches.sh @@ -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 '//,+2d' phpunit.xml.dist; + +# Return back to original dir +cd - > /dev/null diff --git a/.github/sync-repo-settings.yaml b/.github/sync-repo-settings.yaml index c2b2689b5..74cb44ff2 100644 --- a/.github/sync-repo-settings.yaml +++ b/.github/sync-repo-settings.yaml @@ -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 diff --git a/.github/workflows/asset-release.yml b/.github/workflows/asset-release.yml index 6124ac21f..02a224c8b 100644 --- a/.github/workflows/asset-release.yml +++ b/.github/workflows/asset-release.yml @@ -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: diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 141fcd774..6dc9a1233 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -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 @@ -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 diff --git a/README.md b/README.md index 2d9df6d78..784cb4da9 100644 --- a/README.md +++ b/README.md @@ -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. ## 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 ## diff --git a/UPGRADING.md b/UPGRADING.md index 853088e2e..f07a24436 100644 --- a/UPGRADING.md +++ b/UPGRADING.md @@ -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. diff --git a/composer.json b/composer.json index 3f058bbc6..6455f5ef4 100644 --- a/composer.json +++ b/composer.json @@ -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", @@ -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" diff --git a/docs/install.md b/docs/install.md index 36bb6591b..8218978fb 100644 --- a/docs/install.md +++ b/docs/install.md @@ -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 diff --git a/docs/oauth-web.md b/docs/oauth-web.md index 3fef5edef..dfc16f911 100644 --- a/docs/oauth-web.md +++ b/docs/oauth-web.md @@ -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 @@ -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 diff --git a/phpcs.xml.dist b/phpcs.xml.dist index 926146867..3f58a6ba6 100644 --- a/phpcs.xml.dist +++ b/phpcs.xml.dist @@ -10,11 +10,6 @@ - - - - - diff --git a/tests/Google/Http/RESTTest.php b/tests/Google/Http/RESTTest.php index b090fdd77..9f28cc269 100644 --- a/tests/Google/Http/RESTTest.php +++ b/tests/Google/Http/RESTTest.php @@ -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', '/'); diff --git a/tests/Google/Service/AdSenseTest.php b/tests/Google/Service/AdSenseTest.php index 14dbb3b1e..42268c75f 100644 --- a/tests/Google/Service/AdSenseTest.php +++ b/tests/Google/Service/AdSenseTest.php @@ -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()); diff --git a/tests/Google/Service/ResourceTest.php b/tests/Google/Service/ResourceTest.php index 74cdc711d..8da5a7aa6 100644 --- a/tests/Google/Service/ResourceTest.php +++ b/tests/Google/Service/ResourceTest.php @@ -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"); diff --git a/tests/Google/Service/TasksTest.php b/tests/Google/Service/TasksTest.php index 0cae03732..87361bcd0 100644 --- a/tests/Google/Service/TasksTest.php +++ b/tests/Google/Service/TasksTest.php @@ -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()); diff --git a/tests/Google/Service/YouTubeTest.php b/tests/Google/Service/YouTubeTest.php index b7745f8ae..2a9381a61 100644 --- a/tests/Google/Service/YouTubeTest.php +++ b/tests/Google/Service/YouTubeTest.php @@ -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()); diff --git a/tests/Google/Task/RunnerTest.php b/tests/Google/Task/RunnerTest.php index 1dd93a0ec..3d421328b 100644 --- a/tests/Google/Task/RunnerTest.php +++ b/tests/Google/Task/RunnerTest.php @@ -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(); } @@ -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(