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

Update PHPStan #1211

Merged
merged 8 commits into from
Dec 1, 2021
Merged

Update PHPStan #1211

merged 8 commits into from
Dec 1, 2021

Conversation

richardm-stripe
Copy link
Contributor

@richardm-stripe richardm-stripe commented Nov 30, 2021

Notify

r? @dcr-stripe

Summary

  • Upgrades PHPStan to the latest version, for compatibility with php8
  • Moves phpstan into composer.json as a devDependency rather than being installed manually by the Makefile.
  • Adds a step to the CI jobs to remove phpstan from composer.json from all jobs but the PHPStan job.
  • Adds some annotations to suppress new PHPStan errors.
  • Fixes a couple return types.
  • Moves some squelches from the "baseline" file into inline squelches as comments -- a new feature in the latest PHPStan and my preferred way to squelch.
  • Removes coveralls.

@richardm-stripe richardm-stripe force-pushed the richardm-update-phpstan branch 4 times, most recently from 6bb1f2d to d02c3ce Compare December 1, 2021 17:56
@richardm-stripe richardm-stripe force-pushed the richardm-update-phpstan branch from 645e117 to 96a4e46 Compare December 1, 2021 18:58
Copy link
Contributor

@dcr-stripe dcr-stripe left a comment

Choose a reason for hiding this comment

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

Thanks Richard! Did a first pass. PTAL? @richardm-stripe

@@ -4,10 +4,6 @@ export PHPSTAN_VERSION := 0.12.59
vendor: composer.json
Copy link
Contributor

Choose a reason for hiding this comment

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

Probably want to remove the PHPSTAN_VERSION export above.

@@ -24,7 +24,8 @@
"phpunit/phpunit": "^5.7 || ^9.0",
"php-coveralls/php-coveralls": "^2.1",
"squizlabs/php_codesniffer": "^3.3",
"friendsofphp/php-cs-fixer": "3.2.1 || 2.17.1"
"friendsofphp/php-cs-fixer": "3.2.1 || 2.17.1",
"phpstan/phpstan": "^1.2"
Copy link
Contributor

Choose a reason for hiding this comment

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

Will this cause issues installing the package with dev dependencies on earlier versions if we're saying it's not compatible with them?

Copy link
Contributor Author

@richardm-stripe richardm-stripe Dec 1, 2021

Choose a reason for hiding this comment

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

Yes. I think we should go with a policy of composer install is only supported on php 7.3+. I think this policy is fine because the only users of composer install are

  • CI - which we have already handled with the composer remove workaround in this PR.
  • maintainers/contributors to stripe-php:
    • I am happy to be restricted to php7.2+ when doing everyday development on stripe-php
    • When I am explicitly trying to test compatibility things with <php7.2 it will be definitely an inconvenience to not be able to composer install without manually working around, and beyond that it will be inconvenient to not be able to utilize phpstan/php-cs-fixer, but I think this inconvenience is far outweighed by the additional complexity it would take to continuously maintain compatibility with multiple versions of PHPStan and php-cs-fixer.

Copy link
Contributor

Choose a reason for hiding this comment

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

Sounds good - let's leave a comment explaining this and steps for running <php 7.2 so that this doesn't come back to haunt us down the road once we've forgotten :)

@@ -78,6 +78,8 @@ public function deleteDiscount($params = null, $opts = null)
$url = $this->instanceUrl() . '/discount';
list($response, $opts) = $this->_request('delete', $url, $params, $opts);
$this->refreshFrom(['discount' => null], $opts, true);

return $this;
Copy link
Contributor

Choose a reason for hiding this comment

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

This will need a codegen change right?

@@ -66,8 +66,6 @@ class Quote extends ApiResource
* @param null|array|string $opts
*
* @throws \Stripe\Exception\ApiErrorException if the request fails
*
* @return \Stripe\File the created file
Copy link
Contributor

Choose a reason for hiding this comment

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

Flagging this will also need a codegen change.

@richardm-stripe richardm-stripe force-pushed the richardm-update-phpstan branch 3 times, most recently from 8fd72d1 to ca4c186 Compare December 1, 2021 21:13
@richardm-stripe richardm-stripe force-pushed the richardm-update-phpstan branch from ca4c186 to 93308a4 Compare December 1, 2021 21:18
Copy link
Contributor

@dcr-stripe dcr-stripe left a comment

Choose a reason for hiding this comment

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

LGTM! Let's:

  • update the PR description to mention coverall removal
  • update the PR title to no longer be WIP.

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