Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 18 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,24 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [[v0.2.0](https://github.com/The-FireHub-Project/Container/compare/v0.1.0...v0.2.0)] – 2026-10-21

### Added
* Contextual bindings by @dieselxxx in https://github.com/The-FireHub-Project/Container/pull/2
* Union i intersection dependency resolution by @dieselxxx in https://github.com/The-FireHub-Project/Container/pull/2
* Tagged services by @dieselxxx in https://github.com/The-FireHub-Project/Container/pull/2
* Tagged constructor injection by @dieselxxx in https://github.com/The-FireHub-Project/Container/pull/2
* Collection injection by @dieselxxx in https://github.com/The-FireHub-Project/Container/pull/2
* Circular dependency detection by @dieselxxx in https://github.com/The-FireHub-Project/Container/pull/2
* Alias deduplication by @dieselxxx in https://github.com/The-FireHub-Project/Container/pull/2by @dieselxxx in https://github.com/The-FireHub-Project/Container/pull/2

## [v0.1.0] – 2026-10-21

### Added
* Implement initial functionality by @dieselxxx in https://github.com/The-FireHub-Project/Container/pull/1
* Service registration i resolution by @dieselxxx in https://github.com/The-FireHub-Project/Container/pull/1
* Singleton, scoped, transient lifetimes by @dieselxxx in https://github.com/The-FireHub-Project/Container/pull/1
* Constructor autowiring by @dieselxxx in https://github.com/The-FireHub-Project/Container/pull/1
* Parameter binding by @dieselxxx in https://github.com/The-FireHub-Project/Container/pull/1
* Service aliases i factories by @dieselxxx in https://github.com/The-FireHub-Project/Container/pull/1
* Scope management by @dieselxxx in https://github.com/The-FireHub-Project/Container/pull/1
* Container freezing by @dieselxxx in https://github.com/The-FireHub-Project/Container/pull/1
88 changes: 53 additions & 35 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
/></a>
<a href="#">
<img
src="https://img.shields.io/badge/Version-0.1.0-d50000?style=flat&labelColor=30363d&logo=data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAzMzMuNjUxIDM4Ny4wOSI+CiAgICA8dGl0bGU+RmlyZWh1YiBJY29uPC90aXRsZT4KICAgIDxzdHlsZT4KICAgICAgICAuY29sb3Ige2ZpbGw6ICNkNTAwMDA7fQogICAgPC9zdHlsZT4KICAgIDxnPgogICAgICAgIDxwYXRoIGNsYXNzPSJjb2xvciIgZD0iTTI2Ny4xMDYsMjYyLjU2MWMxMC41LTE3LjYzMSwxOS42My0zNi45MzEsMjAuMTItNTcuNDUxYzAuNDktMjAuNTItOS42LTQyLjQxOS0yOC40Ni01MC41MmM1LjcxLDkuNjcsMTAuMjUsMjAuNjIsOS4yOCwzMS44MWMtMC45NywxMS4xOS04Ljg2LDIyLjM3LTIwLDI0Yy0xMC40OSwxLjUyOS0yMC43Ny01Ljg1MS0yNS41MS0xNS4zNGMtNC43NC05LjQ5MS00LjYyLTIwLjU2MS00LTMxLjE1QzIyNC4zOTYsNTYuMTcsMTQyLjA0Niw1Ljk0LDEyNy4yODYsMGMwLDAsMTEuNDksMTIuMzksMTMuODgsMzAuNTNjMS45LDE0LjQ0LDAuMTcsMjkuMjItMy4zNCw0My4yNGMtMTAuODgsNDMuMzUtMzYuODYsNzcuODItNTguNTksMTE2Yy0xNC41OCwyNS41OC0yNCw1NC4wNS0yMy4zMiw4My42OWMwLjc2LDM0LDE2LDY3LjksNDIuNzMsODguODdjMTMuMDUsMTAuMjI5LDI4LjMyLDE3LjY1LDQzLjg0LDIzLjI5Yy0yLjE5LTIuNjItNC44NS01LjYyLTctOC42MDFjLTE4LjY4LTI1LjkzOS0zMi4yNi01MS41LTMzLjE3LTg0LjEwOWMtMC43Ny0yOC4yMyw3LjQtN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I0Ljc3NywxNzMuMTM2LDIyLjQzeiIvPgogICAgICAgIDxwYXRoIGNsYXNzPSJjb2xvciIgZD0iTTQ3LjA0NiwyNzMuNjA5di0wLjA4QzAuNDM1LDIwNy4zNTQsMTYuMjk2LDExNS45MjMsODIuNDcxLDY5LjMxM2MxNS4yNTQtMTAuNzQ0LDMyLjQyLTE4LjQ3Nyw1MC41NzUtMjIuNzgzYzAuMjEyLTQuOTYyLDAuMDA1LTkuOTMzLTAuNjItMTQuODZjLTAuMjUzLTEuODc1LTAuNjI0LTMuNzMxLTEuMTEtNS41NkM0MS4yOTksNDUuNzM4LTE1Ljc2MywxMzQuNjIzLDMuODY1LDIyNC42NGM3LjI4LDMzLjM5LDI0LjY0LDYzLjczOCw0OS43MzEsODYuOTRDNDkuNTU5LDI5OS4zMTQsNDcuMzUyLDI4Ni41Miw0Ny4wNDYsMjczLjYwOXoiLz4KICAgIDwvZz4KPC9zdmc+"
src="https://img.shields.io/badge/Version-0.2.0-d50000?style=flat&labelColor=30363d&logo=data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAzMzMuNjUxIDM4Ny4wOSI+CiAgICA8dGl0bGU+RmlyZWh1YiBJY29uPC90aXRsZT4KICAgIDxzdHlsZT4KICAgICAgICAuY29sb3Ige2ZpbGw6ICNkNTAwMDA7fQogICAgPC9zdHlsZT4KICAgIDxnPgogICAgICAgIDxwYXRoIGNsYXNzPSJjb2xvciIgZD0iTTI2Ny4xMDYsMjYyLjU2MWMxMC41LTE3LjYzMSwxOS42My0zNi45MzEsMjAuMTItNTcuNDUxYzAuNDktMjAuNTItOS42LTQyLjQxOS0yOC40Ni01MC41MmM1LjcxLDkuNjcsMTAuMjUsMjAuNjIsOS4yOCwzMS44MWMtMC45NywxMS4xOS04Ljg2LDIyLjM3LTIwLDI0Yy0xMC40OSwxLjUyOS0yMC43Ny01Ljg1MS0yNS41MS0xNS4zN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uMTA2LDI2Mi41NjF6Ii8+CiAgICAgICAgPHBhdGggY2xhc3M9ImNvbG9yIiBkPSJNMTczLjEzNiwyMi40M2M1LjA3OCw0Ljk5MSw5Ljg3MiwxMC4yNjIsMTQuMzYsMTUuNzljMS43NzMsMi4xODcsMy40ODMsNC40LDUuMTMsNi42NGM3OS42NzQsMTQuMjQ0LDEzMi43MTYsOTAuMzgsMTE4LjQ3MiwxNzAuMDU0Yy02Ljk0NywzOC44NTctMjkuMjc2LDczLjI3LTYxLjkzMiw5NS40NDZjLTEuNDMsMy0yLjc3LDYtNCw5Yy0yLjUyOCw2LjM3Ny00LjMzLDEzLjAxOS01LjM3LDE5LjhjODIuODQ5LTQwLjMyOSwxMTcuMzE4LTE0MC4xODUsNzYuOTg5LTIyMy4wMzNDMjg5Ljg0OSw2MC43OSwyMzQuNjM1LDI0Ljc3NywxNzMuMTM2LDIyLjQzeiIvPgogICAgICAgIDxwYXRoIGNsYXNzPSJjb2xvciIgZD0iTTQ3LjA0NiwyNzMuNjA5di0wLjA4QzAuNDM1LDIwNy4zNTQsMTYuMjk2LDExNS45MjMsODIuNDcxLDY5LjMxM2MxNS4yNTQtMTAuNzQ0LDMyLjQyLTE4LjQ3Nyw1MC41NzUtMjIuNzgzYzAuMjEyLTQuOTYyLDAuMDA1LTkuOTMzLTAuNjItMTQuODZjLTAuMjUzLTEuODc1LTAuNjI0LTMuNzMxLTEuMTEtNS41NkM0MS4yOTksNDUuNzM4LTE1Ljc2MywxMzQuNjIzLDMuODY1LDIyNC42NGM3LjI4LDMzLjM5LDI0LjY0LDYzLjczOCw0OS43MzEsODYuOTRDNDkuNTU5LDI5OS4zMTQsNDcuMzUyLDI4Ni41Miw0Ny4wNDYsMjczLjYwOXoiLz4KICAgIDwvZz4KPC9zdmc+"
alt="version"
/></a>
<a href="./LICENSE">
Expand All @@ -22,10 +22,6 @@
/></a>
</h1>

[![PHPStan](https://github.com/The-FireHub-Project/Container/actions/workflows/PHPStan.yml/badge.svg?branch=develop)](https://github.com/The-FireHub-Project/Container/actions/workflows/PHPStan.yml)
[![PHPUnit](https://github.com/The-FireHub-Project/Container/actions/workflows/PHPUnit.yml/badge.svg?branch=develop)](https://github.com/The-FireHub-Project/Container/actions/workflows/PHPUnit.yml)
[![Codecov](https://codecov.io/gh/The-FireHub-Project/Container/branch/develop/graph/badge.svg?token=XW2YEONF51)](https://app.codecov.io/gh/The-FireHub-Project/Container/tree/develop)

<p>
<a href="https://github.com/The-FireHub-Project/Container">
<img
Expand Down Expand Up @@ -77,47 +73,69 @@ This repository serves as a foundational runtime component for FireHub applicati

---

## <img src="https://raw.githubusercontent.com/The-FireHub-Project/the-firehub-project.github.io/master/resources/graphics/icons/firehub.svg" width="15" alt="FireHub Icon"> Development Branch
## <img src="https://raw.githubusercontent.com/The-FireHub-Project/the-firehub-project.github.io/master/resources/graphics/icons/firehub.svg" width="15" alt="FireHub Icon"> Repository Purpose

FireHub Container is the dependency injection and service resolution component of the FireHub ecosystem.

Built on the contracts provided by FireHub Core, it supplies the mechanisms required to register, construct, resolve, and manage application services.

The purpose of this repository is to centralize dependency management while preserving separation of concerns between service definitions, runtime implementation, and application execution.

⚠️ **This is the `develop` branch**
The Container architecture is designed to support:

- Unstable
- APIs may change without notice
- Not intended for production use
- Service registration and dependency resolution
- Interface-to-implementation bindings
- Instance, factory, and class-based service definitions
- Singleton and transient service lifetimes
- Dependency graph resolution and circular dependency detection
- Immutable service registrations after container construction
- Future support for autowiring and execution-scoped services

## <img src="https://raw.githubusercontent.com/The-FireHub-Project/the-firehub-project.github.io/master/resources/graphics/icons/firehub.svg" width="15" alt="FireHub Icon"> Branch Purpose
FireHub Container follows the architectural principles of The FireHub Project by separating responsibilities between contracts, dependency management, and application lifecycle orchestration.

The `develop` branch is the **primary integration branch** for all ongoing development.
The Container does not control application execution or kernel lifecycle transitions. Instead, it provides dependency management services that can be integrated into applications through the appropriate bootstrap and composition mechanisms.

It serves as the staging area where:
- Feature branches are merged
- Bug fixes are integrated
- Experimental work is stabilized
- Code is prepared for upcoming releases
## <img src="https://raw.githubusercontent.com/The-FireHub-Project/the-firehub-project.github.io/master/resources/graphics/icons/firehub.svg" width="15" alt="FireHub Icon"> Security

All **release branches** are created **from `develop`**.
For security reporting and guidelines, please refer to our [SECURITY.md](https://github.com/The-FireHub-Project/.github/blob/master/.github/SECURITY.md) file.

## Stability Guarantee
## <img src="https://raw.githubusercontent.com/The-FireHub-Project/the-firehub-project.github.io/master/resources/graphics/icons/firehub.svg" width="15" alt="FireHub Icon"> Community

❌ No backward compatibility guarantee
❌ APIs may change without notice
❌ Behavior may be incomplete or inconsistent
❌ Breaking changes are expected
![GitHub watchers](https://img.shields.io/github/watchers/The-FireHub-Project/Container?style=social)
![GitHub Repo stars](https://img.shields.io/github/stars/The-FireHub-Project/Container?style=social)
![GitHub forks](https://img.shields.io/github/forks/The-FireHub-Project/Container?style=social)

This branch is intended **only for contributors and advanced testers**.
- Be sure to review the [Code of Conduct](https://github.com/The-FireHub-Project/.github/blob/master/.github/CODE_OF_CONDUCT.md).
- Read a [Contributing](https://github.com/The-FireHub-Project/.github/blob/master/.github/CONTRIBUTING.md) file to see how you can contribute to this project.
- Read our [Security policy](https://github.com/The-FireHub-Project/.github/blob/master/.github/SECURITY.md) file to see how you can report a vulnerability.
- Review the project [Governance model](https://github.com/The-FireHub-Project/.github/blob/master/.github/GOVERNANCE.md), including roles, decision-making, RFC process, and releases.

## <img src="https://raw.githubusercontent.com/The-FireHub-Project/the-firehub-project.github.io/master/resources/graphics/icons/firehub.svg" width="15" alt="FireHub Icon"> Composer Usage (Not Recommended)
## <img src="https://raw.githubusercontent.com/The-FireHub-Project/the-firehub-project.github.io/master/resources/graphics/icons/firehub.svg" width="15" alt="FireHub Icon"> Support

<p>
<a href="https://github.com/The-FireHub-Project/Container/issues?q=is%3Aissue%20state%3Aopen">
<img
src="https://img.shields.io/github/issues/The-FireHub-Project/Container?style=flat&logo=github&logoColor=959da5&label=in%20progress%20issues&labelColor=31373e"
alt="GitHub in-progress issues"
/></a>
<a href="https://github.com/The-FireHub-Project/Container/issues?q=is%3Aissue">
<img
src="https://img.shields.io/github/issues-search?query=repo%3AThe-FireHub-Project%Foundaton&style=flat&logo=github&logoColor=959da5&label=total%20issues&labelColor=31373e"
alt="GitHub total issues"
/></a>
<a href="https://github.com/The-FireHub-Project/Container/issues?q=is%3Apr%20is%3Aopen">
<img
src="https://img.shields.io/github/issues-pr/The-FireHub-Project/Container?style=flat&logo=github&logoColor=959da5&labelColor=31373e"
alt="GitHub opened pull requests"
/></a>
</p>

For internal testing only:
For help with FireHub products, please refer to the following resources:

```json
{
"require": {
"the-firehub-project/container": "dev-develop"
}
}
```
⚠️ Never use dev-develop in production.
- **General questions & discussions**: [GitHub Discussions](https://github.com/orgs/The-FireHub-Project/discussions)
- **Bug reports & issues**: [Support](https://github.com/The-FireHub-Project/Container/issues)
- **Documentation & guides**: [FireHub Docs](https://the-firehub-project.github.io)
- **Commercial support** (Pro/Enterprise): contact your account manager

## <img src="https://raw.githubusercontent.com/The-FireHub-Project/the-firehub-project.github.io/master/resources/graphics/icons/firehub.svg" width="15" alt="FireHub Icon"> Authors and Contributors

Expand All @@ -134,4 +152,4 @@ Architecture guidelines, design principles, and ecosystem documentation are avai

This software is licensed under the Apache-2.0 License.

For more details, read the full license [here](./LICENSE).
For more details, read the full license [here](./LICENSE).
62 changes: 62 additions & 0 deletions src/Attribute/InjectAll.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
<?php declare(strict_types = 1);

/**
* This file is part of the FireHub Project ecosystem
*
* @author Danijel Galić <danijel.galic@outlook.com>
* @copyright 2026-present The FireHub Project - All rights reserved
* @license https://opensource.org/license/Apache-2-0 Apache License, Version 2.0
*
* @php-version >=8.2
* @package Container
*/

namespace FireHub\Container\Attribute;

use Attribute;

/**
* ### Marks a constructor parameter for collection injection
*
* Automatically injects all explicitly registered services compatible with the specified type.
*
* Services are resolved in registration order while preserving their configured lifetimes and the active resolution
* context.
*
* If no matching services are registered, an empty array is injected.
*
* Only non-nullable array constructor parameters are supported.
*
* <code>
* use FireHub\Container\Attribute\InjectAll;
*
* final readonly class LoggerManager {
*
* public function __construct(
* #[InjectAll(LoggerInterface::class)]
* public array $loggers
* ) {}
*
* }
* </code>
*
* @since 1.0.0
*/
#[Attribute(Attribute::TARGET_PARAMETER)]
final readonly class InjectAll {

/**
* ### Constructor
* @since 1.0.0
*
* @param class-string $type <p>
* Required service type.
* </p>
*
* @return void
*/
public function __construct(
public string $type
) {}

}
69 changes: 69 additions & 0 deletions src/Attribute/Tagged.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
<?php declare(strict_types = 1);

/**
* This file is part of the FireHub Project ecosystem
*
* @author Danijel Galić <danijel.galic@outlook.com>
* @copyright 2026-present The FireHub Project - All rights reserved
* @license https://opensource.org/license/Apache-2-0 Apache License, Version 2.0
*
* @php-version >=8.2
* @package Container
*/

namespace FireHub\Container\Attribute;

use Attribute;

/**
* ### Marks a constructor parameter for tagged service injection
*
* Declares that a constructor parameter should receive all services associated with the specified tag.
*
* Tagged services are resolved in their registration order and retain their configured singleton, scoped, or
* transient lifetimes.
*
* The attribute is intended for array-typed constructor parameters.
*
* <code>
* use FireHub\Container\Attribute\Tagged;
*
* final readonly class MiddlewarePipeline {
*
* public function __construct (
* #[Tagged('http.middleware')]
* public array $middlewares
* ) {}
*
* }
* </code>
*
* @since 1.0.0
*/
#[Attribute(Attribute::TARGET_PARAMETER)]
final readonly class Tagged {

/**
* ### Constructor
*
* <code>
* use FireHub\Container\Attribute\Tagged;
*
* $attribute = new Tagged('http.middleware');
*
* $attribute->tag; // 'http.middleware'
* </code>
*
* @since 1.0.0
*
* @param non-empty-string $tag <p>
* Name of the service tag to resolve.
* </p>
*
* @return void
*/
public function __construct (
public string $tag
) {}

}
Loading
Loading