Skip to content

Commit c5847ff

Browse files
committed
Add base PHPStan configuration
1 parent 13109cf commit c5847ff

File tree

5 files changed

+150
-0
lines changed

5 files changed

+150
-0
lines changed

.github/workflows/php.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,5 +35,8 @@ jobs:
3535
with:
3636
dependency-versions: ${{ matrix.composer_preference }}
3737

38+
- name: Run PHPStan
39+
run: composer run-script phpstan
40+
3841
- name: Run test suite
3942
run: composer run-script test

composer.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
"rct567/dom-query": "^0.8.0"
2323
},
2424
"require-dev": {
25+
"phpstan/phpstan": "^1.10",
2526
"phpunit/phpunit": "^8|^9"
2627
},
2728
"autoload": {
@@ -35,6 +36,7 @@
3536
}
3637
},
3738
"scripts": {
39+
"phpstan": "phpstan",
3840
"test": "phpunit"
3941
}
4042
}

phpstan-baseline.neon

Lines changed: 131 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
1+
parameters:
2+
ignoreErrors:
3+
-
4+
message: "#^Parameter \\#2 \\$replace of function str_ireplace expects array\\|string, null given\\.$#"
5+
count: 1
6+
path: src/Lodestone/Api/DevPosts.php
7+
8+
-
9+
message: "#^Cannot use array destructuring on bool\\|object\\.$#"
10+
count: 1
11+
path: src/Lodestone/Game/ClassJobs.php
12+
13+
-
14+
message: "#^Method Lodestone\\\\Game\\\\ClassJobs\\:\\:findClassJob\\(\\) never returns object so it can be removed from the return type\\.$#"
15+
count: 1
16+
path: src/Lodestone/Game/ClassJobs.php
17+
18+
-
19+
message: "#^Method Lodestone\\\\Game\\\\ClassJobs\\:\\:findClassJob\\(\\) should return bool\\|object but returns array\\<int, int\\>\\.$#"
20+
count: 1
21+
path: src/Lodestone/Game/ClassJobs.php
22+
23+
-
24+
message: "#^Parameter \\#2 \\$replace of function str_ireplace expects array\\|string, null given\\.$#"
25+
count: 1
26+
path: src/Lodestone/Game/ClassJobs.php
27+
28+
-
29+
message: "#^Static property Lodestone\\\\Http\\\\AsyncHandler\\:\\:\\$requestId \\(string\\) does not accept null\\.$#"
30+
count: 1
31+
path: src/Lodestone/Http/AsyncHandler.php
32+
33+
-
34+
message: "#^PHPDoc tag @throws has invalid value \\(\\)\\: Unexpected token \"\\\\n \", expected type at offset 43$#"
35+
count: 1
36+
path: src/Lodestone/Http/Http.php
37+
38+
-
39+
message: "#^PHPDoc tag @throws has invalid value \\(\\)\\: Unexpected token \"\\\\n \", expected type at offset 51$#"
40+
count: 1
41+
path: src/Lodestone/Http/Http.php
42+
43+
-
44+
message: "#^If condition is always true\\.$#"
45+
count: 2
46+
path: src/Lodestone/Parser/ParseCharacter.php
47+
48+
-
49+
message: "#^Parameter \\#2 \\$replace of function str_ireplace expects array\\|string, null given\\.$#"
50+
count: 2
51+
path: src/Lodestone/Parser/ParseCharacter.php
52+
53+
-
54+
message: "#^If condition is always true\\.$#"
55+
count: 1
56+
path: src/Lodestone/Parser/ParseCharacterAchievements.php
57+
58+
-
59+
message: "#^Call to function unset\\(\\) contains undefined variable \\$box\\.$#"
60+
count: 1
61+
path: src/Lodestone/Parser/ParseCharacterClassJobs.php
62+
63+
-
64+
message: "#^Parameter \\#2 \\$replace of function str_ireplace expects array\\|string, null given\\.$#"
65+
count: 6
66+
path: src/Lodestone/Parser/ParseCharacterClassJobs.php
67+
68+
-
69+
message: "#^Variable \\$node in PHPDoc tag @var does not match assigned variable \\$bozjan\\.$#"
70+
count: 1
71+
path: src/Lodestone/Parser/ParseCharacterClassJobs.php
72+
73+
-
74+
message: "#^Access to an undefined property Rct567\\\\DomQuery\\\\DomQuery\\:\\:\\$dom\\.$#"
75+
count: 2
76+
path: src/Lodestone/Parser/ParseFreeCompany.php
77+
78+
-
79+
message: "#^Call to an undefined method Rct567\\\\DomQuery\\\\DomQuery\\:\\:getServerAndDc\\(\\)\\.$#"
80+
count: 1
81+
path: src/Lodestone/Parser/ParseFreeCompany.php
82+
83+
-
84+
message: "#^Call to an undefined method Rct567\\\\DomQuery\\\\DomQuery\\:\\:getTimestamp\\(\\)\\.$#"
85+
count: 1
86+
path: src/Lodestone/Parser/ParseFreeCompany.php
87+
88+
-
89+
message: "#^Parameter \\#2 \\$replace of function str_ireplace expects array\\|string, null given\\.$#"
90+
count: 1
91+
path: src/Lodestone/Parser/ParseFreeCompany.php
92+
93+
-
94+
message: "#^Access to an undefined property Lodestone\\\\Entity\\\\ListView\\\\ListView\\:\\:\\$Profile\\.$#"
95+
count: 1
96+
path: src/Lodestone/Parser/ParseLinkshellCWMembers.php
97+
98+
-
99+
message: "#^Access to an undefined property Lodestone\\\\Entity\\\\ListView\\\\ListView\\:\\:\\$Profile\\.$#"
100+
count: 1
101+
path: src/Lodestone/Parser/ParseLinkshellMembers.php
102+
103+
-
104+
message: "#^Variable \\$node in PHPDoc tag @var does not match assigned variable \\$arr\\.$#"
105+
count: 1
106+
path: src/Lodestone/Parser/ParseLodestoneBanners.php
107+
108+
-
109+
message: "#^Variable \\$node in PHPDoc tag @var does not match assigned variable \\$arr\\.$#"
110+
count: 1
111+
path: src/Lodestone/Parser/ParseLodestoneWorldStatus.php
112+
113+
-
114+
message: "#^Access to an undefined property Lodestone\\\\Entity\\\\ListView\\\\ListView\\:\\:\\$Profile\\.$#"
115+
count: 1
116+
path: src/Lodestone/Parser/ParsePvPTeamMembers.php
117+
118+
-
119+
message: "#^Parameter \\#1 \\$id of method Lodestone\\\\Api\\\\Character\\:\\:following\\(\\) expects int, string given\\.$#"
120+
count: 1
121+
path: tests
122+
123+
-
124+
message: "#^Parameter \\#1 \\$id of method Lodestone\\\\Api\\\\Character\\:\\:friends\\(\\) expects int, string given\\.$#"
125+
count: 1
126+
path: tests
127+
128+
-
129+
message: "#^Parameter \\#1 \\$id of method Lodestone\\\\Api\\\\Character\\:\\:get\\(\\) expects int, string given\\.$#"
130+
count: 1
131+
path: tests

phpstan.neon

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
includes:
2+
- phpstan-baseline.neon
3+
4+
parameters:
5+
level: 5
6+
paths:
7+
- src
8+
- tests

src/Lodestone/Api.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,12 @@ class Api
2020
private $namespaces = [];
2121

2222
/**
23+
* @template T
24+
*
25+
* @param class-string<T> $namespace
26+
*
27+
* @return T
28+
*
2329
* will return an existing set namespace or a new one.
2430
*/
2531
private function getApiNamespace($namespace)

0 commit comments

Comments
 (0)