Skip to content

Commit 2057b5f

Browse files
committed
Add base PHPStan configuration
1 parent 00ef672 commit 2057b5f

File tree

5 files changed

+189
-1
lines changed

5 files changed

+189
-1
lines changed

.github/workflows/php.yaml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
name: PHP Tests
2+
3+
on:
4+
push:
5+
branches: [ "master" ]
6+
pull_request:
7+
branches: [ "master" ]
8+
9+
permissions:
10+
contents: read
11+
12+
jobs:
13+
tests:
14+
15+
runs-on: ubuntu-latest
16+
strategy:
17+
matrix:
18+
php:
19+
- '7.2'
20+
- '7.4'
21+
composer_preference:
22+
- 'lowest'
23+
- 'highest'
24+
25+
steps:
26+
- uses: actions/checkout@v3
27+
28+
- name: Setup PHP
29+
uses: shivammathur/setup-php@v2
30+
with:
31+
php-version: ${{ matrix.php }}
32+
coverage: none
33+
34+
- uses: ramsey/composer-install@v2
35+
with:
36+
dependency-versions: ${{ matrix.composer_preference }}
37+
38+
- name: Run PHPStan
39+
run: composer run-script phpstan

composer.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,15 @@
2222
"rct567/dom-query": "^0.8.0"
2323
},
2424
"require-dev": {
25-
"phpunit/phpunit": "^6.1"
25+
"phpunit/phpunit": "^6.1",
26+
"phpstan/phpstan": "^1.10"
2627
},
2728
"autoload": {
2829
"psr-0": {
2930
"Lodestone\\": "src/"
3031
}
32+
},
33+
"scripts": {
34+
"phpstan": "phpstan"
3135
}
3236
}

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)