feat: guard Deployer singleton before Host construction#4189
Open
m1rm wants to merge 1 commit intodeployphp:masterfrom
Open
feat: guard Deployer singleton before Host construction#4189m1rm wants to merge 1 commit intodeployphp:masterfrom
m1rm wants to merge 1 commit intodeployphp:masterfrom
Conversation
Author
|
Additional info/motivation of this PR: I came across the issue when implementing setDefaultSelector as thin typed wrapper for set('default_selector', ...) (which will be a subsequent PR). |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Bug fix #…?Background
Host::__constructusedDeployer::get()to decide whether to inherit the global recipe config. With a typed, uninitialized static$instance, PHP 8+ throws when get() reads the property before new Deployer(...) has run. That can break HostTest (and any code path that builds a Host without a bootstrapped singleton).Solution
Deployer:
?self (default null).get()throws a clear RuntimeException if not initialized.hasInstance()so callers can check without touching an uninitialized property.resetInstance() (@internal) for tests that need a clean singleton between cases.Host:
Deployer::hasInstance()before callingget()when wiring the parent Configuration.HostTest:
tearDown()callsDeployer::resetInstance()so tests stay isolated.Deployer\Deployerfor tearDown.Behavior / compatibility
Deployer::get()with no instance: still invalid; error is now RuntimeException instead of the engine error on an uninitialized typed static.