Skip to content

Add advanced type definition for Atlas Search Indexes#3234

Merged
GromNaN merged 1 commit intomongodb:5.xfrom
GromNaN:search-index-advanced-type
Apr 17, 2026
Merged

Add advanced type definition for Atlas Search Indexes#3234
GromNaN merged 1 commit intomongodb:5.xfrom
GromNaN:search-index-advanced-type

Conversation

@GromNaN
Copy link
Copy Markdown
Member

@GromNaN GromNaN commented Jan 2, 2025

Replace inline @phpstan-param array shapes on searchIndex() and vectorSearchIndex() with named @phpstan-type aliases 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.

@GromNaN GromNaN added the feature label Jan 2, 2025
@GromNaN
Copy link
Copy Markdown
Member Author

GromNaN commented Jan 17, 2025

Related issue for advanced array shapes: symfony/symfony#58771

@GromNaN GromNaN marked this pull request as ready for review February 25, 2025 12:26
@GromNaN GromNaN requested a review from a team as a code owner February 25, 2025 12:26
@GromNaN GromNaN requested a review from jmikola February 25, 2025 12:26
@GromNaN GromNaN marked this pull request as draft February 25, 2025 12:26
@GromNaN GromNaN removed the request for review from jmikola February 25, 2025 12:27
@GromNaN GromNaN force-pushed the search-index-advanced-type branch from b62b2c1 to 3ea1f14 Compare April 9, 2026 17:20
@GromNaN GromNaN marked this pull request as ready for review April 9, 2026 17:40
Copilot AI review requested due to automatic review settings April 9, 2026 17:40
@GromNaN GromNaN force-pushed the search-index-advanced-type branch from 3ea1f14 to 2cd6c9f Compare April 9, 2026 17:42
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

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-type aliases describing Atlas Search and Vector Search index definition schemas.
  • Updated searchIndex() and vectorSearchIndex() docblocks to reference the new type aliases.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/Schema/Blueprint.php Outdated
Comment thread src/Schema/Blueprint.php Outdated
Comment thread src/Schema/Blueprint.php Outdated
@GromNaN GromNaN force-pushed the search-index-advanced-type branch 3 times, most recently from 630cc02 to 3306c1b Compare April 9, 2026 18:32
@GromNaN GromNaN force-pushed the search-index-advanced-type branch from 3306c1b to e261860 Compare April 9, 2026 18:35
@GromNaN GromNaN requested a review from paulinevos April 9, 2026 18:37
@GromNaN GromNaN enabled auto-merge (squash) April 9, 2026 18:37
@GromNaN GromNaN added this to the 5.8 milestone Apr 15, 2026
Copy link
Copy Markdown
Contributor

@paulinevos paulinevos left a comment

Choose a reason for hiding this comment

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

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
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks Claude, but this feels like kind of a given lol

{
/** @phpstan-param TypeSearchIndexDefinition $definition */
public static function assertSearchIndexDefinition(array $definition): void
{
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Maybe add a comment in the body clarifying that the @phpstan-param constitutes the assertion and no other test logic is expected here?

@GromNaN GromNaN merged commit 92dc495 into mongodb:5.x Apr 17, 2026
36 checks passed
@GromNaN GromNaN deleted the search-index-advanced-type branch April 17, 2026 12:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants