Skip to content

Conversation

@norkunas
Copy link
Collaborator

@norkunas norkunas commented Nov 19, 2025

Pull Request

Related issue

Fixes #767

What does this PR do?

  • Removes legacy namespace

PR checklist

Please check if your PR fulfills the following requirements:

  • 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

  • Refactor
    • Version information is now returned as a structured object with dedicated accessor methods (getCommitSha(), getCommitDate(), getPkgVersion()) instead of an associative array. Update code accessing version endpoint data accordingly.

@norkunas norkunas added enhancement New feature or request breaking-change The related changes are breaking for the users labels Nov 19, 2025
@coderabbitai
Copy link

coderabbitai bot commented Nov 19, 2025

Warning

Rate limit exceeded

@norkunas has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 20 minutes and 12 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between 092ef2b and 4224268.

📒 Files selected for processing (1)
  • composer.json (0 hunks)

Walkthrough

The pull request removes the deprecated MeiliSearch PSR-4 autoload alias from composer.json. HTTP interface and client methods gain explicit mixed return types. A new immutable Version class is introduced to encapsulate version metadata, replacing array-based responses. The version() method in HandlesSystem now returns a Version object instead of an array. Related tests are updated accordingly.

Changes

Cohort / File(s) Summary
Namespace cleanup
composer.json
Removed deprecated MeiliSearch\\ PSR-4 autoload mapping, retaining only Meilisearch\\.
HTTP return types
src/Contracts/Http.php,
src/Http/Client.php
Added explicit mixed return type to get(), post(), put(), patch(), and delete() methods in both interface and implementation.
Version class
src/Contracts/Version.php
Introduced new final immutable Version class with readonly properties (commitSha, commitDate, pkgVersion), accessor methods, and static fromArray() factory method.
System version handling
src/Endpoints/Delegates/HandlesSystem.php
Changed version() return type from array to \MeiliSearch\Contracts\Version, now wrapping result via Version::fromArray().
Version test update
tests/Endpoints/ClientTest.php
Updated testVersion() assertions to use object accessors (getCommitSha(), getPkgVersion()) instead of array key access.

Sequence Diagram

sequenceDiagram
    autonumber
    participant Client
    participant HandlesSystem
    participant HttpClient
    participant VersionFactory

    Client->>HandlesSystem: version()
    HandlesSystem->>HttpClient: $this->version->show()
    HttpClient-->>HandlesSystem: array {commitSha, commitDate, pkgVersion}
    HandlesSystem->>VersionFactory: Version::fromArray(array)
    VersionFactory-->>HandlesSystem: Version (immutable object)
    HandlesSystem-->>Client: Version object
    
    Note over Client: Now uses Version methods:<br/>getCommitSha(), getCommitDate(),<br/>getPkgVersion()
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

  • Key attention areas:
    • Verify Version class immutability and thread-safety of readonly properties
    • Confirm fromArray() factory properly validates and transforms commitDate string to DateTimeImmutable
    • Ensure return type mixed on HTTP methods is intentional and does not mask type information during client usage
    • Validate all callers of version() method handle the new object-based API correctly
    • Check backward compatibility implications if external code depends on array-based version responses

Poem

🐰 Namespaces tidied, types refined,
The MeiliSearch ghost left behind,
Version now immutable, dressed in her best,
Arrays transformed—the mixed returns test.
A cleanup so clean, precise, and bright! 🌟

Pre-merge checks and finishing touches

