Skip to content

Enhance DX and performance with introspection, warmup, and improved error messages#18

Merged
Chemaclass merged 9 commits into
mainfrom
feat/dx-improvements
Nov 8, 2025
Merged

Enhance DX and performance with introspection, warmup, and improved error messages#18
Chemaclass merged 9 commits into
mainfrom
feat/dx-improvements

Conversation

@Chemaclass
Copy link
Copy Markdown
Member

This PR introduces several developer experience and performance improvements to the container library.

Features

Developer Experience

  • Enhanced Error Messages: All exceptions now include actionable suggestions to help developers quickly resolve issues

    • Missing type hints show example code
    • Unresolvable scalars suggest adding default values
    • Frozen/protected services explain why and how to fix
  • Circular Dependency Detection: Automatically detect and report circular dependencies with the full dependency chain (e.g., ClassA -> ClassB -> ClassA)

  • Container Introspection: New methods to inspect container state for debugging

    • getRegisteredServices() - List all registered service IDs
    • isFactory(string $id) - Check if a service is marked as factory
    • isFrozen(string $id) - Check if a service has been accessed (frozen)
    • getBindings() - View all configured bindings

Performance

  • Constructor Method Caching: Cache ReflectionMethod instances to avoid redundant reflection operations
  • Optimized Callable Key Generation: Replace expensive md5(var_export()) with spl_object_id() for better performance
  • WarmUp Method: Pre-resolve dependencies during bootstrap for faster runtime
    $container->warmUp([UserService::class, OrderService::class]);

@Chemaclass Chemaclass self-assigned this Nov 8, 2025
@Chemaclass Chemaclass added the enhancement New feature or request label Nov 8, 2025
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/Container/DependencyResolver.php
@Chemaclass Chemaclass merged commit 917e6f2 into main Nov 8, 2025
11 of 12 checks passed
@Chemaclass Chemaclass deleted the feat/dx-improvements branch November 8, 2025 13:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants