Problem
The codebase currently has no static analysis. Some methods return mixed without strict typing enforcement, which hides potential bugs.
For example in src/OauthClient.php:
private function request(string $method, string $url, ?array $body = null): string
{
// $response could be false on curl failure — currently not typed strictly
$response = curl_exec($ch);
...
}
Running phpstan analyse src/ --level=6 already reports issues like:
------ -------------------------------------------------------
Line src/OauthClient.php
------ -------------------------------------------------------
78 Variable $ch might not be defined.
83 Parameter #1 $ch of function curl_setopt expects resource, CurlHandle|false given.
------ -------------------------------------------------------
Proposal
- Add
phpstan/phpstan to require-dev
- Add a
phpstan.neon config targeting level 6
- Add a
composer run analyse script
Open questions
- Level 6 or level 8? Level 8 requires full generics annotation which may be too strict for now.
- Should PHPStan run in CI on every PR?
Problem
The codebase currently has no static analysis. Some methods return
mixedwithout strict typing enforcement, which hides potential bugs.For example in
src/OauthClient.php:Running
phpstan analyse src/ --level=6already reports issues like:Proposal
phpstan/phpstantorequire-devphpstan.neonconfig targeting level 6composer run analysescriptOpen questions