Skip to content

Introduce Phpstan #456

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

Merged
merged 19 commits into from
Jun 11, 2024
Merged

Introduce Phpstan #456

merged 19 commits into from
Jun 11, 2024

Conversation

Prometee
Copy link
Contributor

@Prometee Prometee commented Jun 11, 2024

Q A
Bug fix? no
New feature? no
BC breaks? no
Deprecations? no
Related tickets
Documentation
License MIT

What's in this PR?

Add PHPStan analyse.

Why?

Avoid issue with non typed variables.

To Do

  • Add PHPStan baseline.
  • Add PHPStan to the static analysis.
  • Try to fix some of the baseline errors.

@dbu
Copy link
Collaborator

dbu commented Jun 11, 2024

thanks a lot for picking this up!

-
message: "#^Call to static method create\\(\\) on an unknown class Symfony\\\\Component\\\\HttpClient\\\\HttpClient\\.$#"
count: 1
path: src/ClientFactory/SymfonyFactory.php
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i guess this means we don't test the factory, otherwise we would depend on the symfony http client.

we should probably add that, but in a separate merge request. and its no blocker for releasing 2.0

-
message: "#^Class Http\\\\Client\\\\Plugin\\\\Vcr\\\\NamingStrategy\\\\NamingStrategyInterface not found\\.$#"
count: 1
path: src/DependencyInjection/Configuration.php
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does the code properly handle a missing vcr plugin? if it does its okay i guess.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we could composer require the vcr plugin in a first step of the phpstan job, to have it validate correctly. the php tests would discover if we messed up with validation.

some nice to haves would be to have the configuration class error when configuring without vcr without having the plugin installed, and https://github.com/php-http/HttplugBundle/blob/b7ad2c1951edec36ef0bd9897e309b0038c59a54/src/DependencyInjection/HttplugExtension.php should throw an exception at the beginning of the method if vcr is not available.

but probably this still not enough to make phpstan happy, so composer require step for this could be added. that means that phpstan locally would complain about those though 🤔

we can also merge the current state and continue in separate pull requests.

@Prometee
Copy link
Contributor Author

@dbu what about raising the PHP version up for 2.0, I propose to start with ^8.1 and keep only 2 version of Symfony : ^6.4|^7.1. It's amazing that this bundle can support four versions but it's normally not possible for Symfony to be able to ensure such a compatibility across versions. WDYT ?

@dbu
Copy link
Collaborator

dbu commented Jun 11, 2024

@dbu what about raising the PHP version up for 2.0, I propose to start with ^8.1 and keep only 2 version of Symfony : ^6.4|^7.1. It's amazing that this bundle can support four versions but it's normally not possible for Symfony to be able to ensure such a compatibility across versions. WDYT ?

yes, good point. its good to support the legacy versions for legacy projects, but in the new major, we should raise to only support the maintained versions of symfony. we can potentially also drop some BC hacks when we drop old symfony versions.

(but lets not do that in the same pull request ;-) )

Copy link
Collaborator

@dbu dbu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

awesome, thanks a lot for the contribution!

@dbu dbu changed the title [WIP] Phpstan Introduce Phpstan Jun 11, 2024
@dbu dbu merged commit 734a76e into php-http:2.x Jun 11, 2024
15 checks passed
@dbu
Copy link
Collaborator

dbu commented Jun 11, 2024

created follow-up tickets #458 #457 #459

@dbu dbu mentioned this pull request Jun 11, 2024
@Prometee Prometee deleted the phpstan branch June 11, 2024 14:43
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

Successfully merging this pull request may close these issues.

2 participants