From 6e47f165e927db7debbe5aca10d03e601b1f2286 Mon Sep 17 00:00:00 2001 From: Daniel Siepmann Date: Tue, 22 Sep 2020 13:03:37 +0200 Subject: [PATCH] Add PHP 7.2 compatibility Also ensure code works in all compatibilities via GitHub Actions. Also add further checks like XML compatibility, CGL, etc. --- .github/workflows/ci.yaml | 158 +++++++++++++++++++ Classes/Backend/Preview.php | 3 + Resources/Private/Language/locallang_be.xlf | 6 +- Resources/Private/Language/locallang_tca.xlf | 4 +- composer.json | 19 ++- ext_emconf.php | 1 + phpcs.xml.dist | 14 +- phpstan.neon | 19 +-- 8 files changed, 185 insertions(+), 39 deletions(-) create mode 100644 .github/workflows/ci.yaml diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml new file mode 100644 index 0000000..5f99865 --- /dev/null +++ b/.github/workflows/ci.yaml @@ -0,0 +1,158 @@ +name: CI +on: [push] +jobs: + check-composer: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + + - name: Validate composer.json + run: composer validate + + php-linting: + runs-on: ubuntu-latest + strategy: + matrix: + php-version: + - 7.2 + - 7.3 + - 7.4 + steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: Install PHP + uses: shivammathur/setup-php@v2 + with: + php-version: "${{ matrix.php-version }}" + + - name: PHP lint + run: "find *.php Classes Configuration -name '*.php' -print0 | xargs -0 -n 1 -P 4 php -l" + + check-cgl: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + + - name: Get Composer Cache Directory + id: composer-cache + run: | + echo "::set-output name=dir::$(composer config cache-files-dir)" + + - uses: actions/cache@v1 + 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 --prefer-dist --no-progress --no-suggest + + - name: Check CGL + run: ./vendor/bin/phpcs + + check-dependencies: + runs-on: ubuntu-latest + needs: [check-composer] + steps: + - uses: actions/checkout@v2 + + - name: Get Composer Cache Directory + id: composer-cache + run: | + echo "::set-output name=dir::$(composer config cache-files-dir)" + + - uses: actions/cache@v1 + 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 --prefer-dist --no-progress --no-suggest --no-plugins + + - name: Missing composer requirements + run: ./vendor/bin/composer-require-checker check + + xml-linting: + runs-on: ubuntu-latest + needs: [check-composer] + steps: + - uses: actions/checkout@v2 + + - name: Install xmllint + run: sudo apt-get install libxml2-utils + + - name: Get Composer Cache Directory + id: composer-cache + run: | + echo "::set-output name=dir::$(composer config cache-files-dir)" + + - uses: actions/cache@v1 + 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 --prefer-dist --no-progress --no-suggest + + - name: PHPCodeSniffer configuration file + run: xmllint --schema vendor/squizlabs/php_codesniffer/phpcs.xsd --noout phpcs.xml.dist + + - name: Fetch schema for xliff + run: wget https://docs.oasis-open.org/xliff/v1.2/os/xliff-core-1.2-strict.xsd --output-document=.Build/xliff-core-1.2-strict.xsd + + - name: TYPO3 language files + run: xmllint --schema .Build/xliff-core-1.2-strict.xsd --noout $(find Resources -name '*.xlf') + + code-quality: + runs-on: ubuntu-latest + needs: [check-dependencies] + steps: + - uses: actions/checkout@v2 + + - name: Get Composer Cache Directory + id: composer-cache + run: | + echo "::set-output name=dir::$(composer config cache-files-dir)" + + - uses: actions/cache@v1 + 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 --prefer-dist --no-progress --no-suggest + + - name: Code Quality (by PHPStan) + run: ./vendor/bin/phpstan analyse + + security-test: + runs-on: ubuntu-latest + needs: [check-dependencies] + steps: + - uses: actions/checkout@v2 + + - name: Get Composer Cache Directory + id: composer-cache + run: | + echo "::set-output name=dir::$(composer config cache-files-dir)" + + - uses: actions/cache@v1 + 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 --prefer-dist --no-progress --no-suggest + + - name: PHP Security test + run: ./vendor/bin/security-checker security:check --no-ansi diff --git a/Classes/Backend/Preview.php b/Classes/Backend/Preview.php index 135af10..4de0e68 100644 --- a/Classes/Backend/Preview.php +++ b/Classes/Backend/Preview.php @@ -39,6 +39,9 @@ class Preview implements PageLayoutViewDrawItemHookInterface $this->skillApi = $skillApi; } + /** + * @return void + */ public function preProcess( PageLayoutView &$parentObject, &$drawItem, diff --git a/Resources/Private/Language/locallang_be.xlf b/Resources/Private/Language/locallang_be.xlf index 1673611..6f627d9 100644 --- a/Resources/Private/Language/locallang_be.xlf +++ b/Resources/Private/Language/locallang_be.xlf @@ -1,6 +1,6 @@ - - - + + +
diff --git a/Resources/Private/Language/locallang_tca.xlf b/Resources/Private/Language/locallang_tca.xlf index 5db767b..152a116 100644 --- a/Resources/Private/Language/locallang_tca.xlf +++ b/Resources/Private/Language/locallang_tca.xlf @@ -1,6 +1,6 @@ - - + +
diff --git a/composer.json b/composer.json index 98532d7..ac79e2f 100644 --- a/composer.json +++ b/composer.json @@ -3,11 +3,17 @@ "description": "SkillDisplay integration for TYPO3", "type": "typo3-cms-extension", "license": "GPL-2.0-or-later", - "homepage": "https://daniel-siepmann.de/projects/typo3-extension-skilldisplay.html", + "homepage": "https://github.com/SkillDisplay/TYPO3ContentElements", + "repositories": [ + { + "type": "vcs", + "url": "git@github.com:DanielSiepmann/PHPToolKit.git" + } + ], "support": { "email": "coding@daniel-siepmann.de", - "source": "https://github.com/DanielSiepmann/SkillDisplay/", - "issues": "https://github.com/DanielSiepmann/SkillDisplay/issues" + "source": "https://github.com/SkillDisplay/TYPO3ContentElements", + "issues": "https://github.com/SkillDisplay/TYPO3ContentElements/issues" }, "authors": [ { @@ -26,11 +32,12 @@ } }, "require": { - "php": "^7.3.0", + "php": "7.2.* || 7.3.* || 7.4.*", "typo3/cms-core": "^10.4", - "skilldisplay/phptoolkit": "^1.0", + "skilldisplay/phptoolkit": "dev-feature/improve-api as v1.0.x-dev", "typo3/cms-backend": "^10.4", - "typo3/cms-frontend": "^10.4" + "typo3/cms-frontend": "^10.4", + "typo3fluid/fluid": "^2.6" }, "require-dev": { "squizlabs/php_codesniffer": "^3.5", diff --git a/ext_emconf.php b/ext_emconf.php index 041bb16..b0024a4 100644 --- a/ext_emconf.php +++ b/ext_emconf.php @@ -1,4 +1,5 @@ 'SkillDisplay', 'description' => 'Integrates SkillDisplay', diff --git a/phpcs.xml.dist b/phpcs.xml.dist index 68b095a..1a01c0b 100644 --- a/phpcs.xml.dist +++ b/phpcs.xml.dist @@ -3,17 +3,9 @@ This project coding standard Classes/ - Tests/ + Configuration/ + ext_emconf.php + ext_localconf.php - - - - - - - - - /Tests/* - diff --git a/phpstan.neon b/phpstan.neon index 22b9fa5..9cd632b 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -2,22 +2,7 @@ parameters: level: max paths: - Classes - - Tests + - Configuration + - ext_localconf.php checkMissingIterableValueType: false reportUnmatchedIgnoredErrors: true - ignoreErrors: - - '#Cannot call method fetch\(\) on Doctrine\\DBAL\\Driver\\Statement\|int\.#' - - '#Cannot call method fetchAll\(\) on Doctrine\\DBAL\\Driver\\Statement\|int\.#' - - '#Cannot call method fetchColumn\(\) on Doctrine\\DBAL\\Driver\\Statement\|int\.#' - - - message: '#\$timestamp of function date expects int, int\|false given\.#' - path: Classes/Dashboard/Provider/PageviewsPerDay.php - count: 1 - - - message: '#Parameter \#1 \$start of method DanielSiepmann\\Tracking\\Dashboard\\Provider\\PageviewsPerDay::getPageviewsInPeriod\(\) expects int, int\|false given\.#' - path: Classes/Dashboard/Provider/PageviewsPerDay.php - count: 1 - - - message: '#Parameter \#2 \$end of method DanielSiepmann\\Tracking\\Dashboard\\Provider\\PageviewsPerDay::getPageviewsInPeriod\(\) expects int, int\|false given\.#' - path: Classes/Dashboard/Provider/PageviewsPerDay.php - count: 1