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

Add more precise types #220

Merged
merged 1 commit into from
Aug 9, 2024
Merged

Conversation

stof
Copy link
Contributor

@stof stof commented Aug 9, 2024

Description

This adds more precise types for some parts of the package. This PR specifically targets only places that are not generated by the GenerateEndpoints script (this will be covered by a separate PR solving #217).
I found those by running phpstan at level 6 (instead of the existing config using level 5). This PR does not solve all non-endpoints errors of level 6:

  • I excluded most of the errors reported in tests (more precise types in tests don't bring benefits to consumers of the package, especially when the missing types are the void return types on test methods themselves)
  • I haven't added the more precise type for SerializerInterface::deserialize as I'm not sure about the correct type:
    • $body has a native type ?string but the phpdoc type says string and implementations don't seem to account for null (so maybe string is the expected type
    • I'm not sure about the expected type for $headers as callers are passing $response['transfer_stats'] there (while ringphp documents that response headers are in $response['headers'])
  • I haven't solve all errors in Connection because dealing with RingPhp responses is complex.

Those can be solved later (before enabling level 6)

Issues Resolved

n/a

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.

Signed-off-by: Christophe Coevoet <[email protected]>
Copy link
Member

@dblock dblock left a comment

Choose a reason for hiding this comment

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

This is great.

Regarding RingHTTP I would not waste our time. I started removing it in #219, might not have time to get back to it, but it needs to go anyway.

@dblock dblock merged commit 7d46b11 into opensearch-project:main Aug 9, 2024
49 of 55 checks passed
@stof stof deleted the improve_types branch August 12, 2024 07:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants