Skip to content

Remove Ray\ServiceLocator\ServiceLocator#19

Merged
koriym merged 2 commits intoray-di:1.xfrom
NaokiTsuchiya:fix/service-locator
Feb 4, 2026
Merged

Remove Ray\ServiceLocator\ServiceLocator#19
koriym merged 2 commits intoray-di:1.xfrom
NaokiTsuchiya:fix/service-locator

Conversation

@NaokiTsuchiya
Copy link
Copy Markdown
Member

@NaokiTsuchiya NaokiTsuchiya commented Feb 4, 2026

Summary by Sourcery

Enhancements:

  • Replace ServiceLocator-based annotation lookup with native attribute-based detection for Injectable classes.

Summary by CodeRabbit

  • Refactor
    • Modernized internal implementation to use PHP 8 attributes; behavior is unchanged and there are no user-facing changes.
  • Chores
    • CI updated to test with PHP 8.5 and skip incompatible framework-version combinations.

@NaokiTsuchiya NaokiTsuchiya self-assigned this Feb 4, 2026
@sourcery-ai
Copy link
Copy Markdown

sourcery-ai bot commented Feb 4, 2026

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Replaces the Ray ServiceLocator-based annotation lookup with native PHP attribute reflection for determining if a class is marked as Injectable, thereby removing the dependency on Ray\ServiceLocator\ServiceLocator.

Sequence diagram for Injectable detection using PHP attributes

sequenceDiagram
    participant Application
    participant ReflectionClass
    participant InjectableAttribute as Injectable

    Application->>Application: shouldBeResolvedByRay(abstract)
    Application->>ReflectionClass: new ReflectionClass(abstract)
    Application->>ReflectionClass: getAttributes(Injectable)
    ReflectionClass-->>Application: attributes[]
    Application->>Application: check if attributes is empty
    alt attributes is empty
        Application-->>Application: return false
    else attributes not empty
        Application-->>Application: proceed with Ray resolution
    end
Loading

Updated class diagram for Application Injectable detection logic

classDiagram
    class Application {
        - injector : InjectorInterface
        - laravelContainer : IlluminateContainer
        + __construct(injector : InjectorInterface, laravelContainer : IlluminateContainer)
        - shouldBeResolvedByRay(abstract : string) bool
    }

    class ReflectionClass {
        + __construct(className : string)
        + getAttributes(name : string) Attribute[]
    }

    class Injectable {
        <<attribute>>
    }

    class InjectorInterface {
        <<interface>>
    }

    class IlluminateContainer {
    }

    Application --> InjectorInterface : uses
    Application --> IlluminateContainer : uses
    Application --> ReflectionClass : uses for metadata
    ReflectionClass --> Injectable : returns attributes of type
Loading

File-Level Changes

Change Details Files
Switch Injectable detection from ServiceLocator annotations to native PHP attributes and remove the ServiceLocator dependency.
  • Remove the import of the Ray ServiceLocator class
  • Use ReflectionClass::getAttributes with the Injectable attribute instead of ServiceLocator::getReader()->getClassAnnotation
  • Change the check from a null annotation result to an empty-attribute-array check to decide if a class should be resolved by Ray
src/Application.php

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Feb 4, 2026

📝 Walkthrough

Walkthrough

Replaced runtime annotation reading via ServiceLocator with PHP 8 attribute inspection for Injectable in src/Application.php. CI matrix updated to include PHP 8.5 with exclusions for incompatible Laravel versions in .github/workflows/continuous-integration.yml.

Changes

Cohort / File(s) Summary
Application attribute switch
src/Application.php
Replaced ServiceLocator-based class annotation lookup with ReflectionClass attribute inspection for Injectable; removed unused ServiceLocator import. Control flow and tracking of resolved abstracts unchanged.
CI matrix update
.github/workflows/continuous-integration.yml
Added PHP 8.5 to the test matrix and added exclusions for Laravel 8.83 and Laravel 9 combinations incompatible with PHP 8.5.

Sequence Diagram(s)

(omitted)

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

  • Fix CI #17 — Changes to CI matrix and Laravel-version handling that overlap with PHP/Laravel matrix adjustments.

Suggested reviewers

  • koriym

Poem

🐰 I swapped the old ink for shining traits,
Reflection now finds the hopeful gates,
CI adds a new PHP day,
Tests hop forth to join the play,
Code hums softly — a carrot fête. 🥕

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately reflects the main change: removing the ServiceLocator dependency from the codebase by replacing it with PHP 8 attributes for Injectable detection.

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

✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey - I've reviewed your changes and they look great!


Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@koriym koriym merged commit 52e950b into ray-di:1.x Feb 4, 2026
39 checks passed
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