From 3f1366f5c8b5d8f7383c568ef023c6a447e056c5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dalibor=20Karlovi=C4=87?= Date: Thu, 16 Mar 2023 18:59:16 +0100 Subject: [PATCH] bump: PHPQA 1.85 (#116) * fix: switch back to sh for all shells * infra: add Analyze to build * fix: docker-compose => docker compose * feat: bump PHPQA image * fix: use make init to streamline config * infra: fix build * infra: fix build * infra: fix build * config: fix common config files --- .gitattributes | 2 + .github/workflows/build.yaml | 16 +- phpstan.baseline.neon | 151 +++++++++++++++ phpstan.neon.dist | 6 +- phpunit.xml.dist | 9 +- psalm.baseline.xml | 179 ++++++++++++++++++ psalm.xml.dist | 25 ++- resources/PHP/common.mk | 2 +- resources/PHP/common/psalm.xml.dist | 2 + resources/Pimcore/application.mk | 28 +-- .../Pimcore/application/phpstan.neon.dist | 6 +- resources/Pimcore/application/psalm.xml.dist | 2 + resources/Pimcore/library.mk | 16 +- resources/YASSG/compat/phpstan.neon.dist | 2 +- resources/YASSG/compat/psalm.xml.dist | 9 +- tests/functional/Common/DefaultTest.php | 2 +- tests/functional/MakefileTestCase.php | 3 +- tests/functional/PHP/LibraryTest.php | 2 +- tests/functional/PHP/PhpTrait.php | 10 +- tests/functional/Pimcore/ApplicationTest.php | 2 +- tests/functional/Pimcore/LibraryTest.php | 2 +- tests/functional/YASSG/CompatTest.php | 2 +- 22 files changed, 415 insertions(+), 63 deletions(-) create mode 100644 phpstan.baseline.neon create mode 100644 psalm.baseline.xml diff --git a/.gitattributes b/.gitattributes index 68242c0..195d20e 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,6 +1,8 @@ +/docs export-ignore /tests export-ignore /.* export-ignore /*dist export-ignore +/*baseline* export-ignore /composer.lock export-ignore /Makefile export-ignore /package.json export-ignore diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 6f4370c..a9ecf5a 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -5,6 +5,18 @@ on: - "main" jobs: + CodeQualityAnalysis: + runs-on: ubuntu-latest + steps: + - + name: Repo checkout + uses: actions/checkout@v3 + - + name: Install dependencies + run: make composer/install + - + name: Run code quality analysis + run: make analyze Test: runs-on: ${{ matrix.operating-system }} strategy: @@ -17,8 +29,8 @@ jobs: with: php-version: 8.2 extensions: mbstring, intl - ini-values: post_max_size=256M, max_execution_time=180 - tools: php-cs-fixer + coverage: xdebug + ini-values: post_max_size=256M, max_execution_time=180, xdebug.mode=develop - name: Repo checkout uses: actions/checkout@v3 diff --git a/phpstan.baseline.neon b/phpstan.baseline.neon new file mode 100644 index 0000000..0eba57a --- /dev/null +++ b/phpstan.baseline.neon @@ -0,0 +1,151 @@ +parameters: + ignoreErrors: + - + message: "#^Method Sigwin\\\\Infra\\\\Test\\\\Functional\\\\Common\\\\DefaultTest\\:\\:getExpectedHelpCommandsExecutionPath\\(\\) return type has no value type specified in iterable type array\\.$#" + count: 1 + path: tests/functional/Common/DefaultTest.php + + - + message: "#^Method Sigwin\\\\Infra\\\\Test\\\\Functional\\\\Common\\\\DefaultTest\\:\\:getExpectedInitPaths\\(\\) return type has no value type specified in iterable type array\\.$#" + count: 1 + path: tests/functional/Common/DefaultTest.php + + - + message: "#^Method Sigwin\\\\Infra\\\\Test\\\\Functional\\\\MakefileTestCase\\:\\:dryRun\\(\\) has parameter \\$args with no value type specified in iterable type array\\.$#" + count: 1 + path: tests/functional/MakefileTestCase.php + + - + message: "#^Method Sigwin\\\\Infra\\\\Test\\\\Functional\\\\MakefileTestCase\\:\\:dryRun\\(\\) return type has no value type specified in iterable type array\\.$#" + count: 1 + path: tests/functional/MakefileTestCase.php + + - + message: "#^Method Sigwin\\\\Infra\\\\Test\\\\Functional\\\\MakefileTestCase\\:\\:execute\\(\\) has parameter \\$args with no value type specified in iterable type array\\.$#" + count: 1 + path: tests/functional/MakefileTestCase.php + + - + message: "#^Method Sigwin\\\\Infra\\\\Test\\\\Functional\\\\MakefileTestCase\\:\\:generateHelpCommandsExecutionPathFixtures\\(\\) return type has no value type specified in iterable type array\\.$#" + count: 1 + path: tests/functional/MakefileTestCase.php + + - + message: "#^Method Sigwin\\\\Infra\\\\Test\\\\Functional\\\\MakefileTestCase\\:\\:generateHelpExecutionPath\\(\\) has parameter \\$additionalFiles with no value type specified in iterable type array\\.$#" + count: 1 + path: tests/functional/MakefileTestCase.php + + - + message: "#^Method Sigwin\\\\Infra\\\\Test\\\\Functional\\\\MakefileTestCase\\:\\:generateHelpExecutionPath\\(\\) has parameter \\$files with no value type specified in iterable type array\\.$#" + count: 1 + path: tests/functional/MakefileTestCase.php + + - + message: "#^Method Sigwin\\\\Infra\\\\Test\\\\Functional\\\\MakefileTestCase\\:\\:generateHelpList\\(\\) has parameter \\$commands with no value type specified in iterable type array\\.$#" + count: 1 + path: tests/functional/MakefileTestCase.php + + - + message: "#^Method Sigwin\\\\Infra\\\\Test\\\\Functional\\\\MakefileTestCase\\:\\:generatePermissionsExecutionPath\\(\\) has parameter \\$dirs with no value type specified in iterable type array\\.$#" + count: 1 + path: tests/functional/MakefileTestCase.php + + - + message: "#^Method Sigwin\\\\Infra\\\\Test\\\\Functional\\\\MakefileTestCase\\:\\:generatePermissionsExecutionPath\\(\\) return type has no value type specified in iterable type array\\.$#" + count: 1 + path: tests/functional/MakefileTestCase.php + + - + message: "#^Method Sigwin\\\\Infra\\\\Test\\\\Functional\\\\MakefileTestCase\\:\\:getExpectedHelpCommandsExecutionPath\\(\\) return type has no value type specified in iterable type array\\.$#" + count: 1 + path: tests/functional/MakefileTestCase.php + + - + message: "#^Method Sigwin\\\\Infra\\\\Test\\\\Functional\\\\MakefileTestCase\\:\\:getExpectedInitPaths\\(\\) return type has no value type specified in iterable type array\\.$#" + count: 1 + path: tests/functional/MakefileTestCase.php + + - + message: "#^Method Sigwin\\\\Infra\\\\Test\\\\Functional\\\\MakefileTestCase\\:\\:getMakefileHelpCommands\\(\\) return type has no value type specified in iterable type array\\.$#" + count: 1 + path: tests/functional/MakefileTestCase.php + + - + message: "#^Method Sigwin\\\\Infra\\\\Test\\\\Functional\\\\MakefileTestCase\\:\\:testMakefileCommandsWork\\(\\) has parameter \\$expected with no value type specified in iterable type array\\.$#" + count: 1 + path: tests/functional/MakefileTestCase.php + + - + message: "#^Property Sigwin\\\\Infra\\\\Test\\\\Functional\\\\MakefileTestCase\\:\\:\\$help type has no value type specified in iterable type array\\.$#" + count: 1 + path: tests/functional/MakefileTestCase.php + + - + message: "#^Property Sigwin\\\\Infra\\\\Test\\\\Functional\\\\MakefileTestCase\\:\\:\\$helpOverride type has no value type specified in iterable type array\\.$#" + count: 1 + path: tests/functional/MakefileTestCase.php + + - + message: "#^Method Sigwin\\\\Infra\\\\Test\\\\Functional\\\\PHP\\\\LibraryTest\\:\\:getExpectedHelpCommandsExecutionPath\\(\\) return type has no value type specified in iterable type array\\.$#" + count: 1 + path: tests/functional/PHP/LibraryTest.php + + - + message: "#^Method Sigwin\\\\Infra\\\\Test\\\\Functional\\\\PHP\\\\LibraryTest\\:\\:getExpectedInitPaths\\(\\) return type has no value type specified in iterable type array\\.$#" + count: 1 + path: tests/functional/PHP/LibraryTest.php + + - + message: "#^Method Sigwin\\\\Infra\\\\Test\\\\Functional\\\\PHP\\\\LibraryTest\\:\\:paths\\(\\) return type has no value type specified in iterable type array\\.$#" + count: 1 + path: tests/functional/PHP/LibraryTest.php + + - + message: "#^Method Sigwin\\\\Infra\\\\Test\\\\Functional\\\\Pimcore\\\\ApplicationTest\\:\\:getExpectedHelpCommandsExecutionPath\\(\\) return type has no value type specified in iterable type array\\.$#" + count: 1 + path: tests/functional/Pimcore/ApplicationTest.php + + - + message: "#^Method Sigwin\\\\Infra\\\\Test\\\\Functional\\\\Pimcore\\\\ApplicationTest\\:\\:getExpectedInitPaths\\(\\) return type has no value type specified in iterable type array\\.$#" + count: 1 + path: tests/functional/Pimcore/ApplicationTest.php + + - + message: "#^Method Sigwin\\\\Infra\\\\Test\\\\Functional\\\\Pimcore\\\\ApplicationTest\\:\\:paths\\(\\) return type has no value type specified in iterable type array\\.$#" + count: 1 + path: tests/functional/Pimcore/ApplicationTest.php + + - + message: "#^Method Sigwin\\\\Infra\\\\Test\\\\Functional\\\\Pimcore\\\\LibraryTest\\:\\:getExpectedHelpCommandsExecutionPath\\(\\) return type has no value type specified in iterable type array\\.$#" + count: 1 + path: tests/functional/Pimcore/LibraryTest.php + + - + message: "#^Method Sigwin\\\\Infra\\\\Test\\\\Functional\\\\Pimcore\\\\LibraryTest\\:\\:getExpectedInitPaths\\(\\) return type has no value type specified in iterable type array\\.$#" + count: 1 + path: tests/functional/Pimcore/LibraryTest.php + + - + message: "#^Method Sigwin\\\\Infra\\\\Test\\\\Functional\\\\Pimcore\\\\LibraryTest\\:\\:paths\\(\\) return type has no value type specified in iterable type array\\.$#" + count: 1 + path: tests/functional/Pimcore/LibraryTest.php + + - + message: "#^Method Sigwin\\\\Infra\\\\Test\\\\Functional\\\\YASSG\\\\CompatTest\\:\\:getExpectedHelpCommandsExecutionPath\\(\\) return type has no value type specified in iterable type array\\.$#" + count: 1 + path: tests/functional/YASSG/CompatTest.php + + - + message: "#^Method Sigwin\\\\Infra\\\\Test\\\\Functional\\\\YASSG\\\\CompatTest\\:\\:getExpectedInitPaths\\(\\) return type has no value type specified in iterable type array\\.$#" + count: 1 + path: tests/functional/YASSG/CompatTest.php + + - + message: "#^Method Sigwin\\\\Infra\\\\Test\\\\Functional\\\\YASSG\\\\CompatTest\\:\\:paths\\(\\) return type has no value type specified in iterable type array\\.$#" + count: 1 + path: tests/functional/YASSG/CompatTest.php + + - + message: "#^Property Sigwin\\\\Infra\\\\Test\\\\Functional\\\\YASSG\\\\CompatTest\\:\\:\\$helpOverride type has no value type specified in iterable type array\\.$#" + count: 1 + path: tests/functional/YASSG/CompatTest.php diff --git a/phpstan.neon.dist b/phpstan.neon.dist index d7d42dd..cc73114 100644 --- a/phpstan.neon.dist +++ b/phpstan.neon.dist @@ -3,13 +3,13 @@ includes: - /tools/.composer/vendor-bin/phpstan/vendor/phpstan/phpstan-strict-rules/rules.neon - /tools/.composer/vendor-bin/phpstan/vendor/phpstan/phpstan-phpunit/extension.neon - /tools/.composer/vendor-bin/phpstan/vendor/phpstan/phpstan-symfony/extension.neon + - phpstan.baseline.neon parameters: - checkMissingIterableValueType: false - checkGenericClassInNonGenericObjectType: false + tmpDir: %currentWorkingDirectory%/var/phpqa/phpstan level: max paths: - ./ excludePaths: - - resources/PHP/php-cs-fixer.php + - resources/ - var/ - vendor/ diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 1396922..f4e5825 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,22 +1,25 @@ - tests + ./tests diff --git a/psalm.baseline.xml b/psalm.baseline.xml new file mode 100644 index 0000000..a34e554 --- /dev/null +++ b/psalm.baseline.xml @@ -0,0 +1,179 @@ + + + + + array + array + + + $command + $command + $command + $dir + $dir + $dir + $dir + $dir + $dir + $dir + $dir + $dir + $files + helpOverride[$command] ?? $this->help[$command] ?? '']]> + + + $files + $files + normalize($item))); + }]]> + + + $command + $command + $dir + $path + + + array + + + + + $mkdir + $mkdir + $mkdir + $mkdir + $test + $test + paths()['analyze']]]> + paths()['prepareAndAnalyze']]]> + paths()['shell: PHP']]]> + + + $mkdir + $test + + + paths()['analyze']]]> + paths()['mkdir: phpqa']]]> + paths()['prepareAndAnalyze']]]> + paths()['shell: PHP']]]> + paths()['test: unit']]]> + + + + + array + + + + + $clean + $mkdir + $mkdir + $mkdir + $mkdir + $mkdir + $testFunctional + $testFunctional + $testUnit + $testUnit + $testUnit + paths()['analyze']]]> + paths()['mkdir: composer']]]> + paths()['permissions: Pimcore']]]> + paths()['prepareAndAnalyze']]]> + paths()['shell: PHP']]]> + + + $clean + $mkdir + $testFunctional + $testUnit + + + paths()['analyze']]]> + paths()['build: dev']]]> + paths()['build: prod']]]> + paths()['clean: Pimcore application']]]> + paths()['docker compose: start app dev']]]> + paths()['docker compose: start app prod']]]> + paths()['docker compose: start app test']]]> + paths()['docker compose: start app']]]> + paths()['docker compose: stop Pimcore app']]]> + paths()['mkdir: composer']]]> + paths()['mkdir: phpqa']]]> + paths()['permissions: Pimcore']]]> + paths()['prepareAndAnalyze']]]> + paths()['setup: Pimcore app test']]]> + paths()['shell: PHP']]]> + paths()['shell: app']]]> + paths()['test: functional app']]]> + paths()['test: unit']]]> + + + + + $mkdir + $mkdir + $mkdir + $mkdir + $mkdir + $testFunctional + $testFunctional + $testUnit + $testUnit + $testUnit + paths()['analyze']]]> + paths()['docker compose: start library test']]]> + paths()['prepareAndAnalyze']]]> + paths()['setup: Pimcore library test']]]> + paths()['shell: PHP']]]> + paths()['touch']]]> + + + $mkdir + $testFunctional + $testUnit + + + paths()['analyze']]]> + paths()['clean: library']]]> + paths()['docker compose: start library test']]]> + paths()['docker compose: start library test']]]> + paths()['docker compose: stop Pimcore library']]]> + paths()['mkdir: phpqa']]]> + paths()['prepareAndAnalyze']]]> + paths()['setup: Pimcore library test']]]> + paths()['shell: PHP']]]> + paths()['shell: app library']]]> + paths()['test: functional library']]]> + paths()['test: unit']]]> + paths()['touch']]]> + + + + + $mkdir + $mkdir + $mkdir + paths()['analyze']]]> + paths()['prepareAndAnalyze']]]> + paths()['shell: PHP']]]> + + + $mkdir + + + paths()['analyze']]]> + paths()['mkdir: phpqa']]]> + paths()['prepareAndAnalyze']]]> + paths()['shell: PHP']]]> + + + diff --git a/psalm.xml.dist b/psalm.xml.dist index 3bd856f..2189c04 100644 --- a/psalm.xml.dist +++ b/psalm.xml.dist @@ -1,25 +1,30 @@ + findUnusedVariablesAndParams="true" + limitMethodComplexity="true" + restrictReturnTypes="true" + strictBinaryOperands="true"> - - - + + - - - - - + diff --git a/resources/PHP/common.mk b/resources/PHP/common.mk index f8fac5e..4ff1c3a 100644 --- a/resources/PHP/common.mk +++ b/resources/PHP/common.mk @@ -8,7 +8,7 @@ PHP_VERSION=8.1 endif ifndef PHPQA_DOCKER_IMAGE -PHPQA_DOCKER_IMAGE=jakzal/phpqa:1.83.2-php${PHP_VERSION}-alpine +PHPQA_DOCKER_IMAGE=jakzal/phpqa:1.85.2-php${PHP_VERSION}-alpine endif ifndef PHPQA_DOCKER_COMMAND diff --git a/resources/PHP/common/psalm.xml.dist b/resources/PHP/common/psalm.xml.dist index 6a25225..669b0ef 100644 --- a/resources/PHP/common/psalm.xml.dist +++ b/resources/PHP/common/psalm.xml.dist @@ -5,6 +5,8 @@ ensureArrayIntOffsetsExist="true" ensureArrayStringOffsetsExist="true" errorLevel="1" + findUnusedBaselineEntry="true" + findUnusedCode="true" findUnusedPsalmSuppress="true" findUnusedVariablesAndParams="true" limitMethodComplexity="true" diff --git a/resources/Pimcore/application.mk b/resources/Pimcore/application.mk index fefd814..a116ae0 100644 --- a/resources/Pimcore/application.mk +++ b/resources/Pimcore/application.mk @@ -8,7 +8,7 @@ ifneq (,$(wildcard ./.env)) export endif -APP_DOCKER_COMMAND ?= docker-compose exec ${DOCKER_USER} app +APP_DOCKER_COMMAND ?= docker compose exec ${DOCKER_USER} app VERSION ?= latest @@ -28,34 +28,34 @@ build/dev: ## Build app for "dev" target build/prod: ## Build app for "prod" target VERSION=${VERSION} docker buildx bake --load --file docker-compose.yaml --set *.args.BASE_URL=${BASE_URL} --file .infra/docker-buildx/docker-buildx.prod.hcl registry/push: - VERSION=${VERSION} docker-compose push + VERSION=${VERSION} docker compose push registry/pull: - VERSION=${VERSION} docker-compose pull + VERSION=${VERSION} docker compose pull start/dev: secrets ## Start app in "dev" mode - VERSION=${VERSION} docker-compose --file docker-compose.yaml --file .infra/docker-compose/docker-compose.dev.yaml up --detach --remove-orphans --no-build + VERSION=${VERSION} docker compose --file docker-compose.yaml --file .infra/docker-compose/docker-compose.dev.yaml up --detach --remove-orphans --no-build start/prod: secrets ## Start app in "prod" mode - VERSION=${VERSION} docker-compose --file docker-compose.yaml --file .infra/docker-compose/docker-compose.prod.yaml up --detach --remove-orphans --no-build + VERSION=${VERSION} docker compose --file docker-compose.yaml --file .infra/docker-compose/docker-compose.prod.yaml up --detach --remove-orphans --no-build start: secrets ## Start app in APP_ENV mode (defined in .env) - VERSION=${VERSION} docker-compose --file docker-compose.yaml --file .infra/docker-compose/docker-compose.${APP_ENV}.yaml up --detach --remove-orphans --no-build + VERSION=${VERSION} docker compose --file docker-compose.yaml --file .infra/docker-compose/docker-compose.${APP_ENV}.yaml up --detach --remove-orphans --no-build stop: ## Stop app - VERSION=${VERSION} docker-compose --file docker-compose.yaml --file .infra/docker-compose/docker-compose.${APP_ENV}.yaml down --remove-orphans + VERSION=${VERSION} docker compose --file docker-compose.yaml --file .infra/docker-compose/docker-compose.${APP_ENV}.yaml down --remove-orphans sh/app: ## Run application shell - VERSION=${VERSION} docker-compose --file docker-compose.yaml --file .infra/docker-compose/docker-compose.${APP_ENV}.yaml exec ${DOCKER_USER} app bash + VERSION=${VERSION} docker compose --file docker-compose.yaml --file .infra/docker-compose/docker-compose.${APP_ENV}.yaml exec ${DOCKER_USER} app sh clean: ## Clear logs and system cache rm -rf var/admin/* var/cache/* var/log/* var/tmp/* test/behat: - VERSION=${VERSION} docker-compose --file docker-compose.yaml --file .infra/docker-compose/docker-compose.test.yaml exec ${DOCKER_USER} app vendor/bin/behat --colors --strict + VERSION=${VERSION} docker compose --file docker-compose.yaml --file .infra/docker-compose/docker-compose.test.yaml exec ${DOCKER_USER} app vendor/bin/behat --colors --strict setup/test: ## Setup: create a functional test runtime - VERSION=${VERSION} docker-compose --file docker-compose.yaml --file .infra/docker-compose/docker-compose.test.yaml exec ${DOCKER_USER} app bin/console --env test --no-interaction doctrine:database:drop --if-exists --force - VERSION=${VERSION} docker-compose --file docker-compose.yaml --file .infra/docker-compose/docker-compose.test.yaml exec ${DOCKER_USER} app bin/console --env test --no-interaction doctrine:database:create - VERSION=${VERSION} docker-compose --file docker-compose.yaml --file .infra/docker-compose/docker-compose.test.yaml exec ${DOCKER_USER} app vendor/bin/pimcore-install --env test --no-interaction --ignore-existing-config --skip-database-config - VERSION=${VERSION} docker-compose --file docker-compose.yaml --file .infra/docker-compose/docker-compose.test.yaml exec ${DOCKER_USER} app bin/console --env test --no-interaction sigwin:testing:setup + VERSION=${VERSION} docker compose --file docker-compose.yaml --file .infra/docker-compose/docker-compose.test.yaml exec ${DOCKER_USER} app bin/console --env test --no-interaction doctrine:database:drop --if-exists --force + VERSION=${VERSION} docker compose --file docker-compose.yaml --file .infra/docker-compose/docker-compose.test.yaml exec ${DOCKER_USER} app bin/console --env test --no-interaction doctrine:database:create + VERSION=${VERSION} docker compose --file docker-compose.yaml --file .infra/docker-compose/docker-compose.test.yaml exec ${DOCKER_USER} app vendor/bin/pimcore-install --env test --no-interaction --ignore-existing-config --skip-database-config + VERSION=${VERSION} docker compose --file docker-compose.yaml --file .infra/docker-compose/docker-compose.test.yaml exec ${DOCKER_USER} app bin/console --env test --no-interaction sigwin:testing:setup start/test: secrets ## Start app in "test" mode - VERSION=${VERSION} docker-compose --file docker-compose.yaml --file .infra/docker-compose/docker-compose.test.yaml up --detach --remove-orphans --no-build + VERSION=${VERSION} docker compose --file docker-compose.yaml --file .infra/docker-compose/docker-compose.test.yaml up --detach --remove-orphans --no-build setup/filesystem: ${HOME}/.composer clean config/pimcore/classes public/var/assets public/var/tmp var/admin var/application-logger var/cache var/config var/email var/log var/tmp var/versions ## Setup: filesystem (var, public/var folders) config/pimcore/classes: diff --git a/resources/Pimcore/application/phpstan.neon.dist b/resources/Pimcore/application/phpstan.neon.dist index 3a81bd3..88108ae 100644 --- a/resources/Pimcore/application/phpstan.neon.dist +++ b/resources/Pimcore/application/phpstan.neon.dist @@ -8,11 +8,7 @@ parameters: tmpDir: %currentWorkingDirectory%/var/phpqa/phpstan level: max paths: - - ./bin - - ./config - - ./public/index.php - - ./src - - ./templates + - ./ excludePaths: - config/pimcore/classes/ - var/ diff --git a/resources/Pimcore/application/psalm.xml.dist b/resources/Pimcore/application/psalm.xml.dist index 352c6d9..9cf10e9 100644 --- a/resources/Pimcore/application/psalm.xml.dist +++ b/resources/Pimcore/application/psalm.xml.dist @@ -5,6 +5,8 @@ ensureArrayIntOffsetsExist="true" ensureArrayStringOffsetsExist="true" errorLevel="1" + findUnusedBaselineEntry="true" + findUnusedCode="true" findUnusedPsalmSuppress="true" findUnusedVariablesAndParams="true" limitMethodComplexity="true" diff --git a/resources/Pimcore/library.mk b/resources/Pimcore/library.mk index 09a08dc..ec9fed7 100644 --- a/resources/Pimcore/library.mk +++ b/resources/Pimcore/library.mk @@ -20,18 +20,18 @@ test: test/unit test/functional ## Test the codebase ifneq ($(and $(COMPOSE_PROJECT_NAME),$(PIMCORE_KERNEL_CLASS)),) start/test: ## Start app in "test" mode - COMPOSE_PROJECT_NAME=${COMPOSE_PROJECT_NAME} docker-compose --file ${TESTS_RUNTIME_ROOT}/docker-compose.yaml up --detach --remove-orphans --no-build + COMPOSE_PROJECT_NAME=${COMPOSE_PROJECT_NAME} docker compose --file ${TESTS_RUNTIME_ROOT}/docker-compose.yaml up --detach --remove-orphans --no-build stop: ## Stop app - COMPOSE_PROJECT_NAME=${COMPOSE_PROJECT_NAME} docker-compose --file ${TESTS_RUNTIME_ROOT}/docker-compose.yaml down --remove-orphans + COMPOSE_PROJECT_NAME=${COMPOSE_PROJECT_NAME} docker compose --file ${TESTS_RUNTIME_ROOT}/docker-compose.yaml down --remove-orphans sh/app: ## Run application shell - COMPOSE_PROJECT_NAME=${COMPOSE_PROJECT_NAME} docker-compose --file ${TESTS_RUNTIME_ROOT}/docker-compose.yaml exec ${DOCKER_USER} --env PIMCORE_KERNEL_CLASS=${PIMCORE_KERNEL_CLASS} app bash + COMPOSE_PROJECT_NAME=${COMPOSE_PROJECT_NAME} docker compose --file ${TESTS_RUNTIME_ROOT}/docker-compose.yaml exec ${DOCKER_USER} --env PIMCORE_KERNEL_CLASS=${PIMCORE_KERNEL_CLASS} app sh setup/test: start/test .env ## Setup: create a functional test runtime - COMPOSE_PROJECT_NAME=${COMPOSE_PROJECT_NAME} docker-compose --file ${TESTS_RUNTIME_ROOT}/docker-compose.yaml exec ${DOCKER_USER} --env PIMCORE_KERNEL_CLASS=${PIMCORE_KERNEL_CLASS} app php tests/runtime/bootstrap.php --env test --no-interaction doctrine:database:drop --if-exists --force - COMPOSE_PROJECT_NAME=${COMPOSE_PROJECT_NAME} docker-compose --file ${TESTS_RUNTIME_ROOT}/docker-compose.yaml exec ${DOCKER_USER} --env PIMCORE_KERNEL_CLASS=${PIMCORE_KERNEL_CLASS} app php tests/runtime/bootstrap.php --env test --no-interaction doctrine:database:create - COMPOSE_PROJECT_NAME=${COMPOSE_PROJECT_NAME} docker-compose --file ${TESTS_RUNTIME_ROOT}/docker-compose.yaml exec ${DOCKER_USER} --env PIMCORE_KERNEL_CLASS=${PIMCORE_KERNEL_CLASS} app vendor/bin/pimcore-install --env test --no-interaction --ignore-existing-config --skip-database-config - COMPOSE_PROJECT_NAME=${COMPOSE_PROJECT_NAME} docker-compose --file ${TESTS_RUNTIME_ROOT}/docker-compose.yaml exec ${DOCKER_USER} --env PIMCORE_KERNEL_CLASS=${PIMCORE_KERNEL_CLASS} app php tests/runtime/bootstrap.php --env test --no-interaction sigwin:testing:setup + COMPOSE_PROJECT_NAME=${COMPOSE_PROJECT_NAME} docker compose --file ${TESTS_RUNTIME_ROOT}/docker-compose.yaml exec ${DOCKER_USER} --env PIMCORE_KERNEL_CLASS=${PIMCORE_KERNEL_CLASS} app php tests/runtime/bootstrap.php --env test --no-interaction doctrine:database:drop --if-exists --force + COMPOSE_PROJECT_NAME=${COMPOSE_PROJECT_NAME} docker compose --file ${TESTS_RUNTIME_ROOT}/docker-compose.yaml exec ${DOCKER_USER} --env PIMCORE_KERNEL_CLASS=${PIMCORE_KERNEL_CLASS} app php tests/runtime/bootstrap.php --env test --no-interaction doctrine:database:create + COMPOSE_PROJECT_NAME=${COMPOSE_PROJECT_NAME} docker compose --file ${TESTS_RUNTIME_ROOT}/docker-compose.yaml exec ${DOCKER_USER} --env PIMCORE_KERNEL_CLASS=${PIMCORE_KERNEL_CLASS} app vendor/bin/pimcore-install --env test --no-interaction --ignore-existing-config --skip-database-config + COMPOSE_PROJECT_NAME=${COMPOSE_PROJECT_NAME} docker compose --file ${TESTS_RUNTIME_ROOT}/docker-compose.yaml exec ${DOCKER_USER} --env PIMCORE_KERNEL_CLASS=${PIMCORE_KERNEL_CLASS} app php tests/runtime/bootstrap.php --env test --no-interaction sigwin:testing:setup test/behat: - COMPOSE_PROJECT_NAME=${COMPOSE_PROJECT_NAME} docker-compose --file ${TESTS_RUNTIME_ROOT}/docker-compose.yaml exec ${DOCKER_USER} --env PIMCORE_KERNEL_CLASS=${PIMCORE_KERNEL_CLASS} app vendor/bin/behat --colors --strict + COMPOSE_PROJECT_NAME=${COMPOSE_PROJECT_NAME} docker compose --file ${TESTS_RUNTIME_ROOT}/docker-compose.yaml exec ${DOCKER_USER} --env PIMCORE_KERNEL_CLASS=${PIMCORE_KERNEL_CLASS} app vendor/bin/behat --colors --strict clean: ## Clear logs and system cache rm -rf var/ tests/runtime/var .env: diff --git a/resources/YASSG/compat/phpstan.neon.dist b/resources/YASSG/compat/phpstan.neon.dist index 5f7fa25..5558741 100644 --- a/resources/YASSG/compat/phpstan.neon.dist +++ b/resources/YASSG/compat/phpstan.neon.dist @@ -10,6 +10,6 @@ parameters: - ./bundle excludePaths: - node_modules/ + - public/ - var/ - vendor/ - - public/ diff --git a/resources/YASSG/compat/psalm.xml.dist b/resources/YASSG/compat/psalm.xml.dist index 60eae91..478c089 100644 --- a/resources/YASSG/compat/psalm.xml.dist +++ b/resources/YASSG/compat/psalm.xml.dist @@ -5,6 +5,8 @@ ensureArrayIntOffsetsExist="true" ensureArrayStringOffsetsExist="true" errorLevel="1" + findUnusedBaselineEntry="true" + findUnusedCode="true" findUnusedPsalmSuppress="true" findUnusedVariablesAndParams="true" limitMethodComplexity="true" @@ -14,15 +16,14 @@ - - - + + - + diff --git a/tests/functional/Common/DefaultTest.php b/tests/functional/Common/DefaultTest.php index 04544db..13d3441 100644 --- a/tests/functional/Common/DefaultTest.php +++ b/tests/functional/Common/DefaultTest.php @@ -20,7 +20,7 @@ * * @coversNothing * - * @small + * @medium */ final class DefaultTest extends MakefileTestCase { diff --git a/tests/functional/MakefileTestCase.php b/tests/functional/MakefileTestCase.php index 8e99e1b..6731b1b 100644 --- a/tests/functional/MakefileTestCase.php +++ b/tests/functional/MakefileTestCase.php @@ -22,7 +22,7 @@ * * @internal * - * @small + * @medium */ abstract class MakefileTestCase extends TestCase { @@ -129,7 +129,6 @@ protected function generateHelpExecutionPath(array $files = [], array $additiona $command = match (\PHP_OS_FAMILY) { 'Darwin' => 'grep --no-filename --extended-regexp \'^ *[-a-zA-Z0-9_/]+ *:.*## \' '.implode(' ', $files).' | awk \'BEGIN {FS = ":.*?## "}; {printf "\033[45m%-20s\033[0m %s\n", $1, $2}\' | sort', 'Linux' => 'grep -h -E \'^ *[-a-zA-Z0-9_/]+ *:.*## \' '.implode(' ', $files).' | awk \'BEGIN {FS = ":.*?## "}; {printf "\033[45m%-20s\033[0m %s\n", $1, $2}\' | sort', - /** @phpstan-ignore-next-line */ 'Windows' => 'Select-String -Pattern \'^ *(?[-a-zA-Z0-9_/]+) *:.*## *(?.+)\' '.implode(',', array_map(function (string $item, int $index): string { if ($index === 0) { return $item; diff --git a/tests/functional/PHP/LibraryTest.php b/tests/functional/PHP/LibraryTest.php index 8fdb890..d24b1ae 100644 --- a/tests/functional/PHP/LibraryTest.php +++ b/tests/functional/PHP/LibraryTest.php @@ -20,7 +20,7 @@ * * @coversNothing * - * @small + * @medium */ final class LibraryTest extends MakefileTestCase { diff --git a/tests/functional/PHP/PhpTrait.php b/tests/functional/PHP/PhpTrait.php index aa169ad..bbf078c 100644 --- a/tests/functional/PHP/PhpTrait.php +++ b/tests/functional/PHP/PhpTrait.php @@ -88,10 +88,10 @@ private function paths(): array ], 'shell: app' => [ - $this->generateDockerComposeAppExecExecutionPath('bash'), + $this->generateDockerComposeAppExecExecutionPath('sh'), ], 'shell: app library' => [ - $this->generateDockerComposeTestExecExecutionPath('bash'), + $this->generateDockerComposeTestExecExecutionPath('sh'), ], 'shell: PHP' => [ $this->generatePhpqaExecutionPath('sh'), @@ -132,7 +132,7 @@ private function generatePhpqaExecutionPath(string $command, ?float $phpVersion $phpVersion ??= 8.1; return $this->normalize(sprintf( - 'docker run --init --interactive --rm --env "COMPOSER_CACHE_DIR=/composer/cache" %2$s --volume "$ROOT/var/phpqa:/cache" --volume "$ROOT:/project" --volume "$HOME/.composer:/composer" --workdir /project jakzal/phpqa:1.83.2-php%3$s-alpine %1$s', + 'docker run --init --interactive --rm --env "COMPOSER_CACHE_DIR=/composer/cache" %2$s --volume "$ROOT/var/phpqa:/cache" --volume "$ROOT:/project" --volume "$HOME/.composer:/composer" --workdir /project jakzal/phpqa:1.85.2-php%3$s-alpine %1$s', sprintf($command, $phpVersion), $this->generateDockerComposeExecutionUser(), $phpVersion @@ -146,12 +146,12 @@ private function generateDockerBuildxExecutionPath(string $env): string private function generateDockerComposeAppExecutionPath(string $command, string $env = 'env'): string { - return sprintf('VERSION=latest docker-compose --file docker-compose.yaml --file .infra/docker-compose/docker-compose.%2$s.yaml %1$s', $command, $env); + return sprintf('VERSION=latest docker compose --file docker-compose.yaml --file .infra/docker-compose/docker-compose.%2$s.yaml %1$s', $command, $env); } private function generateDockerComposeTestExecutionPath(string $command): string { - return sprintf('COMPOSE_PROJECT_NAME=infra docker-compose --file tests/runtime/docker-compose.yaml %1$s', $command); + return sprintf('COMPOSE_PROJECT_NAME=infra docker compose --file tests/runtime/docker-compose.yaml %1$s', $command); } private function generateDockerComposeAppExecExecutionPath(string $command, string $env = 'env'): string diff --git a/tests/functional/Pimcore/ApplicationTest.php b/tests/functional/Pimcore/ApplicationTest.php index 96d5636..8af38ce 100644 --- a/tests/functional/Pimcore/ApplicationTest.php +++ b/tests/functional/Pimcore/ApplicationTest.php @@ -22,7 +22,7 @@ * * @coversNothing * - * @small + * @medium */ final class ApplicationTest extends MakefileTestCase { diff --git a/tests/functional/Pimcore/LibraryTest.php b/tests/functional/Pimcore/LibraryTest.php index f38fa4f..bbc310f 100644 --- a/tests/functional/Pimcore/LibraryTest.php +++ b/tests/functional/Pimcore/LibraryTest.php @@ -21,7 +21,7 @@ * * @coversNothing * - * @small + * @medium */ final class LibraryTest extends MakefileTestCase { diff --git a/tests/functional/YASSG/CompatTest.php b/tests/functional/YASSG/CompatTest.php index 1b1afd0..0ac4148 100644 --- a/tests/functional/YASSG/CompatTest.php +++ b/tests/functional/YASSG/CompatTest.php @@ -21,7 +21,7 @@ * * @coversNothing * - * @small + * @medium */ final class CompatTest extends MakefileTestCase {