Skip to content

Commit c0b8f5d

Browse files
committed
fix: improve typing using phpstan and fix some errors identified by phpstan
1 parent 2971f1f commit c0b8f5d

File tree

9 files changed

+219
-200
lines changed

9 files changed

+219
-200
lines changed

.github/workflows/main.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ jobs:
2626

2727
- name: Install dependencies
2828
run: composer install --prefer-dist --no-progress --no-interaction --no-suggest
29+
- name: Run PHPStan
30+
run: php vendor/bin/phpstan
2931

3032
- name: Run test suite
3133
run: |

composer.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,9 @@
2727
"yiisoft/yii2-app-advanced": "dev-master",
2828
"codeception/verify": "^3.0",
2929
"codemix/yii2-localeurls": "^1.7",
30-
"codeception/module-asserts": "^3.0",
31-
"codeception/module-filesystem": "^3.0"
30+
"codeception/module-asserts": ">= 3.0",
31+
"codeception/module-filesystem": "> 3.0",
32+
"phpstan/phpstan": "^1.10"
3233
},
3334
"autoload":{
3435
"classmap": ["src/"]

phpstan.neon

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#includes:
2+
# - phpstan-baseline.neon
3+
parameters:
4+
reportUnmatchedIgnoredErrors: true
5+
dynamicConstantNames:
6+
- CONSOLE
7+
- YII_DEBUG
8+
level: 5
9+
paths:
10+
- src
11+
checkMaybeUndefinedVariables: true
12+
checkGenericClassInNonGenericObjectType: false
13+
ignoreErrors:
14+
# All Yii setters accept `null` but their phpdoc is incorrect.
15+
- message: '~^Parameter #1 \$value of method yii\\web\\Request::set(.*)\(\) expects (.*), null given.$~'
16+
path: 'src/'
17+
- message: '~^Variable \$_COOKIE in isset\(\) always exists and is not nullable.$~'
18+
path: 'src/'
19+
stubFiles:
20+
- tests/Yii.stub

0 commit comments

Comments
 (0)