Skip to content

Add types Data ArrayAccess methods#912

Merged
Strift merged 1 commit into
meilisearch:mainfrom
norkunas:types-on-data
Apr 28, 2026
Merged

Add types Data ArrayAccess methods#912
Strift merged 1 commit into
meilisearch:mainfrom
norkunas:types-on-data

Conversation

@norkunas
Copy link
Copy Markdown
Collaborator

@norkunas norkunas commented Apr 28, 2026

Pull Request

Related issue

Fixes #849

What does this PR do?

  • Adds types to Data ArrayAccess methods

PR checklist

Please check if your PR fulfills the following requirements:

  • Did you use any AI tool while implementing this PR (code, tests, docs, etc.)? If yes, disclose it in the PR description and describe what it was used for. AI usage is allowed when it is disclosed.
  • Does this PR fix an existing issue, or have you listed the changes applied in the PR description (and why they are needed)?
  • Have you read the contributing guidelines?
  • Have you made sure that the title is accurate and descriptive of the changes?

Summary by CodeRabbit

Release Notes

This release includes internal code quality improvements with no user-facing changes. Type annotations have been strengthened to enhance code reliability and maintainability for developers.

@norkunas norkunas added enhancement New feature or request breaking-change The related changes are breaking for the users labels Apr 28, 2026
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 28, 2026

📝 Walkthrough

Walkthrough

The Data class now includes explicit mixed type hints for ArrayAccess interface method parameters (offsetSet, offsetExists, offsetUnset, offsetGet) and PHPDoc annotations for the $data property and constructor parameter. No control flow or logic changes were introduced.

Changes

Cohort / File(s) Summary
Type Annotations
src/Contracts/Data.php
Added mixed type hints to four ArrayAccess interface methods and PHPDoc annotations for the $data property and constructor parameter.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Poem

🐰 Hops with glee at types so clear,
Mixed declarations now appear!
ArrayAccess, stronger still,
Type safety bends to our will!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 20.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately and concisely describes the primary change of adding explicit type hints to ArrayAccess methods in the Data class.
Linked Issues check ✅ Passed All four required method signature updates for offsetSet, offsetExists, offsetUnset, and offsetGet have been implemented with mixed type parameters as specified in issue #849.
Out of Scope Changes check ✅ Passed All changes are directly related to the linked issue #849; only the specified ArrayAccess method signatures and related PHPDoc annotations were modified.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 28, 2026

Codecov Report

❌ Patch coverage is 25.00000% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 87.56%. Comparing base (0078a8c) to head (ee5317a).
⚠️ Report is 156 commits behind head on main.

Files with missing lines Patch % Lines
src/Contracts/Data.php 25.00% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #912      +/-   ##
==========================================
- Coverage   89.78%   87.56%   -2.23%     
==========================================
  Files          59       85      +26     
  Lines        1449     1801     +352     
==========================================
+ Hits         1301     1577     +276     
- Misses        148      224      +76     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
src/Contracts/Data.php (1)

9-16: Tighten PHPDoc array generics for better static-analysis precision.

@var array<mixed> and @param array<mixed> work, but array<array-key, mixed> is more explicit about allowed keys and typically gives better analyzer feedback.

Suggested diff
 /**
- * `@var` array<mixed>
+ * `@var` array<array-key, mixed>
  */
 protected array $data = [];

 /**
- * `@param` array<mixed> $data
+ * `@param` array<array-key, mixed> $data
  */
 public function __construct(array $data = [])

Based on learnings, docblock type annotations in this repository are used as static-analysis contracts.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/Contracts/Data.php` around lines 9 - 16, Update the docblock array
generics to be explicit about allowed keys: replace occurrences of "@var
array<mixed>" on the protected $data property and any "@param array<mixed>"
annotations (e.g., on the Data class constructor or setData method) with "@var
array<array-key, mixed>" and "@param array<array-key, mixed>" respectively to
improve static-analysis precision for the Data class and its $data member.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@src/Contracts/Data.php`:
- Around line 9-16: Update the docblock array generics to be explicit about
allowed keys: replace occurrences of "@var array<mixed>" on the protected $data
property and any "@param array<mixed>" annotations (e.g., on the Data class
constructor or setData method) with "@var array<array-key, mixed>" and "@param
array<array-key, mixed>" respectively to improve static-analysis precision for
the Data class and its $data member.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 47888c32-21cb-4ac8-a181-f383f38b9add

📥 Commits

Reviewing files that changed from the base of the PR and between ee1654d and ee5317a.

📒 Files selected for processing (1)
  • src/Contracts/Data.php

@Strift Strift removed the enhancement New feature or request label Apr 28, 2026
@Strift Strift added this pull request to the merge queue Apr 28, 2026
Merged via the queue into meilisearch:main with commit f1b6c51 Apr 28, 2026
10 of 12 checks passed
@Strift Strift changed the title Add types to Data ArrayAccess methods Add types Data ArrayAccess methods Apr 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

breaking-change The related changes are breaking for the users

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add parameter types to Data ArrayAccess methods

2 participants