-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[DI] Mark service_container a private service #22806
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -39,7 +39,7 @@ public function process(ContainerBuilder $container) | |
{ | ||
foreach ($container->getDefinitions() as $id => $definition) { | ||
// synthetic service is public | ||
if ($definition->isSynthetic() && !$definition->isPublic()) { | ||
if ($definition->isSynthetic() && !$definition->isPublic() && 'service_container' !== $id) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can be moved before isSynthetic() as this it's faster (micro optimization). |
||
throw new RuntimeException(sprintf('A synthetic service ("%s") must be public.', $id)); | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -64,6 +64,10 @@ protected function processValue($value, $isRoot = false) | |
*/ | ||
private function isInlineableDefinition($id, Definition $definition, ServiceReferenceGraph $graph) | ||
{ | ||
if ('service_container' === $id) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same.. probably a bugfix? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. service_container was public, so this wouldn't change anything as a bug fix |
||
return false; | ||
} | ||
|
||
if (!$definition->isShared()) { | ||
return true; | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,6 +30,9 @@ public function __construct() | |
$this->methodMap = array( | ||
'bar' => 'getBarService', | ||
); | ||
$this->privates = array( | ||
'service_container' => true, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. should we actually dump it in this array ? It receives a special treatment when getting it anyway There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could be left out indeed, but im not sure if we care :) as it requires adding code; which defeats this PR :) |
||
); | ||
|
||
$this->aliases = array(); | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
having to add such check is because there is no way to opt-in in the new behavior of
getServiceIds
, and then we have to skip the private services to avoid deprecations later. This causes issues (see also #22866 which faces the same issue).Can we implement a hidden argument allowing to opt-in for the new behavior instead, to get only public ids ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure.. wouldnt this be over complex? <4.0
getServiceIds
includes privates, using those withget()
etc. is non-crashing, in >=4.0 those id's are exlcuded as they are crashing. I could live with that.For the SF codebase i think explicitly skippping is just fine =/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it is non-crashing, but it triggers deprecation warnings everywhere. And there is no way to avoid this unless you know the ids of all private services (and then, you could as well know the ids of all public services and avoid calling
getServiceIds
)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the hidden arg makes sense, it could be added to #22866