Stripe SDK extension for PHPStan
PHP library for the Stripe API uses PHP objects where some of the properties are used only when the object is updated.
Customer::$source
, used only forsave()
Subscription::$coupon
, used only forsave()
Source::$card
, additional hash for a payment methodInvoice::$charge
andInvoice::$customer
are expandable and can be objects when retrieved, not just strings
These are not documented using @property
tags on the classes, and the dev team feels it should stay this way. Honestly, I'm not sure adding @property
tags would be the best way either.
PHPStan will obviously flag such property access and this extension will resolve those errors by telling PHPStan such properties exist.
The package is hosted on Packagist so you can install it using Composer:
composer require --dev spaze/phpstan-stripe
Add this to your phpstan.neon
:
includes:
- vendor/spaze/phpstan-stripe/extension.neon