Skip to content

T736 di bucket#738

Merged
niden merged 19 commits intophalcon:v6.0.xfrom
niden-code:T736-di-bucket
Apr 19, 2026
Merged

T736 di bucket#738
niden merged 19 commits intophalcon:v6.0.xfrom
niden-code:T736-di-bucket

Conversation

@niden
Copy link
Copy Markdown
Member

@niden niden commented Apr 18, 2026

Hello!

In raising this pull request, I confirm the following:

  • I have read and understood the Contributing Guidelines
  • I have checked that another pull request for this purpose does not exist
  • I wrote some tests for this PR
  • I have updated the relevant CHANGELOG
  • I have created a PR for the documentation about this change

A new, clean-slate dependency injection container has been implemented as Phalcon\Container, replacing the existing Phalcon\Container namespace.

Architecture

Container implements Service\Collection (aligned with service-interop) which itself extends IocContainer (from ioc-interop/interface). ContainerFactory implements IocContainerFactory. Resolution interfaces are aligned with resolver-interop.

Key Features

  • get() returns a shared (singleton) instance; new() always creates a fresh instance
  • Autowiring via PHP Reflection - toggleable, transitive (dependencies of dependencies resolved automatically), runs once per definition and is frozen on first resolution
  • Service tags — label services, retrieve all tagged instances via getByTag()
  • Interface binding via bind() — maps an interface to a concrete implementation
  • extend() — decorate an existing service after registration
  • Scalar parameters — setParameter() stores env vars, config values, and other scalars separately from object services; Lazy\Env and Lazy\CsEnv for environment variable resolution
  • Lazy value system — 12 lazy classes (Get, NewInstance, Call, GetCall, NewCall, StaticCall, FunctionCall, ArrayValues, CallableGet, CallableNew, Env, CsEnv) plus LazyFactory static factory for ergonomic construction
  • Freeze pattern — ServiceDefinition is mutable during registration; frozen on first resolution (reflection cached, setters locked, definition becomes serializable for future warm-boot caching)
  • Service providers — Service\Provider interface; Provider\Web and Provider\Cli pre-wire all standard Phalcon framework services with interface bindings where available and string aliases for backward compatibility

Interop Alignment

Standard Status
ioc-interop Implemented (IocContainer, IocContainerFactory, IocThrowable)
service-interop Copied into Service\ namespace (not yet on Packagist)
resolver-interop Copied into Resolver\ namespace (requires PHP 8.4)

Structure

src/Container/
Container.php / ContainerFactory.php
Definition/ - ServiceDefinition, DefinitionType, ServiceLifetime, Processor/
Exception/ - ContainerThrowable, Invalid, NotFound
Provider/ - Web, Cli
Resolver/ - Resolver + interop interfaces + Lazy/
Service/ - Collection, Definition, Lifetime, Provider, Throwable

@niden niden requested a review from Jeckerson April 18, 2026 23:44
@niden niden self-assigned this Apr 18, 2026
@niden niden added new feature request Planned Feature or New Feature Request 6.0.0 6.0.0 release labels Apr 18, 2026
@codecov
Copy link
Copy Markdown

codecov bot commented Apr 19, 2026

Codecov Report

❌ Patch coverage is 99.83333% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 77.38%. Comparing base (1487bb2) to head (38eed7f).
⚠️ Report is 19 commits behind head on v6.0.x.

Additional details and impacted files
@@            Coverage Diff             @@
##           v6.0.x     #738      +/-   ##
==========================================
+ Coverage   75.82%   77.38%   +1.56%     
==========================================
  Files         500      505       +5     
  Lines       28709    28939     +230     
==========================================
+ Hits        21768    22394     +626     
+ Misses       6941     6545     -396     
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@niden niden merged commit 108bed2 into phalcon:v6.0.x Apr 19, 2026
13 of 14 checks passed
@niden niden deleted the T736-di-bucket branch April 19, 2026 13:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

6.0.0 6.0.0 release new feature request Planned Feature or New Feature Request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant