Skip to content

Conversation

@koriym
Copy link
Member

@koriym koriym commented Aug 3, 2025

Summary

  • Add comprehensive Psalm domain type definitions for Ray.Di components
  • Fix static analysis errors identified by Psalm and PHPStan
  • Improve type safety across the dependency injection framework

Changes

  • Types.php: Define domain-specific type aliases for better type inference
  • Container.php: Add proper return type annotations and mixed return suppression
  • Name.php: Fix parameter name mapping to support empty string keys (Name::ANY)
  • Bind.php: Add null coalescing operator for safe array access
  • Arguments.php: Update return type annotation to list
  • AssistedInjectInterceptor.php: Clean up type annotations
  • DependencyInterface.php: Remove redundant psalm-assert annotation
  • phpstan.neon: Configure raw error format for better CI integration

Test plan

  • All existing tests pass
  • Psalm analysis shows no errors
  • PHPStan warnings reduced from 7 to 2 (minor warnings only)
  • Static analysis integration improved

🤖 Generated with Claude Code

Summary by Sourcery

Enhance type safety across the Ray.Di dependency injection framework by defining reusable Psalm type aliases, updating docblocks to import those types, and fixing static analysis issues reported by Psalm and PHPStan.

New Features:

  • Introduce Types.php with comprehensive Psalm type aliases for Ray.Di domain types

Bug Fixes:

  • Fix Name class to support empty-string keys for Name::ANY mapping
  • Resolve various static analysis errors flagged by Psalm and PHPStan

Enhancements:

  • Import and apply domain-specific Psalm types across core DI classes to improve type safety
  • Add null coalescing checks, refine docblock annotations, and suppress mixed-type warnings

CI:

  • Configure phpstan.neon to use raw error format for improved CI integration

Documentation:

  • Add CLAUDE.md with project overview and development guidance

Tests:

  • Suppress PHPStan warnings in BindTest to accommodate the updated type annotations

Summary by CodeRabbit

  • Documentation

    • Added new documentation file outlining project overview, architecture, usage, and development commands.
    • Introduced comprehensive static type alias documentation for enhanced code clarity.
  • New Features

    • Enhanced static analysis and type safety through extensive use of Psalm type annotations and type aliasing.
  • Refactor

    • Updated codebase and demos to use PHP 8 features such as constructor property promotion and native attribute syntax for dependency injection and qualifiers.
    • Improved property and method type declarations for stricter typing and better IDE support.
    • Replaced legacy annotation styles with PHP 8 attributes throughout demo classes.
  • Style

    • Modernized demo code for clarity and conciseness.
  • Chores

    • Upgraded GitHub Actions workflows to use latest action versions and updated output handling.
    • Set environment variable for temporary directory in demo runner script.
  • Tests

    • Suppressed static analysis warnings in test code where appropriate.
  • Bug Fixes

    • Improved type safety to prevent undefined index notices and enhance static analysis reliability.

koriym and others added 7 commits July 18, 2025 10:11
- Create Types.php with 40+ Psalm type definitions for Ray.Di framework
- Apply type definitions to core files: Container, Bind, Dependency, Arguments, Name
- Achieve 99.41% type inference coverage with zero static analysis errors
- Add proper type annotations for dependency injection patterns
- Include CLAUDE.md documentation for future development

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
- Rename template variables to be unique and descriptive:
  - T → TInterceptor for MethodInterceptor types
  - T → TProvider for Provider types
  - T → TClass for object class types
  - T → TOptional for optional binding types
- Maintain 99.41% type inference coverage with zero errors

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
- Remove unused type definitions:
  - BindingErrorReason (not used in codebase)
  - SerializableDependencyData (not used in codebase)
  - InjectionPointSerialData (not used in codebase)
  - ModuleInstallChain (not used in codebase)
  - ModuleOverrideChain (not used in codebase)
- Improve PHPDoc formatting with clean group headers
- Maintain 99.41% type inference coverage with zero errors
- Keep only practically used type definitions

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
- Replace array<SetterMethod> with SetterMethodsList in SetterMethods and VisitorInterface
- Replace array<Argument> with ArgumentList in VisitorInterface
- Replace array<int, Pointcut> with PointcutList in Dependency and ModuleString
- Replace array<class-string<MethodInterceptor>> with InterceptorClassList in AbstractModule
- Replace array<non-empty-string, list<MethodInterceptor>> with MethodInterceptorBindings in AspectBind
- Replace array<object> with QualifierList in InjectionPointInterface
- Replace array<string, string> with ParameterNameMapping in Name and Bind
- Replace array<string, mixed> with NamedArguments in AssistedInjectInterceptor
- Replace non-empty-array<AbstractModule> with ModuleList in Injector and ContainerFactory
- Replace array{0: string, 1: string, 2: bool} with InjectionPointDefinition in InjectionPoints

Enhance Types.php with domain-specific type aliases while maintaining separation
between technical types and domain types. Improve static analysis coverage to 99.23%.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
- Fix array offset access in Bind.php with null coalescing operator
- Update Container.php with proper return type annotations and suppress mixed return
- Refine ParameterNameMapping type to allow empty string keys for Name::ANY
- Add missing type imports and improve parameter handling in Name.php
- Update Arguments.php return type annotation to list<mixed>
- Clean up AssistedInjectInterceptor type annotations
- Remove redundant psalm-assert annotation from DependencyInterface
- Configure PHPStan raw error format for better CI integration

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
@sourcery-ai
Copy link

sourcery-ai bot commented Aug 3, 2025

Reviewer's Guide

This PR centralizes Psalm domain type definitions in a new Types.php file, updates docblocks across the Ray.Di codebase to leverage these aliases for stronger type safety, and resolves various Psalm/PHPStan errors by refining annotations, removing obsolete assertions, and tuning CI configuration.

File-Level Changes

Change Details Files
Introduce centralized Psalm domain types file
  • Create Types.php with @psalm-type aliases for DI containers, arguments, bindings, AOP, and more
src/di/Types.php
Migrate docblocks to use domain-specific type aliases
  • Add @psalm-import-type declarations to classes
  • Replace generic array/mixed annotations with aliases like DependencyContainer, MethodArguments, ParameterNameMapping, etc.
  • Adjust @return and @param tags to refer to list and domain types
src/di/Container.php
src/di/Bind.php
src/di/Name.php
src/di/Argument.php
src/di/Dependency.php
src/di/AbstractModule.php
src/di/NewInstance.php
src/di/InjectionPoints.php
src/di/Injector.php
src/di/ContainerFactory.php
src/di/DependencyInterface.php
src/di/Arguments.php
src/di/AssistedInjectInterceptor.php
src/di/Grapher.php
src/di/ModuleString.php
src/di/SetterMethods.php
src/di/VisitorInterface.php
src/di/AspectBind.php
src/di/InjectionPointInterface.php
src/di/MultiBinder.php
src/di/MultiBinding/MultiBindingModule.php
src/di/MultiBinding/MultiBindings.php
src/di/SpyCompiler.php
Resolve static analysis errors and refine CI settings
  • Remove obsolete assert calls and add safe null coalescing for array access
  • Fix Name parameter mapping to support empty string keys and suppress mixed return warnings
  • Update phpstan.neon for raw error formatting and ignore specific test lines
src/di/Container.php
src/di/Bind.php
src/di/Name.php
phpstan.neon
tests/di/BindTest.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

coderabbitai bot commented Aug 3, 2025

Walkthrough

This set of changes introduces comprehensive Psalm type alias definitions in a new Types.php file and systematically updates type annotations throughout the Ray.Di dependency injection framework for improved static analysis. Several demo files are modernized to use PHP 8 attributes and constructor property promotion. Documentation and workflow files are also updated, including the addition of a new CLAUDE.md guidance document.

Changes

