From 5e248cf12d24bb92d5d9f765f731dbde41ea17e9 Mon Sep 17 00:00:00 2001 From: oleibman <10341515+oleibman@users.noreply.github.com> Date: Sun, 11 Aug 2024 08:24:27 -0700 Subject: [PATCH] Better Workaround for Versions "Error" PHPCompatibility (versions check) erroneously flags the use of $this in enumerations. They fixed it in their development branch in October 2022. But they haven't had a release since 2019! --- .github/workflows/main.yml | 2 +- .../Style/NumberFormat/Wizard/CurrencyNegative.php | 7 ------- 2 files changed, 1 insertion(+), 8 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 9af1e0944..4a9c4d22b 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -173,7 +173,7 @@ jobs: run: composer install --no-progress --prefer-dist --optimize-autoloader - name: Code Version Compatibility check with PHP_CodeSniffer - run: ./vendor/bin/phpcs -q --report-width=200 --report=summary,full src/ --standard=PHPCompatibility --runtime-set testVersion 8.1- + run: ./vendor/bin/phpcs -q --report-width=200 --report=summary,full src/ --standard=PHPCompatibility --runtime-set testVersion 8.1- --exclude=PHPCompatibility.Variables.ForbiddenThisUseContexts phpstan: runs-on: ubuntu-latest diff --git a/src/PhpSpreadsheet/Style/NumberFormat/Wizard/CurrencyNegative.php b/src/PhpSpreadsheet/Style/NumberFormat/Wizard/CurrencyNegative.php index 72d4ee727..d075d80af 100644 --- a/src/PhpSpreadsheet/Style/NumberFormat/Wizard/CurrencyNegative.php +++ b/src/PhpSpreadsheet/Style/NumberFormat/Wizard/CurrencyNegative.php @@ -4,17 +4,11 @@ namespace PhpOffice\PhpSpreadsheet\Style\NumberFormat\Wizard; enum CurrencyNegative { - // PHPCompatibility (versions check) has an error which - // causes it to flag the use of $this below as erroneous. - // They fixed it in their development branch in October 2022. - // But they haven't had a release since 2019! - // Hence the phpcs disable statment below. case minus; case redMinus; case parentheses; case redParentheses; - // phpcs:disable PHPCompatibility.Variables.ForbiddenThisUseContexts public function start(): string { return match ($this) { @@ -38,5 +32,4 @@ enum CurrencyNegative self::parentheses, self::minus => '', }; } - // phpcs:enable }