Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 24 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,30 @@ jobs:
- "8.3"
- "8.4"
- "8.5"
php-stan:
name: PHPStan code quality checks
runs-on: ubuntu-24.04
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Show the Composer version
run: ./Build/Scripts/runTests.sh -s composer -- --version
- name: Show the Composer configuration
run: ./Build/Scripts/runTests.sh -s composer config --global --list
- name: Install composer dependencies
run: |
./Build/Scripts/runTests.sh -p ${{ matrix.php-version }} -t ${{matrix.typo3-version}} -s composerUpdateMax
- name: Run phpstan code quality checks
run: |
./Build/Scripts/runTests.sh -p ${{ matrix.php-version }} -t ${{matrix.typo3-version}} -s phpstan
strategy:
fail-fast: false
matrix:
include:
- typo3-version: "12.4"
php-version: "8.2"
- typo3-version: "13.4"
php-version: "8.2"
code-quality:
name: Code quality checks
runs-on: ubuntu-24.04
Expand All @@ -56,7 +80,6 @@ jobs:
- "json:lint"
- "php:cs-fixer"
- "php:rector"
- "php:stan"
- "typoscript:lint"
- "xliff:lint"
- "yaml:lint"
Expand Down
10 changes: 6 additions & 4 deletions Build/Scripts/runTests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -677,13 +677,15 @@ case ${TEST_SUITE} in
SUITE_EXIT_CODE=$?
;;
phpstan)
COMMAND="composer check:php:stan"
${CONTAINER_BIN} run ${CONTAINER_COMMON_PARAMS} --name composer-command-${SUFFIX} -e COMPOSER_CACHE_DIR=.cache/composer -e COMPOSER_ROOT_VERSION=${COMPOSER_ROOT_VERSION} ${IMAGE_PHP} /bin/sh -c "${COMMAND}"
PHPSTAN_CONFIG_FILE="Build/phpstan/TYPO3_${CORE_VERSION}/phpstan.neon"
COMMAND=(php -dxdebug.mode=off .Build/bin/phpstan analyse -c ${PHPSTAN_CONFIG_FILE} --no-progress --no-interaction --memory-limit 4G "$@")
${CONTAINER_BIN} run ${CONTAINER_COMMON_PARAMS} --name phpstan-${SUFFIX} -e COMPOSER_CACHE_DIR=.cache/composer -e COMPOSER_ROOT_VERSION=${COMPOSER_ROOT_VERSION} ${IMAGE_PHP} "${COMMAND[@]}"
SUITE_EXIT_CODE=$?
;;
phpstanGenerateBaseline)
COMMAND="composer phpstan:baseline"
${CONTAINER_BIN} run ${CONTAINER_COMMON_PARAMS} --name composer-command-${SUFFIX} -e COMPOSER_CACHE_DIR=.cache/composer -e COMPOSER_ROOT_VERSION=${COMPOSER_ROOT_VERSION} ${IMAGE_PHP} /bin/sh -c "${COMMAND}"
PHPSTAN_CONFIG_FILE="Build/phpstan/TYPO3_${CORE_VERSION}/phpstan.neon"
COMMAND=(php -dxdebug.mode=off .Build/bin/phpstan analyse -c ${PHPSTAN_CONFIG_FILE} --no-progress --no-interaction --memory-limit 4G --allow-empty-baseline --generate-baseline=Build/phpstan/TYPO3_${CORE_VERSION}/phpstan-baseline.neon)
${CONTAINER_BIN} run ${CONTAINER_COMMON_PARAMS} --name phpstan-baseline-${SUFFIX} -e COMPOSER_CACHE_DIR=.cache/composer -e COMPOSER_ROOT_VERSION=${COMPOSER_ROOT_VERSION} ${IMAGE_PHP} "${COMMAND[@]}"
SUITE_EXIT_CODE=$?
;;
shellcheck)
Expand Down
2 changes: 2 additions & 0 deletions Build/phpstan/TYPO3_12.4/phpstan-baseline.neon
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
parameters:
ignoreErrors:
6 changes: 6 additions & 0 deletions Build/phpstan/TYPO3_12.4/phpstan.neon
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
includes:
- ../phpstan.neon
- phpstan-baseline.neon

parameters:
phpVersion: 80100
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,22 @@ parameters:
message: '#^Method TTN\\Tea\\Domain\\Repository\\TeaRepository\:\:findAllFromAllPages\(\) return type with generic interface TYPO3\\CMS\\Extbase\\Persistence\\QueryResultInterface does not specify its types\: TKey, TValue$#'
identifier: missingType.generics
count: 1
path: ../../Classes/Domain/Repository/TeaRepository.php
path: ../../../Classes/Domain/Repository/TeaRepository.php

-
message: '#^Method TTN\\Tea\\Domain\\Repository\\TeaRepository\:\:findByOwnerUid\(\) return type with generic interface TYPO3\\CMS\\Extbase\\Persistence\\QueryResultInterface does not specify its types\: TKey, TValue$#'
identifier: missingType.generics
count: 1
path: ../../Classes/Domain/Repository/TeaRepository.php
path: ../../../Classes/Domain/Repository/TeaRepository.php

-
message: '#^Cannot call method getUid\(\) on mixed\.$#'
identifier: method.nonObject
count: 1
path: ../../Tests/Functional/Domain/Repository/TeaRepositoryTest.php
path: ../../../Tests/Functional/Domain/Repository/TeaRepositoryTest.php

-
message: '#^Mixed variable in a `\$result\-\>current\(\)\-\>\.\.\.\(\)` can skip important errors\. Make sure the type is known$#'
identifier: typePerfect.noMixedMethodCaller
count: 1
path: ../../Tests/Functional/Domain/Repository/TeaRepositoryTest.php
path: ../../../Tests/Functional/Domain/Repository/TeaRepositoryTest.php
7 changes: 7 additions & 0 deletions Build/phpstan/TYPO3_13.4/phpstan.neon
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
includes:
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it make sense to move common logic into e.g. /Build/phpstan/phpstan.neon and include it within this file and /Build/phpstan/TYPO3_12.4/phpstan.neon?

That way we would see the common configuration, and ease maintenance.

- ../phpstan.neon
- phpstan-baseline.neon

parameters:
phpVersion: 80200

3 changes: 0 additions & 3 deletions Build/phpstan/phpstan.neon
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
includes:
- phpstan-baseline.neon
- ../../.Build/vendor/spaze/phpstan-disallowed-calls/disallowed-dangerous-calls.neon
- ../../.Build/vendor/spaze/phpstan-disallowed-calls/disallowed-execution-calls.neon
- ../../.Build/vendor/spaze/phpstan-disallowed-calls/disallowed-insecure-calls.neon
- ../../.Build/vendor/spaze/phpstan-disallowed-calls/disallowed-loose-calls.neon

parameters:
phpVersion: 80100

level: 9

paths:
Expand Down
8 changes: 1 addition & 7 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -136,21 +136,18 @@
"check:json:lint": "find . ! -path '*/.cache/*' ! -path '*/.Build/*' ! -path '*/node_modules/*' -name '*.json' | xargs -r php .Build/bin/jsonlint -q",
"check:php": [
"@check:php:cs-fixer",
"@check:php:lint",
"@check:php:stan"
"@check:php:lint"
],
"check:php:cs-fixer": "php-cs-fixer fix --config ./Build/php-cs-fixer/config.php -v --dry-run --diff",
"check:php:lint": "parallel-lint *.php Build Classes Configuration Tests",
"check:php:rector": "rector process --dry-run --config=./Build/rector/config.php",
"check:php:stan": "phpstan --no-progress -v --configuration=Build/phpstan/phpstan.neon",
"check:static": [
"@check:composer:normalize",
"@check:composer:unused",
"@check:json:lint",
"@check:php:lint",
"@check:composer:psr-verify",
"@check:php:rector",
"@check:php:stan",
"@check:php:cs-fixer",
"@check:typoscript:lint",
"@check:xliff:lint",
Expand All @@ -177,7 +174,6 @@
],
"fix:php:cs-fixer": "php-cs-fixer fix --config ./Build/php-cs-fixer/config.php",
"fix:php:rector": "rector process --config=./Build/rector/config.php",
"phpstan:baseline": "phpstan --generate-baseline=Build/phpstan/phpstan-baseline.neon --allow-empty-baseline --configuration=Build/phpstan/phpstan.neon",
"prepare-release": [
"rm -rf .Build",
"rm -rf .ddev",
Expand Down Expand Up @@ -208,7 +204,6 @@
"check:php:lint": "Lints the PHP files for syntax errors.",
"check:php:mess": "Runs PHP mess detection.",
"check:php:rector": "Checks for code for changes by Rector.",
"check:php:stan": "Checks the PHP types using PHPStan.",
"check:static": "Runs all static code checks (syntax, style, types).",
"check:tests:create-directories": "Creates the directories required to smoothely run the functional tests.",
"check:tests:functional": "Runs the functional tests.",
Expand All @@ -222,7 +217,6 @@
"fix:php": "Runs all fixers for the PHP code.",
"fix:php:cs-fixer": "Fixes the code style with PHP-CS-Fixer.",
"fix:php:rector": "Updates the code with Rector.",
"phpstan:baseline": "Updates the PHPStan baseline file to match the code.",
"prepare-release": "Removes development-only files in preparation of a TER release."
}
}
Loading