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 #644

Closed
wants to merge 36 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
d32875b
PHP 8 Support
driesvints Nov 3, 2020
04affdf
Changelog
driesvints Nov 3, 2020
a142f17
Lower faker dependency
driesvints Nov 3, 2020
470501c
Update build
driesvints Nov 26, 2020
bb981c5
Update CHANGELOG.md
julienbourdeau Nov 26, 2020
a8da9b2
Update composer.json
julienbourdeau Nov 26, 2020
3249c9b
chore: adds circleCI badge
chloelbn Nov 26, 2020
64b156c
fix ci config for forks
julienbourdeau Nov 26, 2020
8272539
Name builds
driesvints Nov 26, 2020
388456b
Remove nightly build for Guzzle 6
driesvints Nov 26, 2020
1591fbe
fix test-no-composer
julienbourdeau Nov 26, 2020
88bb6aa
rename legacy client
julienbourdeau Nov 26, 2020
9f86cb6
Update image
driesvints Dec 1, 2020
4b67cea
Rename
driesvints Dec 1, 2020
2950dcf
update gitattributes
driesvints Dec 1, 2020
e502dd4
Use PHP 8 tag
driesvints Dec 1, 2020
e3570bf
Use different image for 7.4 and 8.0
driesvints Dec 1, 2020
841ec89
Fix param name
driesvints Dec 1, 2020
f25f40a
fix
driesvints Dec 1, 2020
12c278a
Fix
driesvints Dec 1, 2020
72124d5
wip
driesvints Dec 1, 2020
ea318d4
wip
driesvints Dec 1, 2020
7c905f3
wip
driesvints Dec 1, 2020
f98ae6f
wip
driesvints Dec 1, 2020
0369708
wip
driesvints Dec 1, 2020
87d1a8e
Do not run docker ext when cimg is used
driesvints Dec 1, 2020
0f14f95
Do not run php cs fixer on PHP 8
driesvints Dec 1, 2020
b81547c
Try PHPUnit 9.4
driesvints Dec 1, 2020
3db5a57
Try PHPUnit 8
driesvints Dec 1, 2020
ef336c1
Revert safeName changes
driesvints Dec 4, 2020
d46292e
Try to run PHPUnit patch script
driesvints Dec 10, 2020
631e31a
Allow PHP CS Fixer again
driesvints Dec 10, 2020
370a38f
Revert PHP CS Fixer again
driesvints Dec 10, 2020
6bd74e6
Fix
driesvints Dec 10, 2020
3ac9ced
Correct location of patch file
driesvints Dec 10, 2020
d492393
Reverse PHPUnit patching
driesvints Dec 10, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
15 changes: 15 additions & 0 deletions .circleci/apply-phpunit-patches.sh
@@ -0,0 +1,15 @@
#!/bin/sh

# 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 setUpBeforeClass()/function setUpBeforeClass(): void/g';
find tests/ -type f -print0 | xargs -0 sed -i 's/function tearDownAfterClass()/function tearDownAfterClass(): void/g';
find tests/ -type f -print0 | xargs -0 sed -i 's/function setUp()/function setUp(): void/g';
find tests/ -type f -print0 | xargs -0 sed -i 's/function tearDown()/function tearDown(): void/g';

# Return back to original dir
cd - > /dev/null
86 changes: 68 additions & 18 deletions .circleci/config.yml
Expand Up @@ -8,31 +8,41 @@ version: 2.1
executors:
php-docker: # declares a reusable executor
parameters:
image:
description: "Docker image"
type: string
version:
description: "PHP version tag"
type: string
docker:
- image: circleci/php:<<parameters.version>>
- image: <<parameters.image>>:<<parameters.version>>

jobs:
test:
parameters:
image:
description: "Docker image"
type: string
version:
description: "PHP version tag"
type: string
http_client:
description: "PHP Client"
description: "PHP client"
type: string

executor:
name: php-docker
image: <<parameters.image>>
version: <<parameters.version>>

steps:
- checkout

- run: sudo apt update
- run: sudo docker-php-ext-install zip
- run: |
if [ "<<parameters.image>>" = "circleci/php" ]; then
sudo docker-php-ext-install zip
fi

# Download and cache dependencies
- restore_cache:
Expand All @@ -41,7 +51,12 @@ jobs:
# fallback to using the latest cache if no exact match is found
#- composer-deps-

- run: composer install -n --prefer-dist
- run: |
if [ "<<parameters.version>>" != "8.0" ]; then
composer install -n --prefer-dist
else
composer install -n --prefer-dist --ignore-platform-req=php
fi

- save_cache:
key: composer-deps-<<parameters.version>>-{{ checksum "composer.json" }}
Expand All @@ -51,7 +66,7 @@ jobs:
- run:
name: Install PHP Client
command: |
if [ "<<parameters.http_client>>" == "legacy" ]
if [ "<<parameters.http_client>>" == "default" ]
then
echo "Nothing to install, using default Algolia\AlgoliaSearch\Http\Php53HttpClient"
else
Expand All @@ -64,14 +79,25 @@ jobs:

- run:
name: Check code styles
command: vendor/bin/php-cs-fixer fix -v --dry-run
command: |
if [ "<<parameters.version>>" != "8.0" ]; then
vendor/bin/php-cs-fixer fix -v --dry-run
fi

- run:
name: Patch PHPUnit tests
command: |
if [[ "<<parameters.version>>" == "7.4" || "<<parameters.version>>" == "8.0" ]]; then
./.circleci/apply-phpunit-patches.sh
fi

# Run tests with phpunit
#
# If the PR is open by an Algolia, we run all the tests
# with the keys in the env variables
# If the PR was open from a fork (community PR)
# we get API keys from the API key dealer https://alg.li/api-key-dealer

- run:
name: Run tests
command: |
Expand All @@ -83,47 +109,71 @@ jobs:
export CI_PROJ_USERNAME=$CIRCLE_PROJECT_USERNAME
export CI_PROJ_REPONAME=$CIRCLE_PROJECT_REPONAME

eval $(./algolia-keys export)
php vendor/bin/phpunit -v --testsuite Unit,Definition,Community
eval $(./algolia-keys export) && php vendor/bin/phpunit -v --testsuite Unit,Definition,Community
fi

- run:
name: Autoloading without Composer
command: php tests/tests-no-composer.php
command: |
export CI_BUILD_NUM=$CIRCLE_BUILD_NUM
if [ -z ${CIRCLE_PR_REPONAME+x} ]
then
php vendor/bin/phpunit
else
export CI_PROJ_USERNAME=$CIRCLE_PROJECT_USERNAME
export CI_PROJ_REPONAME=$CIRCLE_PROJECT_REPONAME

eval $(./algolia-keys export) && php tests/tests-no-composer.php
fi


workflows:
workflow:
jobs:
- test:
version: "latest"
name: "PHP 8.0 - Guzzle 7"
image: cimg/php
version: "8.0"
http_client: guzzlehttp/guzzle:"^7.0"
- test:
name: "PHP 7.4 - Guzzle 7"
image: cimg/php
version: "7.4"
http_client: guzzlehttp/guzzle:"^7.0"

- test:
version: "latest"
http_client: guzzlehttp/guzzle:"^6.0"
- test:
name: "PHP 7.4 - Guzzle 6"
image: cimg/php
version: "7.4"
http_client: guzzlehttp/guzzle:"^6.0"
- test:
name: "PHP 7.0 - Guzzle 6"
image: circleci/php
version: "7.0"
http_client: guzzlehttp/guzzle:"^6.0"
- test:
name: "PHP 5.6 - Guzzle 6"
image: cimg/php
version: "5.6"
http_client: guzzlehttp/guzzle:"^6.0"

