Skip to content

T13440 di remove instance#17027

Merged
niden merged 6 commits into
5.0.xfrom
T13440-di-remove-instance
May 15, 2026
Merged

T13440 di remove instance#17027
niden merged 6 commits into
5.0.xfrom
T13440-di-remove-instance

Conversation

@niden
Copy link
Copy Markdown
Member

@niden niden commented May 15, 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

Added Phalcon\Di\Di::hasShared(string $name): bool and Phalcon\Di\Di::removeShared(string $name): void (also declared on Phalcon\Di\DiInterface) to operate on the shared-instance cache independently of the service-definition registry. hasShared() reports whether getShared() has already materialized an instance for the given name (in contrast to has(), which reports on the definition registry). removeShared() drops the cached instance — both from Di::$sharedInstances and from the Service object's internal sharedInstance field — without removing the service definition, so the next getShared() call rebuilds a fresh instance. Use case: fork-based multi-process workers that need to discard the parent's inherited resource handle (DB connection, etc.) without re-registering the service. Both methods are alias-aware

Thanks

@niden niden requested a review from Jeckerson May 15, 2026 17:53
@niden niden self-assigned this May 15, 2026
@niden niden added new feature request Planned Feature or New Feature Request 5.0 The issues we want to solve in the 5.0 release labels May 15, 2026
@niden niden merged commit 615de0e into 5.0.x May 15, 2026
191 of 192 checks passed
@niden niden deleted the T13440-di-remove-instance branch May 15, 2026 18:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

5.0 The issues we want to solve in the 5.0 release new feature request Planned Feature or New Feature Request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants