From 6c71d68b215c03ffba0ecc4fd745bb7613d5ebc7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Barto=C5=A1?= Date: Thu, 16 Feb 2023 05:40:22 +0100 Subject: [PATCH] Update tooling --- Makefile | 16 ++++++++------ README.md | 4 ++-- composer.json | 1 + tools/phpstan.baseline.neon | 26 +++++++++++++++++++++++ tools/{phpstan.base.neon => phpstan.neon} | 8 ++++++- tools/phpstan.src.neon | 9 -------- tools/phpstan.tests.neon | 9 -------- 7 files changed, 45 insertions(+), 28 deletions(-) create mode 100644 tools/phpstan.baseline.neon rename tools/{phpstan.base.neon => phpstan.neon} (65%) delete mode 100644 tools/phpstan.src.neon delete mode 100644 tools/phpstan.tests.neon diff --git a/Makefile b/Makefile index bff0f3a..5792bae 100644 --- a/Makefile +++ b/Makefile @@ -3,8 +3,8 @@ _: list # Config PHPCS_CONFIG=tools/phpcs.xml -PHPSTAN_SRC_CONFIG=tools/phpstan.src.neon -PHPSTAN_TESTS_CONFIG=tools/phpstan.tests.neon +PHPSTAN_CONFIG=tools/phpstan.neon +PHPSTAN_BASELINE_CONFIG=tools/phpstan.baseline.neon PHPUNIT_CONFIG=tools/phpunit.xml INFECTION_CONFIG=tools/infection.json @@ -23,8 +23,10 @@ csf: ## Fix PHP files coding style phpstan: ## Analyse code with PHPStan mkdir -p var/tools - $(PRE_PHP) "vendor/bin/phpstan" analyse src -c $(PHPSTAN_SRC_CONFIG) $(ARGS) - $(PRE_PHP) "vendor/bin/phpstan" analyse tests -c $(PHPSTAN_TESTS_CONFIG) $(ARGS) + $(PRE_PHP) "vendor/bin/phpstan" analyse src tests -c $(PHPSTAN_CONFIG) $(ARGS) + +phpstan-baseline: ## Add PHPStan errors to baseline + make phpstan ARGS="-b $(PHPSTAN_BASELINE_CONFIG)" # Tests @@ -36,7 +38,7 @@ coverage-clover: ## Generate code coverage in XML format $(PRE_PHP) $(PHPUNIT_COVERAGE) --coverage-clover=var/coverage/clover.xml $(ARGS) coverage-html: ## Generate code coverage in HTML format - $(PRE_PHP) $(PHPUNIT_COVERAGE) --coverage-html=var/coverage/coverage-html $(ARGS) + $(PRE_PHP) $(PHPUNIT_COVERAGE) --coverage-html=var/coverage/html $(ARGS) mutations: ## Check code for mutants make mutations-tests @@ -44,7 +46,7 @@ mutations: ## Check code for mutants mutations-tests: mkdir -p var/coverage - $(PRE_PHP) $(PHPUNIT_COVERAGE) --coverage-xml=var/coverage/coverage-xml --log-junit=var/coverage/junit.xml + $(PRE_PHP) $(PHPUNIT_COVERAGE) --coverage-xml=var/coverage/xml --log-junit=var/coverage/junit.xml mutations-infection: $(PRE_PHP) vendor/bin/infection \ @@ -68,4 +70,4 @@ PRE_PHP=XDEBUG_MODE=off PHPUNIT_COMMAND="vendor/bin/paratest" -c $(PHPUNIT_CONFIG) --runner=WrapperRunner -p$(LOGICAL_CORES) PHPUNIT_COVERAGE=php -d pcov.enabled=1 -d pcov.directory=./src $(PHPUNIT_COMMAND) -LOGICAL_CORES=$(shell nproc || sysctl -n hw.logicalcpu || echo 4) +LOGICAL_CORES=$(shell nproc || sysctl -n hw.logicalcpu || wmic cpu get NumberOfLogicalProcessors || echo 4) diff --git a/README.md b/README.md index c9b8ed0..55bf95c 100644 --- a/README.md +++ b/README.md @@ -17,8 +17,8 @@