- test:
version: "latest"
http_client: legacy
name: "PHP 8.0 - Default client"
image: cimg/php
version: "8.0"
http_client: default
- test:
name: "PHP 7.4 - Default client"
image: cimg/php
version: "7.4"
http_client: legacy
http_client: default
- test:
name: "PHP 7.0 - Default client"
image: circleci/php
version: "7.0"
http_client: legacy
http_client: default
- test:
name: "PHP 5.6 - Default client"
image: cimg/php
version: "5.6"
http_client: legacy
http_client: default
4 changes: 3 additions & 1 deletion .gitattributes
Expand Up @@ -2,16 +2,18 @@

/docs export-ignore
/tests export-ignore
/.circleci export-ignore
/.github export-ignore
.editorconfig export-ignore
.gitattributes export-ignore
.gitignore export-ignore
.php_cs export-ignore
.php_cs.dist export-ignore
.styleci.yml export-ignore
.travis.yml export-ignore
CHANGELOG.md export-ignore
CONTRIBUTING.md export-ignore
DOCKER_README.md export-ignore
MAINTAINERS.md export-ignore
phpunit.xml.dist export-ignore
README.md export-ignore
SECURITY.md export-ignore
6 changes: 5 additions & 1 deletion CHANGELOG.md
Expand Up @@ -8,6 +8,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/).

## [Unreleased](https://github.com/algolia/algoliasearch-client-php/compare/2.7.2...master)

### Added
- PHP 8 Support

julienbourdeau marked this conversation as resolved.
Show resolved Hide resolved

## [v2.7.2](https://github.com/algolia/algoliasearch-client-php/compare/2.7.1...2.7.2)

### Chore
Expand All @@ -16,7 +20,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
## [v2.7.1](https://github.com/algolia/algoliasearch-client-php/compare/2.7.0...2.7.1)

### Fix
- Enable `JSON_UNESCAPED_UNICODE` option for requests bodies JSON encoding.
- Enable `JSON_UNESCAPED_UNICODE` option for requests bodies JSON encoding.

## [v2.7.0](https://github.com/algolia/algoliasearch-client-php/compare/2.6.2...2.7.0)

Expand Down
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -6,7 +6,7 @@
<h4 align="center">The perfect starting point to integrate <a href="https://algolia.com" target="_blank">Algolia</a> within your PHP project</h4>

<p align="center">
<a href="https://travis-ci.org/algolia/algoliasearch-client-php"><img src="https://img.shields.io/travis/algolia/algoliasearch-client-php/master.svg" alt="Build Status"></a>
<a href="https://circleci.com/gh/algolia/algoliasearch-client-php"><img src="https://circleci.com/gh/algolia/algoliasearch-client-php.svg?style=shield" alt="CircleCI" /></a>
<a href="https://packagist.org/packages/algolia/algoliasearch-client-php"><img src="https://poser.pugx.org/algolia/algoliasearch-client-php/d/total.svg" alt="Total Downloads"></a>
<a href="https://packagist.org/packages/algolia/algoliasearch-client-php"><img src="https://poser.pugx.org/algolia/algoliasearch-client-php/v/stable.svg" alt="Latest Version"></a>
<a href="https://packagist.org/packages/algolia/algoliasearch-client-php"><img src="https://poser.pugx.org/algolia/algoliasearch-client-php/license.svg" alt="License"></a>
Expand Down
8 changes: 4 additions & 4 deletions composer.json
Expand Up @@ -11,7 +11,7 @@
}
],
"require": {
"php": "^5.3 || ^7.0",
"php": "^5.3 || ^7.0 || ^8.0",
"ext-curl": "*",
"ext-json": "*",
"ext-mbstring": "*",
Expand All @@ -20,9 +20,9 @@
"psr/simple-cache": "^1.0"
},
"require-dev": {
"friendsofphp/php-cs-fixer": "^2.0",
"fzaninotto/faker": "^1.8",
"phpunit/phpunit": "^4.8",
"friendsofphp/php-cs-fixer": "^2.17.1",
"fakerphp/faker": "^1.9.1",
"phpunit/phpunit": "^4.8 || ^8.5",
"symfony/yaml": "^2.0 || ^4.0"
},
"autoload": {
Expand Down