From 9d4da7a730b6e96f0abc7f699338b44a2aaba09f Mon Sep 17 00:00:00 2001 From: William Desportes Date: Sun, 5 Sep 2021 21:56:15 +0200 Subject: [PATCH 1/4] Add phpbench Signed-off-by: William Desportes --- composer.json | 2 + phpbench.json | 4 ++ tests/benchmarks/UtfStringBench.php | 67 +++++++++++++++++++++++++++++ 3 files changed, 73 insertions(+) create mode 100644 phpbench.json create mode 100644 tests/benchmarks/UtfStringBench.php diff --git a/composer.json b/composer.json index 9254b7c70..2fe0fee7c 100644 --- a/composer.json +++ b/composer.json @@ -27,6 +27,7 @@ "symfony/polyfill-php80": "^1.16" }, "require-dev": { + "phpbench/phpbench": "^1.1", "phpmyadmin/coding-standard": "^3.0", "phpmyadmin/motranslator": "^4.0 || ^5.0", "phpstan/extension-installer": "^1.1", @@ -66,6 +67,7 @@ "phpstan": "@php phpstan analyse", "psalm": "@php psalm --no-diff", "phpunit": "@php phpunit --color=always", + "phpbench": "@php phpbench run tests/benchmarks --report=aggregate --progress=dots", "test": [ "@phpcs", "@phpstan", diff --git a/phpbench.json b/phpbench.json new file mode 100644 index 000000000..d2d14113a --- /dev/null +++ b/phpbench.json @@ -0,0 +1,4 @@ +{ + "$schema": "./vendor/phpbench/phpbench/phpbench.schema.json", + "runner.bootstrap": "vendor/autoload.php" +} diff --git a/tests/benchmarks/UtfStringBench.php b/tests/benchmarks/UtfStringBench.php new file mode 100644 index 000000000..1bc9ac61a --- /dev/null +++ b/tests/benchmarks/UtfStringBench.php @@ -0,0 +1,67 @@ + 20 milliseconds +/- 10%") + */ + public function benchBuildUtfString(): void + { + $str1 = new UtfString($this->testContents); + for ($i = 0; $i < $str1->length(); $i++) { + $str1[$i];// Make offset offsetGet work + } + } + + /** + * @BeforeMethods("setUp") + * @Iterations(2) + * @Revs(2) + * @OutputTimeUnit("microseconds") + * @Assert("mode(variant.time.avg) < 75 microseconds +/- 10%") + * @Assert("mode(variant.time.avg) > 60 microseconds +/- 10%") + */ + public function benchGetCharLength(): void + { + UtfString::getCharLength(chr(0x00)); // 00000000 + UtfString::getCharLength(chr(0x7F)); // 01111111 + + UtfString::getCharLength(chr(0xC0)); // 11000000 + UtfString::getCharLength(chr(0xDF)); // 11011111 + + UtfString::getCharLength(chr(0xE0)); // 11100000 + UtfString::getCharLength(chr(0xEF)); // 11101111 + + UtfString::getCharLength(chr(0xF0)); // 11110000 + UtfString::getCharLength(chr(0xF7)); // 11110111 + + UtfString::getCharLength(chr(0xF8)); // 11111000 + UtfString::getCharLength(chr(0xFB)); // 11111011 + + UtfString::getCharLength(chr(0xFC)); // 11111100 + UtfString::getCharLength(chr(0xFD)); // 11111101 + } + + public function setUp(): void + { + $contentsPath = __DIR__ . '/../../LICENSE.txt'; + $this->testContents = (string) file_get_contents($contentsPath); + } +} From e772ddd440eb5aa083c58637c08823a46ae436c8 Mon Sep 17 00:00:00 2001 From: William Desportes Date: Mon, 6 Sep 2021 02:22:51 +0200 Subject: [PATCH 2/4] Adjust .gitattributes Signed-off-by: William Desportes --- .gitattributes | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitattributes b/.gitattributes index 6b2be045a..8f13f6eba 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,4 +1,5 @@ /tools export-ignore +/tests/benchmarks export-ignore .gitattributes export-ignore .gitignore export-ignore .editorconfig export-ignore @@ -6,6 +7,7 @@ .weblate export-ignore .scrutinizer.yml export-ignore infection.json.dist export-ignore +phpbench.json export-ignore phpcs.xml.dist export-ignore phpstan.neon.dist export-ignore phpstan-baseline.neon export-ignore From 85369a2ef3ceab9435658de9e4fc37e0392ff63f Mon Sep 17 00:00:00 2001 From: William Desportes Date: Mon, 6 Sep 2021 02:22:40 +0200 Subject: [PATCH 3/4] Add GitHub workflow Signed-off-by: William Desportes --- .github/workflows/tests.yml | 47 +++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 43cf36663..9a04800d3 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -63,3 +63,50 @@ jobs: if: github.repository == 'phpmyadmin/sql-parser' with: cli-args: "--format=php-clover build/logs/clover.xml --revision=${{ github.event.pull_request.head.sha || github.sha }}" + + php-benchmark: + name: Benchmark on PHP ${{ matrix.php-version }} and ${{ matrix.os }} + runs-on: ${{ matrix.os }} + continue-on-error: ${{ matrix.experimental }} + strategy: + matrix: + php-version: ["7.1", "7.2", "7.3", "7.4", "8.0", "8.1", "8.2"] + os: [ubuntu-latest] + experimental: [false] + composer-options: [''] + include: + - { php-version: 'nightly', experimental: true, os: ubuntu-latest, composer-options: '--ignore-platform-reqs' } + steps: + - uses: actions/checkout@v3 + with: + # Fetch some commits for Scrutinizer coverage upload + fetch-depth: 15 + - name: Use PHP ${{ matrix.php-version }} + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php-version }} + # phar, json and curl are used by composer + # json is used by testing code + # dom, json, mbstring, libxml, xml, xmlwriter are used by phpunit + # tokenizer, xmlwriter and simplexml are used by phpcs + # ctype is used by Psalm + extensions: none, mbstring, phar, json, curl, tokenizer, xml, xmlwriter, simplexml, libxml, dom, ctype + coverage: xdebug + - name: Get Composer Cache Directory + id: composer-cache + run: | + echo "::set-output name=dir::$(composer config cache-files-dir)" + - name: Restore cache + uses: actions/cache@v3 + with: + path: ${{ steps.composer-cache.outputs.dir }} + key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} + restore-keys: | + ${{ runner.os }}-composer- + - name: Install dependencies + run: composer install --no-interaction ${{ matrix.composer-options }} + - name: Install motranslator + if: ${{ matrix.php-version == '7.1' }} + run: composer require phpmyadmin/motranslator:^3.0 + - name: Run benchmarks + run: composer run phpbench From b163fc1e5f06522e119932406ff4c220597427e4 Mon Sep 17 00:00:00 2001 From: William Desportes Date: Fri, 6 Jan 2023 09:22:32 +0400 Subject: [PATCH 4/4] Drop PHP 7.1 support Signed-off-by: William Desportes --- .github/workflows/lint-and-analyse-php.yml | 4 ++-- .github/workflows/tests.yml | 12 ++++++------ .scrutinizer.yml | 2 +- CHANGELOG.md | 1 + composer.json | 2 +- 5 files changed, 11 insertions(+), 10 deletions(-) diff --git a/.github/workflows/lint-and-analyse-php.yml b/.github/workflows/lint-and-analyse-php.yml index dd45042bb..c0168cc95 100644 --- a/.github/workflows/lint-and-analyse-php.yml +++ b/.github/workflows/lint-and-analyse-php.yml @@ -13,10 +13,10 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - - name: Use php 7.1 + - name: Use php 7.2 uses: shivammathur/setup-php@v2 with: - php-version: 7.1 + php-version: 7.2 tools: composer:v2 - name: Validate composer.json and composer.lock run: composer validate diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 9a04800d3..3e77f23fd 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -15,7 +15,7 @@ jobs: continue-on-error: ${{ matrix.experimental }} strategy: matrix: - php-version: ["7.1", "7.2", "7.3", "7.4", "8.0", "8.1", "8.2"] + php-version: ["7.2", "7.3", "7.4", "8.0", "8.1", "8.2"] os: [ubuntu-latest] experimental: [false] composer-options: [''] @@ -51,8 +51,8 @@ jobs: - name: Install dependencies run: composer install --no-interaction ${{ matrix.composer-options }} - name: Install motranslator - if: ${{ matrix.php-version == '7.1' }} - run: composer require phpmyadmin/motranslator:^3.0 + if: ${{ matrix.php-version == '7.2' }} + run: composer require phpmyadmin/motranslator:^3.0 --with-all-dependencies --no-interaction - name: Run php tests run: composer run phpunit - name: Send coverage @@ -70,7 +70,7 @@ jobs: continue-on-error: ${{ matrix.experimental }} strategy: matrix: - php-version: ["7.1", "7.2", "7.3", "7.4", "8.0", "8.1", "8.2"] + php-version: ["7.2", "7.3", "7.4", "8.0", "8.1", "8.2"] os: [ubuntu-latest] experimental: [false] composer-options: [''] @@ -106,7 +106,7 @@ jobs: - name: Install dependencies run: composer install --no-interaction ${{ matrix.composer-options }} - name: Install motranslator - if: ${{ matrix.php-version == '7.1' }} - run: composer require phpmyadmin/motranslator:^3.0 + if: ${{ matrix.php-version == '7.2' }} + run: composer require phpmyadmin/motranslator:^3.0 --with-all-dependencies --no-interaction - name: Run benchmarks run: composer run phpbench diff --git a/.scrutinizer.yml b/.scrutinizer.yml index ee8f714d3..9c1cf8527 100644 --- a/.scrutinizer.yml +++ b/.scrutinizer.yml @@ -17,7 +17,7 @@ build: nodes: analysis: environment: - php: 7.1 + php: 7.2 dependencies: before: - composer install diff --git a/CHANGELOG.md b/CHANGELOG.md index 8f388d509..23fd31b99 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ * Performance improvement to use less the `nextToken()` function (#397) * Lexer - Solving ambiguity on function keywords (#385) +* Drop PHP 7.1 support ## [5.6.0] - 2023-01-02 diff --git a/composer.json b/composer.json index 2fe0fee7c..6f35e098e 100644 --- a/composer.json +++ b/composer.json @@ -22,7 +22,7 @@ } ], "require": { - "php": "^7.1 || ^8.0", + "php": "^7.2 || ^8.0", "symfony/polyfill-mbstring": "^1.3", "symfony/polyfill-php80": "^1.16" },