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

PHPLIB-1598 Use named types for enums #1570

Merged
merged 1 commit into from
Jan 24, 2025
Merged

Conversation

GromNaN
Copy link
Member

@GromNaN GromNaN commented Jan 23, 2025

Fix PHPLIB-1598

When a field accepts a specific list of values, I use a named type. It will be possible to improve the parameter types later by specifying the list of accepted values.

@GromNaN GromNaN requested a review from a team as a code owner January 23, 2025 13:50
@GromNaN GromNaN requested a review from jmikola January 23, 2025 13:50
* Available only if the all groupBy values are numeric and none of them are NaN.
*/
public function __construct(
Type|ExpressionInterface|stdClass|array|bool|float|int|null|string $groupBy,
int $buckets,
Optional|Document|Serializable|stdClass|array $output = Optional::Undefined,
Optional|Document|Serializable|stdClass|array $granularity = Optional::Undefined,
Optional|string $granularity = Optional::Undefined,
Copy link
Member Author

Choose a reason for hiding this comment

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

The type was incorrect. granularity must be a string: https://www.mongodb.com/docs/manual/reference/operator/aggregation/bucketAuto/

Copy link
Member

@jmikola jmikola left a comment

Choose a reason for hiding this comment

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

IIRC, in a previous Atlas Search PR you opted not to use enums since that might become a hindrance if something changed upstream before this library was able to apply the change.

In the event the server removed a supported string value, might that lead of a situation in the library where we'd be stuck with it out of BC obligations?

Certainly not for this implementation, since everything is just a string; however, I'm concerned with what happens if you do start modeling the server API more closely. I'm very sensitive to how that might backfire on us (similar to #1569).

'Window' => [
'acceptedTypes' => [...$bsonTypes['object']],
],
'GeoPoint' => [
Copy link
Member

Choose a reason for hiding this comment

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

Just want to confirm that "FillOut", "Window", and "GeoPoint" were never used.

Copy link
Member Author

Choose a reason for hiding this comment

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

If they were used, the generator would fail.

@GromNaN GromNaN merged commit acfe2ac into mongodb:v1.x Jan 24, 2025
31 checks passed
@GromNaN GromNaN deleted the PHPLIB-1598 branch January 24, 2025 10:03
This was referenced Jan 24, 2025
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