Skip to content
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

Adding PHPStan #66

Open
bobkorinek opened this issue Sep 10, 2024 · 0 comments
Open

Adding PHPStan #66

bobkorinek opened this issue Sep 10, 2024 · 0 comments

Comments

@bobkorinek
Copy link
Contributor

Hello,

I'd like to help with the development of this library, so I wanted to ask if it would be okay to add PHPStan for static analysis. This would assist the project with development and make it easier to accept new pull requests.

I ran PHPStan at level 5 on the current code, and it found 6 errors. At higher levels, there were significantly more errors, but this was mostly due to missing type declarations. Adding those might impact some users, so that could be a standalone PR in the future (if such a change would be welcomed, of course). For now, I'd be happy to add PHPStan and fix the current issues.

Here are the current issues. In my opinion, fixing most of them shouldn't affect the current behavior. The only potential problem might be the JsonBrowser class, which contains code referencing (likely) an old version of Guzzle. Unless there's a specific reason for this code to exist, I don't think it should be an issue to remove it, as this library uses Guzzle version ^7.7.0 anyway.

Current errors for PHPStan level 5

Line File Issue
26 src/Http/JsonBrowser.php Call to an undefined method GuzzleHttp\Client::createRequest().
28 src/Http/JsonBrowser.php Call to static method factory() on an unknown class GuzzleHttp\Stream\Stream.
31 src/Http/JsonBrowser.php Parameter 1 $method of class GuzzleHttp\Psr7\Request constructor expects string, GoPay\Definition\RequestMethods given.
35 src/Http/JsonBrowser.php Property GoPay\Http\Response::$statusCode (int) does not accept string.
12 src/Http/Log/PrintHttpRequest.php Part $request->method (GoPay\Definition\RequestMethods) of encapsed string cannot be cast to string.
10 src/Http/Request.php Property GoPay\Http\Request::$method (GoPay\Definition\RequestMethods) does not accept default value of type string.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant