Skip to content

Add base PHPStan configuration #21

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/workflows/php.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,8 @@ jobs:
with:
dependency-versions: ${{ matrix.composer_preference }}

- name: Run PHPStan
run: composer run-script phpstan

- name: Run test suite
run: composer run-script test
2 changes: 2 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
"rct567/dom-query": "^0.8.0"
},
"require-dev": {
"phpstan/phpstan": "^1.10",
"phpunit/phpunit": "^8|^9"
},
"autoload": {
Expand All @@ -35,6 +36,7 @@
}
},
"scripts": {
"phpstan": "phpstan",
"test": "phpunit"
}
}
131 changes: 131 additions & 0 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
parameters:
ignoreErrors:
-
message: "#^Parameter \\#2 \\$replace of function str_ireplace expects array\\|string, null given\\.$#"
count: 1
path: src/Lodestone/Api/DevPosts.php

-
message: "#^Cannot use array destructuring on bool\\|object\\.$#"
count: 1
path: src/Lodestone/Game/ClassJobs.php

-
message: "#^Method Lodestone\\\\Game\\\\ClassJobs\\:\\:findClassJob\\(\\) never returns object so it can be removed from the return type\\.$#"
count: 1
path: src/Lodestone/Game/ClassJobs.php

-
message: "#^Method Lodestone\\\\Game\\\\ClassJobs\\:\\:findClassJob\\(\\) should return bool\\|object but returns array\\<int, int\\>\\.$#"
count: 1
path: src/Lodestone/Game/ClassJobs.php

-
message: "#^Parameter \\#2 \\$replace of function str_ireplace expects array\\|string, null given\\.$#"
count: 1
path: src/Lodestone/Game/ClassJobs.php

-
message: "#^Static property Lodestone\\\\Http\\\\AsyncHandler\\:\\:\\$requestId \\(string\\) does not accept null\\.$#"
count: 1
path: src/Lodestone/Http/AsyncHandler.php

-
message: "#^PHPDoc tag @throws has invalid value \\(\\)\\: Unexpected token \"\\\\n \", expected type at offset 43$#"
count: 1
path: src/Lodestone/Http/Http.php

-
message: "#^PHPDoc tag @throws has invalid value \\(\\)\\: Unexpected token \"\\\\n \", expected type at offset 51$#"
count: 1
path: src/Lodestone/Http/Http.php

-
message: "#^If condition is always true\\.$#"
count: 2
path: src/Lodestone/Parser/ParseCharacter.php

-
message: "#^Parameter \\#2 \\$replace of function str_ireplace expects array\\|string, null given\\.$#"
count: 2
path: src/Lodestone/Parser/ParseCharacter.php

-
message: "#^If condition is always true\\.$#"
count: 1
path: src/Lodestone/Parser/ParseCharacterAchievements.php

-
message: "#^Call to function unset\\(\\) contains undefined variable \\$box\\.$#"
count: 1
path: src/Lodestone/Parser/ParseCharacterClassJobs.php

-
message: "#^Parameter \\#2 \\$replace of function str_ireplace expects array\\|string, null given\\.$#"
count: 6
path: src/Lodestone/Parser/ParseCharacterClassJobs.php

-
message: "#^Variable \\$node in PHPDoc tag @var does not match assigned variable \\$bozjan\\.$#"
count: 1
path: src/Lodestone/Parser/ParseCharacterClassJobs.php

-
message: "#^Access to an undefined property Rct567\\\\DomQuery\\\\DomQuery\\:\\:\\$dom\\.$#"
count: 2
path: src/Lodestone/Parser/ParseFreeCompany.php

-
message: "#^Call to an undefined method Rct567\\\\DomQuery\\\\DomQuery\\:\\:getServerAndDc\\(\\)\\.$#"
count: 1
path: src/Lodestone/Parser/ParseFreeCompany.php

-
message: "#^Call to an undefined method Rct567\\\\DomQuery\\\\DomQuery\\:\\:getTimestamp\\(\\)\\.$#"
count: 1
path: src/Lodestone/Parser/ParseFreeCompany.php

-
message: "#^Parameter \\#2 \\$replace of function str_ireplace expects array\\|string, null given\\.$#"
count: 1
path: src/Lodestone/Parser/ParseFreeCompany.php

-
message: "#^Access to an undefined property Lodestone\\\\Entity\\\\ListView\\\\ListView\\:\\:\\$Profile\\.$#"
count: 1
path: src/Lodestone/Parser/ParseLinkshellCWMembers.php

-
message: "#^Access to an undefined property Lodestone\\\\Entity\\\\ListView\\\\ListView\\:\\:\\$Profile\\.$#"
count: 1
path: src/Lodestone/Parser/ParseLinkshellMembers.php

-
message: "#^Variable \\$node in PHPDoc tag @var does not match assigned variable \\$arr\\.$#"
count: 1
path: src/Lodestone/Parser/ParseLodestoneBanners.php

-
message: "#^Variable \\$node in PHPDoc tag @var does not match assigned variable \\$arr\\.$#"
count: 1
path: src/Lodestone/Parser/ParseLodestoneWorldStatus.php

-
message: "#^Access to an undefined property Lodestone\\\\Entity\\\\ListView\\\\ListView\\:\\:\\$Profile\\.$#"
count: 1
path: src/Lodestone/Parser/ParsePvPTeamMembers.php

-
message: "#^Parameter \\#1 \\$id of method Lodestone\\\\Api\\\\Character\\:\\:following\\(\\) expects int, string given\\.$#"
count: 1
path: tests

-
message: "#^Parameter \\#1 \\$id of method Lodestone\\\\Api\\\\Character\\:\\:friends\\(\\) expects int, string given\\.$#"
count: 1
path: tests

-
message: "#^Parameter \\#1 \\$id of method Lodestone\\\\Api\\\\Character\\:\\:get\\(\\) expects int, string given\\.$#"
count: 1
path: tests
8 changes: 8 additions & 0 deletions phpstan.neon
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
includes:
- phpstan-baseline.neon

parameters:
level: 5
paths:
- src
- tests
6 changes: 6 additions & 0 deletions src/Lodestone/Api.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@ class Api
private $namespaces = [];

/**
* @template T
*
* @param class-string<T> $namespace
*
* @return T
*
* will return an existing set namespace or a new one.
*/
private function getApiNamespace($namespace)
Expand Down