Add advanced type definition for Atlas Search Indexes#3234
Add advanced type definition for Atlas Search Indexes#3234GromNaN merged 1 commit intomongodb:5.xfrom
Conversation
|
Related issue for advanced array shapes: symfony/symfony#58771 |
b62b2c1 to
3ea1f14
Compare
3ea1f14 to
2cd6c9f
Compare
There was a problem hiding this comment.
Pull request overview
This PR refactors the PHPStan type information for Atlas Search and Atlas Vector Search index definitions by extracting the array-shape schemas into reusable @phpstan-type aliases on MongoDB\Laravel\Schema\Blueprint, then reusing those aliases for the searchIndex() and vectorSearchIndex() parameter annotations to improve IDE/static-analysis ergonomics.
Changes:
- Added
@phpstan-typealiases describing Atlas Search and Vector Search index definition schemas. - Updated
searchIndex()andvectorSearchIndex()docblocks to reference the new type aliases.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
630cc02 to
3306c1b
Compare
3306c1b to
e261860
Compare
paulinevos
left a comment
There was a problem hiding this comment.
Some small remarks, but lgtm (without painstakingly checking every single data structure to be fair)
|
|
||
| /** | ||
| * PHPStan type-level tests for search index definitions. | ||
| * These functions are never executed at runtime — they exist to let PHPStan |
There was a problem hiding this comment.
Thanks Claude, but this feels like kind of a given lol
| { | ||
| /** @phpstan-param TypeSearchIndexDefinition $definition */ | ||
| public static function assertSearchIndexDefinition(array $definition): void | ||
| { |
There was a problem hiding this comment.
Maybe add a comment in the body clarifying that the @phpstan-param constitutes the assertion and no other test logic is expected here?
Replace inline
@phpstan-paramarray shapes onsearchIndex()andvectorSearchIndex()with named@phpstan-typealiases defined at the class level.A PHPStan type test file (
tests/PHPStan/SearchIndexTypeTest.php) validates the types against real index definition examples taken from the MongoDB documentation.