- - + + diff --git a/composer.json b/composer.json index f9df447..ae1d9bb 100644 --- a/composer.json +++ b/composer.json @@ -35,6 +35,7 @@ "phpstan/extension-installer": "^1.0.0", "phpstan/phpstan": "^1.0.0", "phpstan/phpstan-deprecation-rules": "^1.0.0", + "phpstan/phpstan-nette": "^1.2.0", "phpstan/phpstan-phpunit": "^1.0.0", "phpstan/phpstan-strict-rules": "^1.0.0", "phpunit/phpunit": "^9.5.0", diff --git a/tools/phpstan.baseline.neon b/tools/phpstan.baseline.neon new file mode 100644 index 0000000..1af1f06 --- /dev/null +++ b/tools/phpstan.baseline.neon @@ -0,0 +1,26 @@ +parameters: + ignoreErrors: + - + message: "#^Call to static method PHPUnit\\\\Framework\\\\Assert\\:\\:assertInstanceOf\\(\\) with 'OriNette\\\\\\\\Http\\\\\\\\Auth\\\\\\\\HttpAuthenticator' and OriNette\\\\Http\\\\Auth\\\\HttpAuthenticator will always evaluate to true\\.$#" + count: 3 + path: ../tests/Unit/Auth/DI/HttpAuthExtensionTest.php + + - + message: "#^Call to function method_exists\\(\\) with 'Nette\\\\\\\\Http\\\\\\\\Request' and 'getBasicCredentials' will always evaluate to true\\.$#" + count: 2 + path: ../tests/Unit/Auth/HttpAuthenticatorTest.php + + - + message: "#^Call to static method PHPUnit\\\\Framework\\\\Assert\\:\\:assertTrue\\(\\) with true will always evaluate to true\\.$#" + count: 4 + path: ../tests/Unit/Auth/HttpAuthenticatorTest.php + + - + message: "#^Parameter \\#2 \\$string of static method PHPUnit\\\\Framework\\\\Assert\\:\\:assertStringStartsWith\\(\\) expects string, string\\|null given\\.$#" + count: 1 + path: ../tests/Unit/Tester/TestResponseTest.php + + - + message: "#^Call to static method PHPUnit\\\\Framework\\\\Assert\\:\\:assertInstanceOf\\(\\) with 'OriNette\\\\\\\\Http\\\\\\\\Tracy\\\\\\\\HttpPanel' and null will always evaluate to false\\.$#" + count: 1 + path: ../tests/Unit/Tracy/DI/HttpPanelExtensionTest.php diff --git a/tools/phpstan.base.neon b/tools/phpstan.neon similarity index 65% rename from tools/phpstan.base.neon rename to tools/phpstan.neon index fde599d..ac19c8d 100644 --- a/tools/phpstan.base.neon +++ b/tools/phpstan.neon @@ -1,9 +1,12 @@ includes: - ../vendor/phpstan/phpstan/conf/bleedingEdge.neon + - phpstan.baseline.neon parameters: - phpVersion: 70400 + phpVersion: 80000 + level: 8 tmpDir: ../var/tools/PHPStan + resultCachePath: %currentWorkingDirectory%/var/tools/PHPStan/resultCache.php checkBenevolentUnionTypes: true checkMissingCallableSignature: true @@ -16,3 +19,6 @@ parameters: tooWideThrowType: true checkedExceptionClasses: - Orisai\Exceptions\Check\CheckedException + + ignoreErrors: + - '#^Fetching deprecated class constant (S302_FOUND|S401_UNAUTHORIZED)(.+)#' diff --git a/tools/phpstan.src.neon b/tools/phpstan.src.neon deleted file mode 100644 index 2b042d9..0000000 --- a/tools/phpstan.src.neon +++ /dev/null @@ -1,9 +0,0 @@ -includes: - - phpstan.base.neon - -parameters: - level: 8 - resultCachePath: %currentWorkingDirectory%/var/tools/PHPStan/resultCache.src.php - - ignoreErrors: - - '#^Fetching deprecated class constant (S302_FOUND|S401_UNAUTHORIZED)(.+)#' diff --git a/tools/phpstan.tests.neon b/tools/phpstan.tests.neon deleted file mode 100644 index e8088f8..0000000 --- a/tools/phpstan.tests.neon +++ /dev/null @@ -1,9 +0,0 @@ -includes: - - phpstan.base.neon - -parameters: - level: 3 - resultCachePath: %currentWorkingDirectory%/var/tools/PHPStan/resultCache.tests.php - - scanDirectories: - - ../src