Skip to content

Conversation

@giuscris
Copy link
Member

This pull request updates the dependency injection container to implement the PSR-11 standard (psr/container) and improves error handling by introducing custom exception classes that conform to PSR-11 interfaces. The changes ensure better interoperability with other libraries and provide more precise exception types for container-related errors.

PSR-11 Compliance:

  • The Container class now implements Psr\Container\ContainerInterface, making it PSR-11 compliant and compatible with other libraries expecting a standard container interface.

Improved Exception Handling:

  • Introduced custom exceptions: ContainerException and ServiceNotFoundException, both implementing the corresponding PSR-11 interfaces for better error granularity and standardization. [1] [2]
  • Updated the container logic to throw these new exceptions instead of generic LogicException for various error cases, such as aliasing to self, missing services, and invalid variadic arguments. [1] [2] [3] [4]
  • Modified ServiceResolutionException to implement ContainerExceptionInterface, aligning it with PSR-11 requirements.

Dependency Updates:

  • Added psr/container as a required dependency in composer.json to support PSR-11 compliance.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR implements PSR-11 compliance for the dependency injection container by making the Container class implement Psr\Container\ContainerInterface and introducing standardized exception handling through custom exception classes.

Key Changes:

  • Added PSR-11 compliance by implementing ContainerInterface
  • Introduced ContainerException and ServiceNotFoundException implementing PSR-11 exception interfaces
  • Updated exception handling throughout the container to use appropriate PSR-11 compliant exceptions
  • Added psr/container dependency to composer.json

Reviewed changes

Copilot reviewed 5 out of 6 changed files in this pull request and generated no comments.

Show a summary per file
File Description
formwork/src/Services/Container.php Implements ContainerInterface and replaces generic LogicException with PSR-11 compliant exceptions (ContainerException for validation errors, ServiceNotFoundException for missing services)
formwork/src/Services/Exceptions/ServiceResolutionException.php Updated to implement ContainerExceptionInterface for PSR-11 compliance
formwork/src/Services/Exceptions/ServiceNotFoundException.php New exception class implementing NotFoundExceptionInterface for missing service scenarios
formwork/src/Services/Exceptions/ContainerException.php New exception class implementing ContainerExceptionInterface for general container errors
composer.json Added psr/container ^2.0 as a required dependency
composer.lock Updated with psr/container package metadata, moved from dev to production dependencies

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@giuscris giuscris marked this pull request as ready for review December 31, 2025 18:31
@giuscris giuscris merged commit e432995 into 2.x Dec 31, 2025
7 checks passed
@giuscris giuscris deleted the feature/psr-11 branch December 31, 2025 18:33
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