-
-
Notifications
You must be signed in to change notification settings - Fork 9.7k
[DI] Exclude private services from alternatives #19679
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 |
---|---|---|
|
@@ -269,10 +269,10 @@ public function get($id, $invalidBehavior = self::EXCEPTION_ON_INVALID_REFERENCE | |
} | ||
|
||
$alternatives = array(); | ||
foreach ($this->services as $key => $associatedService) { | ||
$lev = levenshtein($id, $key); | ||
if ($lev <= strlen($id) / 3 || false !== strpos($key, $id)) { | ||
$alternatives[] = $key; | ||
foreach ($this->getServiceIds(false) as $knownId) { | ||
$lev = levenshtein($id, $knownId); | ||
if ($lev <= strlen($id) / 3 || false !== strpos($knownId, $id)) { | ||
$alternatives[] = $knownId; | ||
} | ||
} | ||
|
||
|
@@ -336,11 +336,22 @@ public function reset() | |
* | ||
* @return array An array of all defined service ids | ||
*/ | ||
public function getServiceIds() | ||
public function getServiceIds(/*$includePrivates = true*/) | ||
{ | ||
$includePrivates = true; | ||
if (func_num_args() === 1) { | ||
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. Nobody calls this with an argument, which means nobody will see the deprecation notice. |
||
$includePrivates = (bool) func_get_arg(0); | ||
if ($includePrivates) { | ||
@trigger_error(sprintf('Including private services in the list of service id\'s is deprecated since Symfony 3.2 and won\'t be supported anymore in Symfony 4.0.', $id), E_USER_DEPRECATED); | ||
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. @ogizanagi something like this? edit: it makes no real sense though.. we can just deprecate privates in 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. Sorry, I don't understand your concerns 😕 ? You can't just deprecate privates in 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. Got it. |
||
} | ||
} | ||
$ids = array(); | ||
foreach (get_class_methods($this) as $method) { | ||
if (preg_match('/^get(.+)Service$/', $method, $match)) { | ||
$id = self::underscore($match[1]); | ||
if (!$includePrivates && isset($this->privates[$id])) { | ||
continue; | ||
} | ||
$ids[] = self::underscore($match[1]); | ||
} | ||
} | ||
|
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.
this change is unrelated and should be discussed in #19685 (thus no need for the patch here)
Uh oh!
There was an error while loading. Please reload this page.
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.
Agree. Im reverting it so we check for privates here again.
Deprecating privates from
getServiceIds
is a new PR i guess which cleans this up.. it needs to be taken care of.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.
@nicolas-grekas if #19685 and a new PR, fixing excluding privates from
getServiceIds
, are done.... this becomes a non-issue. Shall we close it?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 this PR should be closed yes.