From b36c26f87fa80be5c0677d0626473067b1c0587d Mon Sep 17 00:00:00 2001 From: remorhaz Date: Tue, 17 Aug 2021 11:16:16 +0300 Subject: [PATCH] IndexMap compatibility issue fixed (#24) --- .github/workflows/build.yml | 59 +++++++++++++++++++++++++++++++++++++ CHANGELOG.md | 4 +++ composer.json | 10 +++---- docker-compose.yml | 7 +++++ php-8.1.Dockerfile | 19 ++++++++++++ src/Value/IndexMap.php | 3 ++ 6 files changed, 97 insertions(+), 5 deletions(-) create mode 100644 .github/workflows/build.yml create mode 100644 php-8.1.Dockerfile diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..17fa1bc --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,59 @@ +name: Build + +on: + pull_request: + branches: + - '*' + push: + branches: + - 'master' + +jobs: + tests: + runs-on: ubuntu-latest + strategy: + matrix: + platform-reqs: + - use-platform-reqs + php-version: + - "7.3" + - "7.4" + - "8.0" + dependencies: + - lowest + - highest + include: + - php-version: "8.1" + platform-reqs: ignore-platform-reqs + dependencies: highest + - php-version: "8.1" + platform-reqs: ignore-platform-reqs + dependencies: lowest + + steps: + - name: Checkout + uses: actions/checkout@v1 + + - name: Install PHP + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php-version }} + + - name: Install lowest dependencies + if: ${{ matrix.dependencies == 'lowest' && matrix.platform-reqs == 'use-platform-reqs' }} + run: composer update --no-interaction --prefer-lowest + + - name: Install lowest dependencies (ignore platform reqs) + if: ${{ matrix.dependencies == 'lowest' && matrix.platform-reqs == 'ignore-platform-reqs' }} + run: composer update --no-interaction --prefer-lowest --ignore-platform-reqs + + - name: Install highest dependencies + if: ${{ matrix.dependencies == 'highest' && matrix.platform-reqs == 'use-platform-reqs' }} + run: composer update --no-interaction + + - name: Install highest dependencies (ignore platform reqs) + if: ${{ matrix.dependencies == 'highest' && matrix.platform-reqs == 'ignore-platform-reqs' }} + run: composer update --no-interaction --ignore-platform-reqs + + - name: Run tests + run: composer test diff --git a/CHANGELOG.md b/CHANGELOG.md index 6c6fd9c..29ac8e8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [Unreleased] +### Fixed +- PHP 8.1 compatibility issue ([#24](./issues/24)). + ## [0.7.5] - 2021-04-10 ### Fixed - Closure moved out from generated query code to prevent memory leak (see https://bugs.php.net/bug.php?id=76982). diff --git a/composer.json b/composer.json index 1a1bb16..fdd12cb 100644 --- a/composer.json +++ b/composer.json @@ -16,17 +16,17 @@ } ], "require": { - "php": "^7.3 | ^8", + "php": "^7.3 || ^8", "ext-intl": "*", "ext-json": "*", - "remorhaz/php-unilex": "^0.4", + "remorhaz/php-unilex": "^0.4.1", "remorhaz/php-json-data": "^0.5.3", - "nikic/php-parser": "^4.10" + "nikic/php-parser": "^4.12" }, "require-dev": { + "infection/infection": "^0.18 || ^0.19 || ^0.20 || ^0.21 || ^0.22 || ^0.23 || ^0.24", "phpunit/phpunit": "^9.5", - "squizlabs/php_codesniffer": "^3.5", - "infection/infection": "^0.18" + "squizlabs/php_codesniffer": "^3.6" }, "autoload": { "psr-4": { diff --git a/docker-compose.yml b/docker-compose.yml index fe68e84..acd7060 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -22,3 +22,10 @@ services: volumes: - .:/app working_dir: /app + php8.1: + build: + context: . + dockerfile: php-8.1.Dockerfile + volumes: + - .:/app + working_dir: /app diff --git a/php-8.1.Dockerfile b/php-8.1.Dockerfile new file mode 100644 index 0000000..a95f759 --- /dev/null +++ b/php-8.1.Dockerfile @@ -0,0 +1,19 @@ +FROM php:8.1-rc-cli + +RUN apt-get update && apt-get install -y \ + zip \ + git \ + libicu-dev && \ + pecl install -f -o xdebug && \ + docker-php-ext-enable xdebug && \ + docker-php-ext-configure intl --enable-intl && \ + docker-php-ext-install intl && \ + echo "xdebug.mode = develop,coverage,debug" >> "$PHP_INI_DIR/conf.d/docker-php-ext-xdebug.ini" && \ + echo "xdebug.max_nesting_level = 1024" >> "$PHP_INI_DIR/conf.d/docker-php-ext-xdebug.ini" + + +ENV COMPOSER_ALLOW_SUPERUSER=1 \ + COMPOSER_PROCESS_TIMEOUT=1200 + +RUN curl --silent --show-error https://getcomposer.org/installer | php -- \ + --install-dir=/usr/bin --filename=composer diff --git a/src/Value/IndexMap.php b/src/Value/IndexMap.php index 984cf36..f3bb790 100644 --- a/src/Value/IndexMap.php +++ b/src/Value/IndexMap.php @@ -4,6 +4,8 @@ namespace Remorhaz\JSON\Path\Value; +use ReturnTypeWillChange; + use function array_keys; use function count; use function in_array; @@ -18,6 +20,7 @@ public function __construct(?int ...$outerIndexes) $this->outerIndexes = $outerIndexes; } + #[ReturnTypeWillChange] public function count() { return count($this->outerIndexes);