Cohort / File(s) Change Summary
Psalm Type Aliases
src/di/Types.php
Adds a new file defining numerous Psalm type aliases for enhanced static analysis across the DI framework.
Type Annotations Refactor
src/di/AbstractModule.php, src/di/Argument.php, src/di/Arguments.php, src/di/AspectBind.php, src/di/AssistedInjectInterceptor.php, src/di/Bind.php, src/di/Container.php, src/di/ContainerFactory.php, src/di/Dependency.php, src/di/DependencyInterface.php, src/di/Grapher.php, src/di/InjectionPointInterface.php, src/di/InjectionPoints.php, src/di/Injector.php, src/di/ModuleString.php, src/di/MultiBinder.php, src/di/MultiBinding/MultiBindingModule.php, src/di/MultiBinding/MultiBindings.php, src/di/Name.php, src/di/NewInstance.php, src/di/SetterMethods.php, src/di/SpyCompiler.php, src/di/VisitorInterface.php
Updates and refines type annotations in classes and interfaces to use Psalm-imported type aliases, improving type safety and static analysis. No runtime logic changes.
Demo Modernization: PHP 8 Attributes & Typing
demo/01a-linked-binding.php, demo/01b-linked-binding-setter-injection.php, demo/02-provider-binding.php, demo/02a-named-by-qualifier.php, demo/02b-named-by-named.php, demo/03-injection-point.php, demo/05b-constructor-binding-setter-injection.php, demo/finder/Db.php, demo/finder/DbFinder.php, demo/finder/MovieFinder.php, demo/finder/MovieLister.php
Refactors demo classes to use PHP 8 constructor property promotion, strict typing, and native attribute syntax (#[Inject], #[Named], etc.) for dependency injection and qualifiers, replacing PHPDoc annotations.
Demo Support Script
demo/run.php
Adds putenv() to set the TMPDIR environment variable at script start.
Documentation
CLAUDE.md
Adds a new documentation file providing AI guidance on Ray.Di's architecture, usage, and development practices.
PHPStan & Psalm Static Analysis Config
phpstan.neon, tests/di/BindTest.php
Updates static analysis configuration and adds suppression for a specific test case.
GitHub Actions Workflow Updates
.github/workflows/demo.yml, .github/workflows/update-copyright-years-in-license-file.yml
Upgrades actions to latest versions, updates output variable setting, and points demo workflow to the unified demo script.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant DemoClass
    participant RayDiContainer

    User->>DemoClass: Instantiate with PHP 8 promoted/annotated constructor
    DemoClass->>RayDiContainer: Requests dependency via attribute (e.g., #[Inject])
    RayDiContainer-->>DemoClass: Injects dependency per attribute/type
    DemoClass->>User: Ready for use with injected dependencies
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Suggested reviewers

  • NaokiTsuchiya

Poem

🐇✨
In fields of types, I nibbled through,
Psalm aliases fresh as morning dew.
With attributes bright and syntax neat,
The demos now feel extra sweet.
Static checks hop strong and spry—
This bunny’s code is typed to fly!
🥕


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a08a24f and d016ec3.

📒 Files selected for processing (1)
  • src/di/ContainerFactory.php (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/di/ContainerFactory.php
✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • 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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@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 @koriym - I've reviewed your changes - here's some feedback:

  • Consider refining the few remaining @psalm-suppress annotations by tightening your code-level types so suppressions are only used where absolutely necessary.
  • The newly added Types.php file centralizes many Psalm type aliases—consider grouping or segmenting related type groups (e.g. AOP, injection, multi-binding) into smaller modules to improve readability and maintainability.
  • There are still two PHPStan warnings—address them now or add contextual suppressions to fully close the gap in your static analysis coverage.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- Consider refining the few remaining @psalm-suppress annotations by tightening your code-level types so suppressions are only used where absolutely necessary.
- The newly added Types.php file centralizes many Psalm type aliases—consider grouping or segmenting related type groups (e.g. AOP, injection, multi-binding) into smaller modules to improve readability and maintainability.
- There are still two PHPStan warnings—address them now or add contextual suppressions to fully close the gap in your static analysis coverage.

## Individual Comments

### Comment 1
<location> `src/di/Types.php:48` </location>
<code_context>
+ * @psalm-type MethodInterceptorBindings array<non-empty-string, list<MethodInterceptor>>
+ * @psalm-type InterceptorClassList array<class-string<MethodInterceptor>>
+ * @psalm-type VisitorResult = object|array<array-key, mixed>|null
+ * @psalm-type SetterMethodList = array<SetterMethod>
+ * @psalm-type ArgumentList = array<Argument>
+ *
+ * Reflection and Metadata Types
</code_context>

<issue_to_address>
Duplicate or inconsistent type aliases for SetterMethodList/SetterMethodsList and ArgumentList/ArgumentsList.

Please standardize the naming of these type aliases to ensure consistency and prevent confusion.

Suggested implementation:

```
 * @psalm-type SetterMethodsList = array<SetterMethod>
 * @psalm-type ArgumentsList = array<Argument>

```

- Update all usages of `SetterMethodList` to `SetterMethodsList` and `ArgumentList` to `ArgumentsList` throughout the codebase for consistency.
- If there are other aliases like `SetterMethodsList` or `ArgumentsList` already defined elsewhere, remove the duplicates to avoid confusion.
</issue_to_address>

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.

@codecov
Copy link

codecov bot commented Aug 3, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.49%. Comparing base (941d25c) to head (d016ec3).
⚠️ Report is 65 commits behind head on 2.x.

❌ Your project status has failed because the head coverage (99.49%) is below the target coverage (100.00%). You can increase the head coverage or adjust the target coverage.

Additional details and impacted files
@@              Coverage Diff              @@
##                 2.x     #299      +/-   ##
=============================================
- Coverage     100.00%   99.49%   -0.51%     
- Complexity       359      365       +6     
=============================================
  Files             49       50       +1     
  Lines            963      996      +33     
=============================================
+ Hits             963      991      +28     
- Misses             0        5       +5     

☔ 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

@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: 6

🔭 Outside diff range comments (3)
src/di/Grapher.php (1)

61-67: Align the parameter PHPDoc with the imported alias.

Replace list<mixed> with the imported MethodArguments to gain the benefit of the centralized type definition and eliminate the unused-import warning.

-     * @param string      $class  class name
-     * @param list<mixed> $params construct parameters (MethodArguments)
+     * @param string            $class  class name
+     * @param MethodArguments   $params constructor arguments
src/di/VisitorInterface.php (1)

79-83: Propagate the alias fix to parameter annotation

After correcting the import line, update the parameter tag to stay in sync:

- * @param ArgumentList $arguments
+ * @param ArgumentsList $arguments
src/di/Name.php (1)

115-123: Possible null array access when only an empty binding name is provided

$this->names is accessed without being initialised when $this->name === '' (i.e. Name::ANY).
Constructing new Name(Name::ANY) sets $this->name to an empty string but never populates $this->names, so calling the object later in __invoke() will raise “Trying to access array offset on null”.

A minimal defensive fix:

-        return $this->names[$parameterName] ?? $this->names[self::ANY] ?? self::ANY;
+        return $this->names[$parameterName]                // per-parameter binding
+            ?? $this->names[self::ANY] ?? self::ANY;       // fallback bindings

or, guard the property first:

return $this->names[$parameterName]
    ?? ($this->names[self::ANY] ?? self::ANY);
🧹 Nitpick comments (15)
src/di/SpyCompiler.php (1)

32-40: Consider using a standardized @psalm-suppress ... justification line instead of a prose NOTE

Psalm recognises an optional justification string placed on the same @psalm-suppress line (e.g. @psalm-suppress MoreSpecificReturnType Dummy class used only for logging).
Encoding the rationale that way keeps the comment machine-parsable and consistent with the rest of the docblock style, while avoiding additional prose lines.

CLAUDE.md (1)

1-4: Use a descriptive title instead of the filename

Starting the document with the literal filename is uncommon in Markdown docs. A descriptive heading improves readability when the file is rendered on GitHub/GitLab.

-# CLAUDE.md
+# Guide for Claude Code 🤖
src/di/Types.php (1)

48-65: Duplicate / confusing aliases for setter methods

SetterMethodList (singular) and SetterMethodsList (plural) are both defined but map to the same shape.
Consider keeping only one to avoid ambiguity.

src/di/AssistedInjectInterceptor.php (2)

23-32: Redundant twin docblocks – collapse into one

You have a file-scope import block (lines 23-26) and then replicate the same imports in the class-level docblock (line 31). One is enough; keep the one closest to the class.


72-90: Leverage the new NamedArguments alias in return annotation

getNamedArguments() currently returns array<string, mixed> even though NamedArguments is imported.

-     * @return array<string, mixed>
+     * @return NamedArguments

This gives Psalm stronger guarantees and eliminates another mixed array.

src/di/MultiBinder.php (1)

13-16: Imported aliases are unused

BindableInterface and LazyBindingList are not referenced anywhere in this class.
Remove the import block or use the aliases to document $container / $multiBindings.

src/di/MultiBinding/MultiBindingModule.php (1)

13-15: Unused BindableInterface import

Same situation as in MultiBinder.php – either use the alias or drop the import block.

tests/di/BindTest.php (1)

54-56: Use a consistent PHPStan suppression style.

Earlier in this file you suppress PHPStan with the inline form // @phpstan-ignore-line, whereas here you switch to the docblock form /** @phpstan-ignore-next-line */. Mixing the two makes the test harder to scan for suppressions.

-        /** @phpstan-ignore-next-line */
+        // @phpstan-ignore-line
         new Bind(new Container(), 'invalid-interface');
src/di/Injector.php (1)

34-35: Consider giving $module a real union type

Now that PHP 8+ supports union types you could surface the same information in the method signature:

-public function __construct($module = null, string $tmpDir = '')
+public function __construct(
+    AbstractModule|array|null $module = null,
+    string $tmpDir = ''
+)

This would let Psalm/PhpStan skip the PHPDoc fallback.

src/di/NewInstance.php (2)

54-56: Minor: repeated Psalm suppression could be avoided

$reflection->newInstanceArgs() is always safe here because $arguments->inject() returns an array. Consider adding a narrow return type on Arguments::inject() instead of suppressing MixedMethodCall every use-site.


70-71: Parameter still typed as array

Since you now document $params as MethodArguments, you could update the method signature for extra static safety:

- public function newInstanceArgs(Container $container, array $params): object
+ public function newInstanceArgs(Container $container, array $params /* MethodArguments */): object

(Or declare the alias directly once Psalm supports it in signatures.)

src/di/Dependency.php (1)

88-90: Same note as in NewInstance – you may eventually expose MethodArguments in the signature when possible to drop the generic array.

src/di/ContainerFactory.php (1)

35-36: Same ordering issue in getModule() – swap the @param annotations to match the actual signature.

src/di/Name.php (1)

160-167: Typo: $trimedKey should be $trimmedKey

Misspelling in a frequently-used helper makes grep-based searches harder and is an easy source of copy-paste bugs.

-                $trimedKey = trim((string) $key);
-                $names[$trimedKey] = trim($value);
+                $trimmedKey = trim((string) $key);
+                $names[$trimmedKey] = trim($value);
src/di/Container.php (1)

33-35: Property annotation conflicts with the default value

@var DependencyContainer requires non-empty string keys, yet the property is initialised to an empty array.
Psalm treats [] as array<empty, empty> which is incompatible and will raise InvalidPropertyAssignmentValue.

Either:

- /** @var DependencyContainer */
- private $container = [];
+ /** @var DependencyContainer */
+ private $container = []; // @phpstan-ignore-line (empty initial state is allowed)

or loosen the alias to allow the empty state.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 33a4a68 and 984f82b.

📒 Files selected for processing (27)
  • CLAUDE.md (1 hunks)
  • phpstan.neon (1 hunks)
  • src/di/AbstractModule.php (4 hunks)
  • src/di/Argument.php (4 hunks)
  • src/di/Arguments.php (2 hunks)
  • src/di/AspectBind.php (2 hunks)
  • src/di/AssistedInjectInterceptor.php (1 hunks)
  • src/di/Bind.php (6 hunks)
  • src/di/Container.php (7 hunks)
  • src/di/ContainerFactory.php (2 hunks)
  • src/di/Dependency.php (3 hunks)
  • src/di/DependencyInterface.php (2 hunks)
  • src/di/Grapher.php (2 hunks)
  • src/di/InjectionPointInterface.php (2 hunks)
  • src/di/InjectionPoints.php (2 hunks)
  • src/di/Injector.php (3 hunks)
  • src/di/ModuleString.php (1 hunks)
  • src/di/MultiBinder.php (1 hunks)
  • src/di/MultiBinding/MultiBindingModule.php (1 hunks)
  • src/di/MultiBinding/MultiBindings.php (1 hunks)
  • src/di/Name.php (6 hunks)
  • src/di/NewInstance.php (3 hunks)
  • src/di/SetterMethods.php (1 hunks)
  • src/di/SpyCompiler.php (1 hunks)
  • src/di/Types.php (1 hunks)
  • src/di/VisitorInterface.php (3 hunks)
  • tests/di/BindTest.php (1 hunks)
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: the use of "ray/aop": "^2.x-dev" in composer.json is intentional as it depends on features from the ...
Learnt from: koriym
PR: ray-di/Ray.Di#297
File: composer.json:17-17
Timestamp: 2025-02-22T08:34:22.655Z
Learning: The use of "ray/aop": "^2.x-dev" in composer.json is intentional as it depends on features from the upcoming version that hasn't been released yet.

Applied to files:

  • src/di/ModuleString.php
  • src/di/Dependency.php
🧬 Code Graph Analysis (1)
src/di/MultiBinding/MultiBindingModule.php (1)
src/di/Types.php (1)
  • Types (71-73)
🔇 Additional comments (20)
CLAUDE.md (1)

25-46: All Composer scripts referenced in “Development Commands” are present

The listed commands (test, coverage, pcov, cs, cs-fix, sa, clean, build, tests) in CLAUDE.md match the entries under composer.json > scripts. No updates needed.

src/di/InjectionPointInterface.php (1)

11-13: LGTM – type alias import is correctly applied.

The new QualifierList alias clarifies the return type without impacting runtime behaviour.

Also applies to: 37-39

src/di/ModuleString.php (1)

16-24: LGTM – pointcut collection now strongly typed.
The PointcutList alias improves clarity while keeping runtime unchanged.

src/di/AspectBind.php (1)

12-30: LGTM – return type correctly narrowed with MethodInterceptorBindings.

src/di/SetterMethods.php (1)

9-19: Psalm alias import & annotations look correct

The new @psalm-import-type SetterMethodsList import and the updated property / constructor annotations are consistent with the alias naming convention used across the PR and will improve static-analysis fidelity.
No further action required.

src/di/InjectionPoints.php (2)

10-20: Type-alias adoption is sound

InjectionPointDefinition and InjectionPointsList are imported and applied consistently to both the property and the helper method parameter. These doc-block refinements align with the new central Types definitions and need no changes.


53-58: Method signature remains compatible

The helper keeps the runtime signature array $point, while the doc-block narrows the expected structure via the alias. This is the accepted pattern when PHP can’t express tuple-like shapes. Good to merge.

src/di/Arguments.php (2)

10-17: Accurate alias usage for Arguments

Importing ArgumentsList and MethodArguments plus annotating the property enhances Psalm coverage without affecting runtime behaviour.


30-34: Return type narrowed to list<mixed>

The new doc-block correctly reflects the sequential array guarantee delivered by the implementation. No further change needed.

src/di/DependencyInterface.php (1)

7-34: Consistent container alias, but check naming

The interface now imports DependencyContainer, ScopeType, and InjectableValue; the register doc-block references DependencyContainer and marks it @param-out, which is correct for a by-ref array.
Looks good.

src/di/MultiBinding/MultiBindings.php (1)

8-14: Type-alias import is spot-on

Importing Types and re-using the LazyBindingList alias tightens Psalm coverage and removes duplication across the codebase. No other concerns here.

src/di/Injector.php (1)

21-24: Good use of central Psalm aliases

The BindableInterface and ModuleList imports remove a lot of inline doc clutter. Looks correct given the new Types class.

src/di/NewInstance.php (1)

14-16: Alias import keeps docs concise

Importing MethodArguments here is consistent with the rest of the refactor. No issues.

src/di/Dependency.php (2)

18-22: Psalm aliases correctly applied

The switch to MethodArguments / PointcutList keeps the docs in sync with the rest of the PR.


123-124: Pointcut list alias looks good

The new docblock matches the actual usage in weaveAspects().

src/di/ContainerFactory.php (1)

11-13: Consistent alias import

The ModuleList import is correct and lines up with the rest of the refactor.

src/di/Argument.php (1)

112-118: __unserialize() DocBlock shape does not match the real payload

The annotation advertises six elements (0 … 5) but __serialize() actually returns only five.
This makes Psalm / PHPStan ignore valuable structural checks.

- * @param array{0: DependencyIndex, 1: bool, 2: string, 3: string, 4: string, 5: array{0: string, 1: string, 2:string}} $unserialized
+ * @param array{
+ *     0: DependencyIndex,
+ *     1: bool,
+ *     2: mixed,                 # same type as $default
+ *     3: string,
+ *     4: array{0:string,1:string,2:string}
+ * } $unserialized

Adjusting the DocBlock (or the actual payload) keeps static analysis reliable.

src/di/AbstractModule.php (1)

80-88: InterceptorClassList may be too restrictive for the real usage

bindInterceptor() accepts both concrete interceptor classes and qualifier interfaces (see Lines 88-96).
If InterceptorClassList is defined as list<class-string<MethodInterceptor>>, qualifier interface names will violate the alias and Psalm will complain.

Either broaden the alias (e.g. class-string<MethodInterceptor>|class-string) or add a second, looser param for interfaces.

src/di/Bind.php (1)

231-236: Nice guard against undefined index

Using the null-coalescing operator prevents Undefined array key notices when a constructor-parameter name is omitted in the mapping. 👍

phpstan.neon (1)

1-3: Verify that raw is the desired errorFormat for CI consumers

errorFormat: raw gives plain-text, human-oriented output.
If any downstream CI step (e.g. GitHub Actions annotations, SARIF converters, merge-gate scripts) expects a structured format such as json, jsonlines, table, or github, those integrations will silently break.

Please double-check the tooling that parses PHPStan output and confirm it supports the raw format.

You can run the pipeline locally and inspect the produced artifact or annotate the job to be sure the change does not regress reporting. If structured output is still required, consider switching to "github" (good for PR annotations) or "table" while keeping raw for local runs via an override flag.

koriym and others added 2 commits August 3, 2025 13:24
- Remove old demo/ directory using DocBlock annotations (PHP7 era)
- Rename demo-php8/ to demo/ as the primary demo directory
- All demos now use PHP8 Attributes instead of DocBlock annotations
- Fixes demo execution issues with named binding (@nAmed annotation)
- Improves user experience with working examples

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
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: 4

🧹 Nitpick comments (5)
demo/tmp/Sorter-.php (1)

5-7: Consider error handling and namespace qualification

While this appears to be generated code, consider these improvements for robustness:

  1. The Sorter class lacks namespace qualification - ensure it's available in the global namespace
  2. No error handling for potential instantiation failures

If this is generated code, ensure the generator includes proper error handling:

-$instance = new \Sorter();
+try {
+    $instance = new \Sorter();
+} catch (\Throwable $e) {
+    throw new \RuntimeException('Failed to create Sorter instance: ' . $e->getMessage(), 0, $e);
+}
demo/finder/DbFinder.php (1)

14-16: Address unused parameter in demo method

The $db parameter is unused as flagged by static analysis. Since this is a demo file, consider either:

  1. Adding a comment explaining this is a demonstration method
  2. Adding minimal implementation to show usage
     public function setDb(DbInterface $db)
     {
+        // Demo setter method - $db would be stored in real implementation
     }
demo/02-provider-binding.php (1)

42-45: Excellent use of PHP 8 constructor property promotion.

The refactoring to use constructor property promotion is a great modernization that makes the code more concise and readable while maintaining type safety. This pattern is consistent with similar updates across the demo files.

Minor formatting suggestion: Consider moving the closing brace to line 45 for better consistency:

 public function __construct(
     public FinderInterface $finder
-){
+) {
 }
demo/tmp/MovieFinder_4221959595.php (1)

5-6: Remove unused import.

The Assisted import is not used in this generated proxy class.

-use Ray\Di\Di\Assisted;
 use Ray\Di\Di\Inject;
demo/tmp/MovieFinder_1102178874.php (1)

5-6: Remove unused import.

Same as the other proxy class, the Assisted import is not used.

-use Ray\Di\Di\Assisted;
 use Ray\Di\Di\Inject;
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 984f82b and 7b3b7a3.

⛔ Files ignored due to path filters (1)
  • demo/tmp/_compile.log is excluded by !**/*.log
📒 Files selected for processing (107)
  • .github/workflows/demo-php8.yml (3 hunks)
  • .github/workflows/update-copyright-years-in-license-file.yml (1 hunks)
  • demo/01a-linked-binding.php (1 hunks)
  • demo/01b-linked-binding-setter-injection.php (1 hunks)
  • demo/02-provider-binding.php (1 hunks)
  • demo/02a-named-by-qualifier.php (1 hunks)
  • demo/02b-named-by-named.php (1 hunks)
  • demo/03-injection-point.php (2 hunks)
  • demo/05b-constructor-binding-setter-injection.php (1 hunks)
  • demo/finder/Db.php (1 hunks)
  • demo/finder/DbFinder.php (1 hunks)
  • demo/finder/MovieFinder.php (1 hunks)
  • demo/finder/MovieLister.php (1 hunks)
  • demo/run.php (1 hunks)
  • demo/tmp/-Ray_Di_Annotation_ScriptDir.php (1 hunks)
  • demo/tmp/-dsn.php (1 hunks)
  • demo/tmp/-password.php (1 hunks)
  • demo/tmp/-username.php (1 hunks)
  • demo/tmp/03/03419867.php (1 hunks)
  • demo/tmp/04/0424916e.php (1 hunks)
  • demo/tmp/05/05cacb22.php (1 hunks)
  • demo/tmp/06/063abd7e.php (1 hunks)
  • demo/tmp/09/09a2a810.php (1 hunks)
  • demo/tmp/0a/0aac2e56.php (1 hunks)
  • demo/tmp/0f/0f4883c8.php (1 hunks)
  • demo/tmp/11/118d374f.php (1 hunks)
  • demo/tmp/16/16db7ca3.php (1 hunks)
  • demo/tmp/18/181572f3.php (1 hunks)
  • demo/tmp/1a/1a87dd68.php (1 hunks)
  • demo/tmp/1c/1c2a6b4f.php (1 hunks)
  • demo/tmp/1d/1d519d44.php (1 hunks)
  • demo/tmp/23/233715a9.php (1 hunks)
  • demo/tmp/25/25bfde8a.php (1 hunks)
  • demo/tmp/2d/2d60ca4c.php (1 hunks)
  • demo/tmp/2f/2f2190de.php (1 hunks)
  • demo/tmp/30/302b05b8.php (1 hunks)
  • demo/tmp/32/3278bb46.php (1 hunks)
  • demo/tmp/36/360f8996.php (1 hunks)
  • demo/tmp/37/37ac895e.php (1 hunks)
  • demo/tmp/37/37b68821.php (1 hunks)
  • demo/tmp/38/382f29d1.php (1 hunks)
  • demo/tmp/3c/3c01e384.php (1 hunks)
  • demo/tmp/3c/3cbc861b.php (1 hunks)
  • demo/tmp/3d/3d02f4dc.php (1 hunks)
  • demo/tmp/3e/3eab3b2e.php (1 hunks)
  • demo/tmp/42/4293e451.php (1 hunks)
  • demo/tmp/44/44a694c9.php (1 hunks)
  • demo/tmp/45/452443ba.php (1 hunks)
  • demo/tmp/46/46f82e41.php (1 hunks)
  • demo/tmp/48/48cd4d82.php (1 hunks)
  • demo/tmp/4e/4e6bce49.php (1 hunks)
  • demo/tmp/57/57826e15.php (1 hunks)
  • demo/tmp/58/5870f1b7.php (1 hunks)
  • demo/tmp/59/591f77f6.php (1 hunks)
  • demo/tmp/5c/5cb7bcd1.php (1 hunks)
  • demo/tmp/5d/5d62ed99.php (1 hunks)
  • demo/tmp/61/61b0b607.php (1 hunks)
  • demo/tmp/68/685871c9.php (1 hunks)
  • demo/tmp/6f/6f006109.php (1 hunks)
  • demo/tmp/6f/6f5236fc.php (1 hunks)
  • demo/tmp/74/74d78426.php (1 hunks)
  • demo/tmp/7d/7d4c13f6.php (1 hunks)
  • demo/tmp/7e/7e51911c.php (1 hunks)
  • demo/tmp/7e/7ebe39af.php (1 hunks)
  • demo/tmp/84/847273f5.php (1 hunks)
  • demo/tmp/87/87d912fb.php (1 hunks)
  • demo/tmp/8a/8aa50a17.php (1 hunks)
  • demo/tmp/8b/8bfbbd3c.php (1 hunks)
  • demo/tmp/8f/8fd42a7d.php (1 hunks)
  • demo/tmp/93/93710521.php (1 hunks)
  • demo/tmp/95/9517c9b8.php (1 hunks)
  • demo/tmp/96/9653b90b.php (1 hunks)
  • demo/tmp/96/96c72435.php (1 hunks)
  • demo/tmp/98/98bb2f1d.php (1 hunks)
  • demo/tmp/9e/9ef70bb3.php (1 hunks)
  • demo/tmp/9f/9fd59cba.php (1 hunks)
  • demo/tmp/DbInterface-.php (1 hunks)
  • demo/tmp/FinderInterface-.php (1 hunks)
  • demo/tmp/MovieFinder_1102178874.php (1 hunks)
  • demo/tmp/MovieFinder_4221959595.php (1 hunks)
  • demo/tmp/MovieListerInterface-.php (1 hunks)
  • demo/tmp/Ray_Di_InjectorInterface-.php (1 hunks)
  • demo/tmp/Sorter-.php (1 hunks)
  • demo/tmp/_aop.txt (1 hunks)
  • demo/tmp/a0/a0a2d23a.php (1 hunks)
  • demo/tmp/a5/a566d957.php (1 hunks)
  • demo/tmp/a6/a65d4eab.php (1 hunks)
  • demo/tmp/a9/a9a47135.php (1 hunks)
  • demo/tmp/ab/aba86a5b.php (1 hunks)
  • demo/tmp/b1/b1701da3.php (1 hunks)
  • demo/tmp/b3/b36f6c1c.php (1 hunks)
  • demo/tmp/b9/b9b64f51.php (1 hunks)
  • demo/tmp/ba/ba30bacc.php (1 hunks)
  • demo/tmp/be/be749378.php (1 hunks)
  • demo/tmp/c0/c03c4f15.php (1 hunks)
  • demo/tmp/c5/c51071a2.php (1 hunks)
  • demo/tmp/c5/c5d461fa.php (1 hunks)
  • demo/tmp/c6/c642a16c.php (1 hunks)
  • demo/tmp/c8/c898fdad.php (1 hunks)
  • demo/tmp/cd/cdb4c31a.php (1 hunks)
  • demo/tmp/cf/cf1cb878.php (1 hunks)
  • demo/tmp/d1/d1463758.php (1 hunks)
  • demo/tmp/d1/d1b6e4e5.php (1 hunks)
  • demo/tmp/d1/d1e364f0.php (1 hunks)
  • demo/tmp/d2/d238a6bc.php (1 hunks)
  • demo/tmp/d4/d49ada52.php (1 hunks)
  • demo/tmp/d9/d99048f1.php (1 hunks)
⛔ Files not processed due to max files limit (9)
  • demo/tmp/db/db5e0a2a.php
  • demo/tmp/e1/e1830981.php
  • demo/tmp/e9/e90020b6.php
  • demo/tmp/eb/eb7b5616.php
  • demo/tmp/ec/ec467936.php
  • demo/tmp/ed/ed227561.php
  • demo/tmp/ed/ed812cd3.php
  • demo/tmp/ef/ef61eae4.php
  • demo/tmp/f8/f8758f25.php
✅ Files skipped from review due to trivial changes (94)
  • demo/tmp/7e/7ebe39af.php
  • demo/finder/Db.php
  • demo/tmp/3c/3cbc861b.php
  • demo/tmp/c5/c51071a2.php
  • demo/tmp/_aop.txt
  • demo/tmp/1a/1a87dd68.php
  • demo/tmp/18/181572f3.php
  • demo/tmp/06/063abd7e.php
  • demo/tmp/05/05cacb22.php
  • demo/tmp/3d/3d02f4dc.php
  • demo/tmp/03/03419867.php
  • demo/tmp/1d/1d519d44.php
  • demo/tmp/7e/7e51911c.php
  • demo/tmp/16/16db7ca3.php
  • demo/tmp/7d/7d4c13f6.php
  • demo/tmp/36/360f8996.php
  • demo/tmp/0f/0f4883c8.php
  • demo/tmp/5d/5d62ed99.php
  • .github/workflows/update-copyright-years-in-license-file.yml
  • demo/tmp/-username.php
  • demo/tmp/-password.php
  • demo/tmp/04/0424916e.php
  • demo/tmp/58/5870f1b7.php
  • demo/run.php
  • demo/tmp/09/09a2a810.php
  • demo/tmp/59/591f77f6.php
  • demo/tmp/ab/aba86a5b.php
  • demo/tmp/c8/c898fdad.php
  • demo/tmp/4e/4e6bce49.php
  • demo/tmp/8b/8bfbbd3c.php
  • demo/tmp/74/74d78426.php
  • demo/tmp/8a/8aa50a17.php
  • demo/tmp/11/118d374f.php
  • demo/tmp/57/57826e15.php
  • demo/tmp/Ray_Di_InjectorInterface-.php
  • demo/tmp/b3/b36f6c1c.php
  • demo/tmp/b9/b9b64f51.php
  • demo/tmp/5c/5cb7bcd1.php
  • demo/tmp/a5/a566d957.php
  • demo/tmp/c0/c03c4f15.php
  • demo/tmp/45/452443ba.php
  • demo/tmp/3e/3eab3b2e.php
  • demo/tmp/87/87d912fb.php
  • demo/tmp/3c/3c01e384.php
  • demo/tmp/9e/9ef70bb3.php
  • demo/tmp/a0/a0a2d23a.php
  • demo/tmp/25/25bfde8a.php
  • demo/tmp/1c/1c2a6b4f.php
  • demo/tmp/96/9653b90b.php
  • demo/tmp/be/be749378.php
  • demo/tmp/d9/d99048f1.php
  • demo/tmp/8f/8fd42a7d.php
  • demo/tmp/-Ray_Di_Annotation_ScriptDir.php
  • demo/tmp/2f/2f2190de.php
  • demo/tmp/b1/b1701da3.php
  • demo/05b-constructor-binding-setter-injection.php
  • demo/tmp/84/847273f5.php
  • demo/tmp/9f/9fd59cba.php
  • demo/tmp/c6/c642a16c.php
  • demo/tmp/48/48cd4d82.php
  • demo/tmp/68/685871c9.php
  • demo/tmp/37/37ac895e.php
  • demo/tmp/46/46f82e41.php
  • demo/tmp/32/3278bb46.php
  • demo/tmp/c5/c5d461fa.php
  • demo/tmp/95/9517c9b8.php
  • demo/tmp/ba/ba30bacc.php
  • demo/tmp/30/302b05b8.php
  • demo/finder/MovieLister.php
  • demo/tmp/cf/cf1cb878.php
  • demo/tmp/38/382f29d1.php
  • demo/tmp/cd/cdb4c31a.php
  • demo/tmp/d1/d1463758.php
  • demo/tmp/37/37b68821.php
  • demo/tmp/6f/6f5236fc.php
  • demo/tmp/93/93710521.php
  • demo/tmp/98/98bb2f1d.php
  • demo/tmp/44/44a694c9.php
  • demo/tmp/a9/a9a47135.php
  • demo/tmp/d1/d1b6e4e5.php
  • demo/tmp/61/61b0b607.php
  • demo/tmp/d4/d49ada52.php
  • demo/tmp/0a/0aac2e56.php
  • demo/tmp/6f/6f006109.php
  • demo/tmp/23/233715a9.php
  • demo/tmp/2d/2d60ca4c.php
  • demo/tmp/d2/d238a6bc.php
  • demo/tmp/-dsn.php
  • demo/tmp/96/96c72435.php
  • demo/tmp/a6/a65d4eab.php
  • demo/tmp/42/4293e451.php
  • demo/tmp/d1/d1e364f0.php
  • demo/02b-named-by-named.php
  • demo/03-injection-point.php
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: php 8.4 has been released and is supported in github actions....
Learnt from: koriym
PR: ray-di/Ray.Di#293
File: .github/workflows/continuous-integration.yml:13-13
Timestamp: 2024-11-29T13:50:16.707Z
Learning: PHP 8.4 has been released and is supported in GitHub Actions.

Applied to files:

  • .github/workflows/demo-php8.yml
🧬 Code Graph Analysis (6)
demo/01a-linked-binding.php (3)
demo/02-provider-binding.php (2)
  • __construct (19-22)
  • __construct (42-45)
demo/03-injection-point.php (3)
  • __construct (24-27)
  • __construct (39-42)
  • __construct (47-50)
demo/finder/MovieLister.php (1)
  • __construct (9-11)
demo/02-provider-binding.php (3)
demo/02a-named-by-qualifier.php (1)
  • __construct (27-30)
demo/01a-linked-binding.php (1)
  • __construct (24-26)
demo/03-injection-point.php (3)
  • __construct (24-27)
  • __construct (39-42)
  • __construct (47-50)
demo/01b-linked-binding-setter-injection.php (2)
demo/finder/DbFinder.php (2)
  • Inject (13-16)
  • Inject (18-21)
demo/finder/MovieLister.php (1)
  • Inject (13-16)
demo/finder/MovieFinder.php (3)
demo/01b-linked-binding-setter-injection.php (1)
  • Inject (27-31)
demo/finder/DbFinder.php (2)
  • Inject (13-16)
  • Inject (18-21)
demo/finder/MovieLister.php (1)
  • Inject (13-16)
demo/02a-named-by-qualifier.php (5)
demo/02-provider-binding.php (2)
  • __construct (19-22)
  • __construct (42-45)
demo/01a-linked-binding.php (1)
  • __construct (24-26)
demo/03-injection-point.php (3)
  • __construct (24-27)
  • __construct (39-42)
  • __construct (47-50)
demo/02b-named-by-named.php (1)
  • __construct (29-31)
demo/finder/MovieLister.php (1)
  • __construct (9-11)
demo/finder/DbFinder.php (2)
demo/01b-linked-binding-setter-injection.php (1)
  • Inject (27-31)
demo/finder/MovieLister.php (1)
  • Inject (13-16)
🪛 PHPMD (2.15.0)
demo/finder/DbFinder.php

14-14: Avoid unused parameters such as '$db'. (Unused Code Rules)

(UnusedFormalParameter)

🔇 Additional comments (15)
.github/workflows/demo-php8.yml (3)

14-14: LGTM: Updated to actions/checkout@v4

Good modernization to use the latest stable version of the checkout action.


25-25: LGTM: Replaced deprecated set-output command

Correctly updated from the deprecated ::set-output command to the modern $GITHUB_OUTPUT file approach.


28-28: LGTM: Updated to actions/cache@v4

Good modernization to use the latest stable version of the cache action.

demo/01a-linked-binding.php (1)

24-26: LGTM: Excellent use of PHP 8 constructor property promotion

The refactoring from traditional property declaration and assignment to constructor property promotion is well-executed. This modernization reduces boilerplate code while maintaining the same functionality and is consistent with similar updates across other demo files.

demo/finder/DbFinder.php (1)

13-13: LGTM: Successful migration to PHP 8 attributes

Good modernization from PHPDoc @Inject to native PHP 8 #[Inject] attribute. This change is consistent with the broader codebase modernization and improves type safety integration with static analysis tools.

demo/tmp/FinderInterface-.php (1)

1-10: Generated DI container code follows expected patterns.

This appears to be generated dependency injection container code that correctly implements the expected pattern: constructor injection, setter injection, singleton flag configuration, and instance return. The structure is appropriate for compiled DI containers.

demo/tmp/MovieListerInterface-.php (1)

1-9: Generated DI container code is structurally correct.

This generated dependency injection container code follows the same correct pattern as other generated files: constructor injection, setter injection with multiple dependencies, and proper instance configuration.

demo/01b-linked-binding-setter-injection.php (2)

25-25: Excellent type safety improvement.

Adding the FinderInterface type declaration to the property enhances type safety and provides better IDE support. This aligns well with the overall modernization effort across the demo files.


27-27: Good modernization to PHP 8 attributes.

The migration from @Inject docblock annotation to #[Inject] attribute follows modern PHP 8 practices and provides better language-level support for dependency injection metadata. This change is consistent with similar updates throughout the demo codebase.

demo/finder/MovieFinder.php (2)

6-6: Necessary import for PHP 8 attribute usage.

Adding the import for Ray\Di\Di\Inject is required to support the new attribute syntax used in the method parameter.


10-10: Modern parameter-level dependency injection attribute.

The migration from @Assisted({"finder"}) docblock to #[Inject] attribute directly on the parameter follows PHP 8 best practices for dependency injection metadata. This approach provides better language-level support and is consistent with the modernization efforts across the demo codebase.

demo/tmp/MovieFinder_4221959595.php (1)

8-14: Well-structured AOP proxy class.

The proxy class correctly implements the weaving interface and delegates method calls to the intercept mechanism. The PHP 8 attribute syntax and union types are properly used.

demo/02a-named-by-qualifier.php (3)

25-25: Good addition of strict typing.

Adding explicit FinderInterface typing to the property enhances type safety and aligns with the PR's goal of improving type safety.


27-27: Excellent modernization to PHP 8 attributes.

The migration from docblock annotations to native PHP 8 attributes (#[Legacy]) is well-executed and consistent with the modernization effort across other demo files like demo/02b-named-by-named.php.


33-36: Properly structured PHP 8 attribute definition.

The Legacy qualifier is correctly defined as a PHP 8 attribute with appropriate target and qualifier traits. This modernization enhances static analysis capabilities.

koriym and others added 3 commits August 3, 2025 13:50
- Remove all generated cache and temporary files from demo/tmp/
- Keep only .gitkeep file to preserve directory structure
- Remove demo/error.log file
- Ensure clean repository state without build artifacts

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
Remove duplicate SetterMethodList and ArgumentList type aliases from Types.php,
keeping the standardized SetterMethodsList and ArgumentsList variants.
Update VisitorInterface.php to use consistent ArgumentsList type.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
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: 1

🔭 Outside diff range comments (1)
.github/workflows/demo.yml (1)

28-32: Also pin actions/cache to a SHA
Same security rationale as with actions/checkout.

-        uses: actions/cache@v4
+        uses: actions/cache@v4.0.2  # replace with the current commit SHA
🧹 Nitpick comments (1)
.github/workflows/demo.yml (1)

25-26: Quote $GITHUB_OUTPUT to avoid issues with path expansion
If the runner ever sets GITHUB_OUTPUT to a path containing spaces, the current command will fail. Quoting the variable is a one-liner fix.

-        run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
+        run: echo "dir=$(composer config cache-files-dir)" >> "$GITHUB_OUTPUT"
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 7b3b7a3 and a08a24f.

📒 Files selected for processing (3)
  • .github/workflows/demo.yml (3 hunks)
  • src/di/Types.php (1 hunks)
  • src/di/VisitorInterface.php (3 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • src/di/VisitorInterface.php
  • src/di/Types.php
🧰 Additional context used
🧠 Learnings (2)
📓 Common learnings
Learnt from: koriym
PR: ray-di/Ray.Di#297
File: composer.json:17-17
Timestamp: 2025-02-22T08:34:22.655Z
Learning: The use of "ray/aop": "^2.x-dev" in composer.json is intentional as it depends on features from the upcoming version that hasn't been released yet.
📚 Learning: php 8.4 has been released and is supported in github actions....
Learnt from: koriym
PR: ray-di/Ray.Di#293
File: .github/workflows/continuous-integration.yml:13-13
Timestamp: 2024-11-29T13:50:16.707Z
Learning: PHP 8.4 has been released and is supported in GitHub Actions.

Applied to files:

  • .github/workflows/demo.yml
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: sa / Psalm
🔇 Additional comments (1)
.github/workflows/demo.yml (1)

38-38: Verify updated demo path exists in the repository
The script path changed from demo-php8/run.php to demo/run.php. Please confirm that the file has indeed been moved/renamed in this PR to avoid a runtime “file not found” failure.

@koriym koriym force-pushed the feature/psalm-domain-types branch from 10363e7 to d016ec3 Compare August 3, 2025 10:28
@sonarqubecloud
Copy link

sonarqubecloud bot commented Aug 3, 2025

Quality Gate Failed Quality Gate failed

Failed conditions
8.7% Duplication on New Code (required ≤ 3%)

See analysis details on SonarQube Cloud

@koriym koriym merged commit f85c539 into ray-di:2.x Aug 3, 2025
27 of 29 checks passed
@koriym koriym deleted the feature/psalm-domain-types branch August 3, 2025 10:45
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.

1 participant