From 8dd42f04c5b76fa791f2a7ab72d36d5e08ed3a68 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Marek=20Barto=C5=A1?=
Date: Wed, 15 Feb 2023 22:20:37 +0100
Subject: [PATCH] Update tooling
---
Makefile | 16 ++---
README.md | 4 +-
tools/phpstan.baseline.neon | 71 +++++++++++++++++++++++
tools/{phpstan.base.neon => phpstan.neon} | 3 +
tools/phpstan.src.neon | 6 --
tools/phpstan.tests.neon | 9 ---
6 files changed, 85 insertions(+), 24 deletions(-)
create mode 100644 tools/phpstan.baseline.neon
rename tools/{phpstan.base.neon => phpstan.neon} (80%)
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 3f1e1db..8843e91 100644
--- a/README.md
+++ b/README.md
@@ -21,8 +21,8 @@
-
-
+
+
diff --git a/tools/phpstan.baseline.neon b/tools/phpstan.baseline.neon
new file mode 100644
index 0000000..e66f2b5
--- /dev/null
+++ b/tools/phpstan.baseline.neon
@@ -0,0 +1,71 @@
+parameters:
+ ignoreErrors:
+ -
+ message: "#^Parameter \\#1 \\$name of method Orisai\\\\OpenAPI\\\\Spec\\\\Encoding\\:\\:addContentType\\(\\) expects non\\-empty\\-string, string given\\.$#"
+ count: 1
+ path: ../tests/Unit/Spec/EncodingTest.php
+
+ -
+ message: "#^Cannot call method toArray\\(\\) on Orisai\\\\OpenAPI\\\\Spec\\\\Schema\\|null\\.$#"
+ count: 1
+ path: ../tests/Unit/Spec/HeaderTest.php
+
+ -
+ message: "#^Parameter \\#1 \\$name of method Orisai\\\\OpenAPI\\\\Spec\\\\Header\\:\\:addContent\\(\\) expects non\\-empty\\-string, string given\\.$#"
+ count: 1
+ path: ../tests/Unit/Spec/HeaderTest.php
+
+ -
+ message: "#^Cannot call method toArray\\(\\) on Orisai\\\\OpenAPI\\\\Spec\\\\Schema\\|null\\.$#"
+ count: 1
+ path: ../tests/Unit/Spec/ParameterTest.php
+
+ -
+ message: "#^Parameter \\#1 \\$name of method Orisai\\\\OpenAPI\\\\Spec\\\\Parameter\\:\\:addContent\\(\\) expects non\\-empty\\-string, string given\\.$#"
+ count: 1
+ path: ../tests/Unit/Spec/ParameterTest.php
+
+ -
+ message: "#^Parameter \\#1 \\$name of method Orisai\\\\OpenAPI\\\\Spec\\\\RequestBody\\:\\:addContent\\(\\) expects non\\-empty\\-string, string given\\.$#"
+ count: 1
+ path: ../tests/Unit/Spec/RequestBodyTest.php
+
+ -
+ message: "#^Parameter \\#1 \\$name of method Orisai\\\\OpenAPI\\\\Spec\\\\Response\\:\\:addContent\\(\\) expects non\\-empty\\-string, string given\\.$#"
+ count: 1
+ path: ../tests/Unit/Spec/ResponseTest.php
+
+ -
+ message: "#^Parameter \\#1 \\$code of method Orisai\\\\OpenAPI\\\\Spec\\\\Responses\\:\\:addResponse\\(\\) expects '1XX'\\|'2XX'\\|'3XX'\\|'4XX'\\|'default'\\|int\\<100, 599\\>, '200' given\\.$#"
+ count: 1
+ path: ../tests/Unit/Spec/ResponsesTest.php
+
+ -
+ message: "#^Parameter \\#1 \\$code of method Orisai\\\\OpenAPI\\\\Spec\\\\Responses\\:\\:addResponse\\(\\) expects '1XX'\\|'2XX'\\|'3XX'\\|'4XX'\\|'default'\\|int\\<100, 599\\>, '5XX' given\\.$#"
+ count: 1
+ path: ../tests/Unit/Spec/ResponsesTest.php
+
+ -
+ message: "#^Parameter \\#1 \\$code of method Orisai\\\\OpenAPI\\\\Spec\\\\Responses\\:\\:addResponse\\(\\) expects '1XX'\\|'2XX'\\|'3XX'\\|'4XX'\\|'default'\\|int\\<100, 599\\>, int\\|string given\\.$#"
+ count: 1
+ path: ../tests/Unit/Spec/ResponsesTest.php
+
+ -
+ message: "#^Offset 0 might not exist on list\\\\|null\\.$#"
+ count: 1
+ path: ../tests/Unit/Utils/HeadersTest.php
+
+ -
+ message: "#^Call to static method PHPUnit\\\\Framework\\\\Assert\\:\\:assertSame\\(\\) with array\\{application/json\\: null, application/xml\\: null, application/x\\-neon\\: null, application/x\\-yaml\\: null, text/csv\\: null, text/\\*\\: null, \\*/\\*\\: null\\} and array\\{text/\\*\\: null, \\*/\\*\\: null, text/csv\\: null, application/x\\-neon\\: null, application/xml\\: null, application/x\\-yaml\\: null, application/json\\: null\\} will always evaluate to false\\.$#"
+ count: 1
+ path: ../tests/Unit/Utils/MediaTypesTest.php
+
+ -
+ message: "#^Offset 1 might not exist on list\\\\|null\\.$#"
+ count: 1
+ path: ../tests/Unit/Utils/MediaTypesTest.php
+
+ -
+ message: "#^Parameter \\#1 \\$mediaType of static method Orisai\\\\OpenAPI\\\\Utils\\\\MediaTypes\\:\\:format\\(\\) expects non\\-empty\\-string, string given\\.$#"
+ count: 1
+ path: ../tests/Unit/Utils/MediaTypesTest.php
diff --git a/tools/phpstan.base.neon b/tools/phpstan.neon
similarity index 80%
rename from tools/phpstan.base.neon
rename to tools/phpstan.neon
index fde599d..8437767 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
+ level: 8
tmpDir: ../var/tools/PHPStan
+ resultCachePath: %currentWorkingDirectory%/var/tools/PHPStan/resultCache.php
checkBenevolentUnionTypes: true
checkMissingCallableSignature: true
diff --git a/tools/phpstan.src.neon b/tools/phpstan.src.neon
deleted file mode 100644
index 7844d1f..0000000
--- a/tools/phpstan.src.neon
+++ /dev/null
@@ -1,6 +0,0 @@
-includes:
- - phpstan.base.neon
-
-parameters:
- level: 8
- resultCachePath: %currentWorkingDirectory%/var/tools/PHPStan/resultCache.src.php
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