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

More specific PHPDoc type for RequestOptions arrays on services #1646

Merged

Conversation

richardm-stripe
Copy link
Contributor

@richardm-stripe richardm-stripe commented Feb 13, 2024

Summary

Defines and uses "array shape" types for "RequestOptions"

/**
 * @phpstan-type RequestOptionsArray array{api_key?: string, idempotency_key?: string, stripe_account?: string, stripe_version?: string, api_base?: string }
 * @psalm-type RequestOptionsArray = array{api_key?: string, idempotency_key?: string, stripe_account?: string, stripe_version?: string, api_base?: string }
 */

that are more specific than array.

In psalm, this is sufficient to prevent typos/misuses like ["api_kkey" => "sk_test_xyz"] https://psalm.dev/r/7a73e0e48f

But in PHPStan this isn't: https://phpstan.org/r/cbdc5206-60c0-4104-8d59-9dd62d9e1bfe because, at least for the time being, "array shapes" are considered "unsealed" (see phpstan/phpstan#8438).


paired with @helenye-stripe on this

@richardm-stripe richardm-stripe marked this pull request as ready for review February 13, 2024 19:59
@richardm-stripe
Copy link
Contributor Author

Marking this as ready for review. I don't think there's any reason not to merge this?

@richardm-stripe richardm-stripe requested review from a team and helenye-stripe and removed request for a team February 13, 2024 19:59
Copy link
Contributor

@helenye-stripe helenye-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 for taking this!

@richardm-stripe richardm-stripe merged commit f5c5a4d into master Feb 13, 2024
22 checks passed
@richardm-stripe richardm-stripe deleted the helenye-richardm-requestoptions-arrayshape-type branch February 13, 2024 20:04
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.

None yet

2 participants