{"action":"opened","issue":{"url":"https://api.github.com/repos/symfony/symfony-docs/issues/6959","repository_url":"https://api.github.com/repos/symfony/symfony-docs","labels_url":"https://api.github.com/repos/symfony/symfony-docs/issues/6959/labels{/name}","comments_url":"https://api.github.com/repos/symfony/symfony-docs/issues/6959/comments","events_url":"https://api.github.com/repos/symfony/symfony-docs/issues/6959/events","html_url":"https://github.com/symfony/symfony-docs/issues/6959","id":176239019,"number":6959,"title":"Public service, very vague","user":{"login":"appeltaert","id":8100221,"avatar_url":"https://avatars.githubusercontent.com/u/8100221?v=3","gravatar_id":"","url":"https://api.github.com/users/appeltaert","html_url":"https://github.com/appeltaert","followers_url":"https://api.github.com/users/appeltaert/followers","following_url":"https://api.github.com/users/appeltaert/following{/other_user}","gists_url":"https://api.github.com/users/appeltaert/gists{/gist_id}","starred_url":"https://api.github.com/users/appeltaert/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/appeltaert/subscriptions","organizations_url":"https://api.github.com/users/appeltaert/orgs","repos_url":"https://api.github.com/users/appeltaert/repos","events_url":"https://api.github.com/users/appeltaert/events{/privacy}","received_events_url":"https://api.github.com/users/appeltaert/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2016-09-11T11:18:04Z","updated_at":"2016-09-11T11:18:04Z","closed_at":null,"body":"http://symfony.com/doc/current/service_container/alias_private.html\r\n\r\n> What makes private services special is that, if they are only injected once, they are converted from services to inlined instantiations (e.g. new PrivateThing()). This increases the container's performance.\r\n\r\nIt seems that a private service is only inline instantiated if there is only one service depending on it which is not shared(`shared:false`), couldn't find any other use case..\r\n\r\n> Now that the service is private, you should not fetch the service directly from the container:\r\nThis may or may not work, depending on if the service could be inlined. Simply said: A service can be marked as private if you do not want to access it directly from your code\r\n\r\nWhether the private service is inline instantiated or not, or even used or not, i couldn't find any use-case where i could get it manually from the container.\r\n\r\n> Services are by default public, but it's considered a good practice to mark as much services private as possible.\r\n\r\nFor something that's considered a good practise, it would be good to have a little insight on what's going on. You would expect a private service to simply not be callable from the container, let alone \"it may or may not\". It doesn't seem to have any use besides the small performance boost, and the vague behaviour you get in return doens't seem worth it.\r\n\r\nIt feels like poor design and not good practise at all, but maybe someone can improve the docs. I looked into the file that has the conditions, but they contain no inline docs with some sort of clarification.\r\n\r\nhttps://github.com/symfony/dependency-injection/blob/master/Compiler/InlineServiceDefinitionsPass.php#L108\r\n\r\nThis would feel like a more solid feature doing only what it suggests, namely the only possibility for it to be injected into another service, no side-effects or performance boosts"}}
{"actor":{"display_login":"appeltaert"}}