Skip to content

Commit

Permalink
Make PHPStan stricter
Browse files Browse the repository at this point in the history
Signed-off-by: Maurício Meneghini Fauth <[email protected]>
  • Loading branch information
MauricioFauth committed Sep 13, 2023
1 parent f37b41c commit 8e6df4e
Show file tree
Hide file tree
Showing 3 changed files with 123 additions and 3 deletions.
8 changes: 6 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,10 @@
"require-dev": {
"phpmyadmin/coding-standard": "^4.0",
"phpmyadmin/motranslator": "^5.2",
"phpstan/phpstan": "^1.9.4",
"phpstan/extension-installer": "^1.3",
"phpstan/phpstan": "^1.10",
"phpstan/phpstan-phpunit": "^1.3",
"phpstan/phpstan-strict-rules": "^1.5",
"phpunit/phpunit": "^9.6"
},
"scripts": {
Expand All @@ -44,7 +47,8 @@
"config":{
"sort-packages": true,
"allow-plugins": {
"dealerdirect/phpcodesniffer-composer-installer": true
"dealerdirect/phpcodesniffer-composer-installer": true,
"phpstan/extension-installer": true
}
},
"extra": {
Expand Down
111 changes: 111 additions & 0 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
parameters:
ignoreErrors:
-
message: "#^Only booleans are allowed in an if condition, array\\<int, Twig\\\\Node\\\\Expression\\\\NameExpression\\> given\\.$#"
count: 1
path: src/Node/TransNode.php

-
message: "#^Only booleans are allowed in an if condition, int\\<0, max\\> given\\.$#"
count: 1
path: src/Node/TransNode.php

-
message: "#^Parameter \\#1 \\$name of class Twig\\\\Node\\\\Expression\\\\NameExpression constructor expects string, mixed given\\.$#"
count: 1
path: src/Node/TransNode.php

-
message: "#^Parameter \\#1 \\$string of function trim expects string, mixed given\\.$#"
count: 2
path: src/Node/TransNode.php

-
message: "#^Parameter \\#2 \\.\\.\\.\\$values of function sprintf expects bool\\|float\\|int\\|string\\|null, mixed given\\.$#"
count: 1
path: src/Node/TransNode.php

-
message: "#^Method PhpMyAdmin\\\\Twig\\\\Extensions\\\\TokenParser\\\\TransTokenParser\\:\\:preParse\\(\\) should return array\\{Twig\\\\Node\\\\Node, Twig\\\\Node\\\\Node\\|null, Twig\\\\Node\\\\Expression\\\\AbstractExpression\\|null, Twig\\\\Node\\\\Node\\|null, Twig\\\\Node\\\\Node\\|null, Twig\\\\Node\\\\Node\\|null, int, string\\} but returns array\\{mixed, Twig\\\\Node\\\\Node\\|null, mixed, Twig\\\\Node\\\\Node\\|null, Twig\\\\Node\\\\Node\\|null, mixed, int, string\\}\\.$#"
count: 1
path: src/TokenParser/TransTokenParser.php

-
message: "#^Parameter \\#1 \\$body of method PhpMyAdmin\\\\Twig\\\\Extensions\\\\TokenParser\\\\TransTokenParser\\:\\:checkTransString\\(\\) expects Twig\\\\Node\\\\Node, mixed given\\.$#"
count: 1
path: src/TokenParser/TransTokenParser.php

-
message: "#^Dynamic call to static method PHPUnit\\\\Framework\\\\Assert\\:\\:assertNotEmpty\\(\\)\\.$#"
count: 1
path: test/I18nExtensionMoTranslatorDebugTest.php

-
message: "#^Dynamic call to static method PHPUnit\\\\Framework\\\\Assert\\:\\:assertNotEmpty\\(\\)\\.$#"
count: 1
path: test/I18nExtensionMoTranslatorSandboxTest.php

-
message: "#^Dynamic call to static method PHPUnit\\\\Framework\\\\Assert\\:\\:assertNotEmpty\\(\\)\\.$#"
count: 1
path: test/I18nExtensionSandboxTest.php

-
message: "#^Dynamic call to static method PHPUnit\\\\Framework\\\\Assert\\:\\:assertNotEmpty\\(\\)\\.$#"
count: 1
path: test/I18nExtensionTest.php

-
message: "#^Dynamic call to static method PHPUnit\\\\Framework\\\\Assert\\:\\:assertEquals\\(\\)\\.$#"
count: 6
path: test/Node/MoTranslatorTransTest.php

-
message: "#^Parameter \\#2 \\.\\.\\.\\$values of function sprintf expects bool\\|float\\|int\\|string\\|null, mixed given\\.$#"
count: 8
path: test/Node/MoTranslatorTransTest.php

-
message: "#^Parameter \\#3 \\.\\.\\.\\$values of function sprintf expects bool\\|float\\|int\\|string\\|null, mixed given\\.$#"
count: 3
path: test/Node/MoTranslatorTransTest.php

-
message: "#^Cannot call method compile\\(\\) on mixed\\.$#"
count: 2
path: test/Node/TransTest.php

-
message: "#^Cannot call method getDebugInfo\\(\\) on mixed\\.$#"
count: 4
path: test/Node/TransTest.php

-
message: "#^Cannot call method getSource\\(\\) on mixed\\.$#"
count: 2
path: test/Node/TransTest.php

-
message: "#^Dynamic call to static method PHPUnit\\\\Framework\\\\Assert\\:\\:assertEmpty\\(\\)\\.$#"
count: 2
path: test/Node/TransTest.php

-
message: "#^Dynamic call to static method PHPUnit\\\\Framework\\\\Assert\\:\\:assertEquals\\(\\)\\.$#"
count: 7
path: test/Node/TransTest.php

-
message: "#^Dynamic call to static method PHPUnit\\\\Framework\\\\Assert\\:\\:assertSame\\(\\)\\.$#"
count: 4
path: test/Node/TransTest.php

-
message: "#^Parameter \\#2 \\.\\.\\.\\$values of function sprintf expects bool\\|float\\|int\\|string\\|null, mixed given\\.$#"
count: 5
path: test/Node/TransTest.php

-
message: "#^Parameter \\#3 \\.\\.\\.\\$values of function sprintf expects bool\\|float\\|int\\|string\\|null, mixed given\\.$#"
count: 1
path: test/Node/TransTest.php
7 changes: 6 additions & 1 deletion phpstan.neon.dist
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
includes:
- phpstan-baseline.neon
parameters:
level: max
paths:
- src
- test
checkBenevolentUnionTypes: true
checkImplicitMixed: true
checkTooWideReturnTypesInProtectedAndPublicMethods: true
checkUninitializedProperties: true
reportUnmatchedIgnoredErrors: true
checkMissingIterableValueType: false

0 comments on commit 8e6df4e

Please sign in to comment.