❌ Failed checks (2 warnings)
Check name Status Explanation Resolution
Out of Scope Changes check ⚠️ Warning The PR contains substantial out-of-scope changes beyond removing the legacy namespace, including new Version contract, Http return types, and test modifications unrelated to issue #767. Remove out-of-scope changes (src/Contracts/Version.php, Http return types, HandlesSystem updates, and test changes) or document their necessity for the namespace removal in issue #767.
Docstring Coverage ⚠️ Warning Docstring coverage is 55.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Remove legacy namespace' accurately summarizes the primary objective of removing the deprecated MeiliSearch PSR-4 autoloading alias from composer.json.
Linked Issues check ✅ Passed The PR removes the legacy MeiliSearch namespace alias from composer.json [#767], aligning with the linked issue objective to remove PSR-4 autoloading for the deprecated namespace.

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.

Copy link

@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.

Actionable comments posted: 2

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
tests/Endpoints/ClientTest.php (1)

202-208: Update namespace from MeiliSearch to Meilisearch in three locations to match autoloader configuration

The test expectations are correct, but the code will fail at runtime due to a namespace mismatch. The src/Contracts/Version.php file and its references use the legacy MeiliSearch\Contracts namespace, which is not exposed by the PSR-4 autoloader (which only defines Meilisearch\\). Update these locations:

  • src/Contracts/Version.php line 5: Change namespace MeiliSearch\Contracts; to namespace Meilisearch\Contracts;
  • src/Endpoints/Delegates/HandlesSystem.php line 36: Change return type from \MeiliSearch\Contracts\Version to \Meilisearch\Contracts\Version
  • src/Endpoints/Delegates/HandlesSystem.php line 38: Change \MeiliSearch\Contracts\Version::fromArray() to \Meilisearch\Contracts\Version::fromArray()
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 4d90618 and 092ef2b.

📒 Files selected for processing (6)
  • composer.json (0 hunks)
  • src/Contracts/Http.php (1 hunks)
  • src/Contracts/Version.php (1 hunks)
  • src/Endpoints/Delegates/HandlesSystem.php (1 hunks)
  • src/Http/Client.php (5 hunks)
  • tests/Endpoints/ClientTest.php (1 hunks)
💤 Files with no reviewable changes (1)
  • composer.json
🧰 Additional context used
🧬 Code graph analysis (4)
src/Http/Client.php (4)
src/Contracts/Http.php (5)
  • get (16-16)
  • post (24-24)
  • put (32-32)
  • patch (38-38)
  • delete (44-44)
src/Endpoints/Tasks.php (1)
  • get (20-23)
src/Endpoints/Keys.php (2)
  • get (156-161)
  • delete (208-211)
src/Endpoints/Indexes.php (1)
  • delete (147-153)
src/Contracts/Http.php (5)
src/Http/Client.php (5)
  • get (69-77)
  • post (87-98)
  • put (108-119)
  • patch (121-129)
  • delete (131-139)
src/Endpoints/Tasks.php (1)
  • get (20-23)
src/Endpoints/Batches.php (1)
  • get (13-16)
src/Endpoints/Keys.php (2)
  • get (156-161)
  • delete (208-211)
src/Endpoints/Indexes.php (1)
  • delete (147-153)
src/Endpoints/Delegates/HandlesSystem.php (2)
src/Contracts/Version.php (2)
  • Version (7-53)
  • fromArray (45-52)
src/Contracts/Endpoint.php (1)
  • show (19-22)
tests/Endpoints/ClientTest.php (1)
src/Contracts/Version.php (2)
  • getCommitSha (23-26)
  • getPkgVersion (33-36)
🪛 GitHub Actions: Tests
src/Endpoints/Delegates/HandlesSystem.php

[error] 38-38: PHPUnit-related failure: Class 'MeiliSearch\Contracts\Version' not found. (Call stack reference from HandlesSystem.php)

tests/Endpoints/ClientTest.php

[error] 204-204: PHPUnit error: Class 'MeiliSearch\Contracts\Version' not found. (Triggered during test Versions in ClientTest)

🔇 Additional comments (2)
src/Http/Client.php (1)

69-139: Adding mixed return types to HTTP methods matches actual behaviour and the Http contract

The explicit mixed return types on get, post, put, patch, and delete correctly document what execute()/parseResponse() already return (decoded JSON or null), and they stay in sync with the updated Meilisearch\Contracts\Http interface. No functional issues stand out here.

Given this is a public class and interface, it’s worth confirming that any custom Http implementations (or subclasses) in your ecosystem are updated to match the new signatures.

src/Contracts/Http.php (1)

16-50: Http contract now exposes flexible mixed responses; ensure all implementations are updated

Changing get, post, put, patch, and delete to return mixed (and updating post/put parameters) brings the interface in line with the actual Client behaviour and the variety of response payloads.

This is a breaking change for any userland classes implementing Meilisearch\Contracts\Http, so it would be good to confirm:

  • All internal implementations have been updated, and
  • The changelog/release notes clearly call out the new method signatures for v2.

@norkunas norkunas force-pushed the remove-legacy-namespace branch from 092ef2b to 62e3a3a Compare November 19, 2025 14:49
@codecov
Copy link

codecov bot commented Nov 19, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 88.32%. Comparing base (0078a8c) to head (4224268).
⚠️ Report is 88 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #822      +/-   ##
==========================================
- Coverage   89.78%   88.32%   -1.46%     
==========================================
  Files          59       78      +19     
  Lines        1449     1679     +230     
==========================================
+ Hits         1301     1483     +182     
- Misses        148      196      +48     

☔ 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.

@norkunas norkunas force-pushed the remove-legacy-namespace branch from 62e3a3a to eb28e5a Compare November 24, 2025 04:43
@norkunas norkunas force-pushed the remove-legacy-namespace branch from eb28e5a to 4224268 Compare November 24, 2025 05:21
@Strift Strift added this pull request to the merge queue Nov 24, 2025
Merged via the queue into meilisearch:main with commit 2df206d Nov 24, 2025
10 of 11 checks passed
@norkunas norkunas deleted the remove-legacy-namespace branch November 24, 2025 08:01
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 enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Remove psr4 autoloading MeiliSearch alias

2 participants