minor #24423 [DI] Improve some deprecation messages (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
-------
3e8076023d
[DI] Improve some deprecation messages
This commit is contained in:
commit
417ec3a49c
@ -199,16 +199,16 @@ class Container implements ResettableContainerInterface
|
||||
|
||||
if (isset($this->privates[$id])) {
|
||||
if (null === $service) {
|
||||
@trigger_error(sprintf('Unsetting 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, unsetting it is deprecated since Symfony 3.2 and will fail in 4.0.', $id), E_USER_DEPRECATED);
|
||||
unset($this->privates[$id]);
|
||||
} else {
|
||||
@trigger_error(sprintf('Setting 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, replacing it is deprecated since Symfony 3.2 and will fail in 4.0.', $id), E_USER_DEPRECATED);
|
||||
}
|
||||
} elseif ($wasSet && isset($this->methodMap[$id])) {
|
||||
if (null === $service) {
|
||||
@trigger_error(sprintf('Unsetting the "%s" service after it\'s been initialized is deprecated since Symfony 3.3 and won\'t be supported anymore in Symfony 4.0.', $id), E_USER_DEPRECATED);
|
||||
@trigger_error(sprintf('The "%s" service is already initialized, unsetting it is deprecated since Symfony 3.3 and will fail in 4.0.', $id), E_USER_DEPRECATED);
|
||||
} else {
|
||||
@trigger_error(sprintf('Setting the "%s" service after it\'s been initialized is deprecated since Symfony 3.3 and won\'t be supported anymore in Symfony 4.0.', $id), E_USER_DEPRECATED);
|
||||
@trigger_error(sprintf('The "%s" service is already initialized, replacing it is deprecated since Symfony 3.3 and will fail in 4.0.', $id), E_USER_DEPRECATED);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -224,7 +224,7 @@ class Container implements ResettableContainerInterface
|
||||
{
|
||||
for ($i = 2;;) {
|
||||
if (isset($this->privates[$id])) {
|
||||
@trigger_error(sprintf('Checking for the existence of 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, checking for its existence is deprecated since Symfony 3.2 and will fail in 4.0.', $id), E_USER_DEPRECATED);
|
||||
}
|
||||
if (isset($this->aliases[$id])) {
|
||||
$id = $this->aliases[$id];
|
||||
@ -282,7 +282,7 @@ class Container implements ResettableContainerInterface
|
||||
// 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 dependency injection instead.', $id), E_USER_DEPRECATED);
|
||||
}
|
||||
if (isset($this->aliases[$id])) {
|
||||
$id = $this->aliases[$id];
|
||||
|
@ -186,7 +186,7 @@ class ContainerTest extends TestCase
|
||||
|
||||
/**
|
||||
* @group legacy
|
||||
* @expectedDeprecation Unsetting the "bar" service after it's been initialized is deprecated since Symfony 3.3 and won't be supported anymore in Symfony 4.0.
|
||||
* @expectedDeprecation The "bar" service is already initialized, unsetting it is deprecated since Symfony 3.3 and will fail in 4.0.
|
||||
*/
|
||||
public function testSetWithNullOnInitializedPredefinedService()
|
||||
{
|
||||
@ -452,7 +452,7 @@ class ContainerTest extends TestCase
|
||||
|
||||
/**
|
||||
* @group legacy
|
||||
* @expectedDeprecation Unsetting the "internal" private service is deprecated since Symfony 3.2 and won't be supported anymore in Symfony 4.0.
|
||||
* @expectedDeprecation The "internal" service is private, unsetting it is deprecated since Symfony 3.2 and will fail in 4.0.
|
||||
*/
|
||||
public function testUnsetInternalPrivateServiceIsDeprecated()
|
||||
{
|
||||
@ -462,7 +462,7 @@ class ContainerTest extends TestCase
|
||||
|
||||
/**
|
||||
* @group legacy
|
||||
* @expectedDeprecation Setting the "internal" private service is deprecated since Symfony 3.2 and won't be supported anymore in Symfony 4.0.
|
||||
* @expectedDeprecation The "internal" service is private, replacing it is deprecated since Symfony 3.2 and will fail in 4.0.
|
||||
*/
|
||||
public function testChangeInternalPrivateServiceIsDeprecated()
|
||||
{
|
||||
@ -473,7 +473,7 @@ class ContainerTest extends TestCase
|
||||
|
||||
/**
|
||||
* @group legacy
|
||||
* @expectedDeprecation Checking for the existence of the "internal" private service is deprecated since Symfony 3.2 and won't be supported anymore in Symfony 4.0.
|
||||
* @expectedDeprecation The "internal" service is private, checking for its existence is deprecated since Symfony 3.2 and will fail in 4.0.
|
||||
*/
|
||||
public function testCheckExistenceOfAnInternalPrivateServiceIsDeprecated()
|
||||
{
|
||||
@ -484,7 +484,7 @@ class ContainerTest extends TestCase
|
||||
|
||||
/**
|
||||
* @group legacy
|
||||
* @expectedDeprecation Requesting the "internal" private service is deprecated since Symfony 3.2 and won't be supported anymore in Symfony 4.0.
|
||||
* @expectedDeprecation The "internal" 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 dependency injection instead.
|
||||
*/
|
||||
public function testRequestAnInternalSharedPrivateServiceIsDeprecated()
|
||||
{
|
||||
@ -495,7 +495,7 @@ class ContainerTest extends TestCase
|
||||
|
||||
/**
|
||||
* @group legacy
|
||||
* @expectedDeprecation Setting the "bar" service after it's been initialized is deprecated since Symfony 3.3 and won't be supported anymore in Symfony 4.0.
|
||||
* @expectedDeprecation The "bar" service is already initialized, replacing it is deprecated since Symfony 3.3 and will fail in 4.0.
|
||||
*/
|
||||
public function testReplacingAPreDefinedServiceIsDeprecated()
|
||||
{
|
||||
|
@ -269,7 +269,7 @@ class PhpDumperTest extends TestCase
|
||||
|
||||
/**
|
||||
* @group legacy
|
||||
* @expectedDeprecation Setting the "bar" service after it's been initialized is deprecated since Symfony 3.3 and won't be supported anymore in Symfony 4.0.
|
||||
* @expectedDeprecation The "bar" service is already initialized, replacing it is deprecated since Symfony 3.3 and will fail in 4.0.
|
||||
*/
|
||||
public function testOverrideServiceWhenUsingADumpedContainer()
|
||||
{
|
||||
@ -286,7 +286,7 @@ class PhpDumperTest extends TestCase
|
||||
|
||||
/**
|
||||
* @group legacy
|
||||
* @expectedDeprecation Setting the "bar" service after it's been initialized is deprecated since Symfony 3.3 and won't be supported anymore in Symfony 4.0.
|
||||
* @expectedDeprecation The "bar" service is already initialized, replacing it is deprecated since Symfony 3.3 and will fail in 4.0.
|
||||
*/
|
||||
public function testOverrideServiceWhenUsingADumpedContainerAndServiceIsUsedFromAnotherOne()
|
||||
{
|
||||
|
Reference in New Issue
Block a user