-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[DI] Improve some deprecation messages #24423
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
Conversation
@@ -282,7 +282,7 @@ public function get($id, $invalidBehavior = self::EXCEPTION_ON_INVALID_REFERENCE | ||
// calling $this->normalizeId($id) unless necessary. | ||
for ($i = 2;;) { | ||
if (isset($this->privates[$id])) { | ||
@trigger_error(sprintf('Requesting the "%s" private service is deprecated since Symfony 3.2 and won\'t be supported anymore in Symfony 4.0.', $id), E_USER_DEPRECATED); | ||
@trigger_error(sprintf('The "%s" service is private, getting it from the container is deprecated since Symfony 3.2 and will fail in 4.0. You should either make the service public, or preferably eg implement ServiceSubscriberInterface or use any other dependency injection method instead of using the container at all.', $id), E_USER_DEPRECATED); |
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 is the most critical one, as it will be triggered quite often in 3.4 where services are now private by default.
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.
Minor reword proposal:
Before:
The "%s" service is private, getting it from the container is deprecated since
Symfony 3.2 and will fail in 4.0. You should either make the service public, or
preferably eg implement ServiceSubscriberInterface or use any other dependency
injection method instead of using the container at all.
After:
The "%s" service is private, getting it from the container is deprecated since
Symfony 3.2 and will fail in 4.0. You should either make the service public or
stop getting services directly from the container (instead, implement
ServiceSubscriberInterface or use other dependency injection methods).
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 would not mention ServiceSubscriberInterface
here as this is just one example amongst many other ones.
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.
updated, better?
9f18291
to
2cc8592
Compare
@@ -282,7 +282,7 @@ public function get($id, $invalidBehavior = self::EXCEPTION_ON_INVALID_REFERENCE | ||
// calling $this->normalizeId($id) unless necessary. | ||
for ($i = 2;;) { | ||
if (isset($this->privates[$id])) { | ||
@trigger_error(sprintf('Requesting the "%s" private service is deprecated since Symfony 3.2 and won\'t be supported anymore in Symfony 4.0.', $id), E_USER_DEPRECATED); | ||
@trigger_error(sprintf('The "%s" service is private, getting it from the container is deprecated since Symfony 3.2 and will fail in 4.0. You should either make the service public or stop getting services directly from the container and use any dependency injection methods instead.', $id), E_USER_DEPRECATED); |
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's "any method", not "any methods" because only one of the methods should be used, not several at once.
2cc8592
to
3e80760
Compare
Thank you @nicolas-grekas. |
This PR was merged into the 3.3 branch. Discussion ---------- [DI] Improve some deprecation messages | Q | A | ------------- | --- | Branch? | 3.3 | Bug fix? | no | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | - | License | MIT | Doc PR | - To improve DX. Commits ------- 3e80760 [DI] Improve some deprecation messages
To improve DX.