Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added support for deprecating aliases (runtime+dumper)
- Loading branch information
Renan
committed
Jan 24, 2019
1 parent
0eb071b
commit 6711e59
Showing
10 changed files
with
220 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
...y/Component/DependencyInjection/Tests/Fixtures/containers/container_alias_deprecation.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<?php | ||
|
||
use Symfony\Component\DependencyInjection\ContainerBuilder; | ||
|
||
$container = new ContainerBuilder(); | ||
|
||
$container | ||
->register('foo', 'stdClass') | ||
->setPublic(true) | ||
; | ||
|
||
$container | ||
->setAlias('alias_for_foo_deprecated', 'foo') | ||
->setDeprecated(true) | ||
->setPublic(true); | ||
|
||
$container | ||
->setAlias('alias_for_foo_non_deprecated', 'foo') | ||
->setPublic(true); | ||
|
||
return $container; |
73 changes: 73 additions & 0 deletions
73
src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/container_alias_deprecation.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
<?php | ||
|
||
use Symfony\Component\DependencyInjection\Argument\RewindableGenerator; | ||
use Symfony\Component\DependencyInjection\ContainerInterface; | ||
use Symfony\Component\DependencyInjection\Container; | ||
use Symfony\Component\DependencyInjection\Exception\InvalidArgumentException; | ||
use Symfony\Component\DependencyInjection\Exception\LogicException; | ||
use Symfony\Component\DependencyInjection\Exception\RuntimeException; | ||
use Symfony\Component\DependencyInjection\ParameterBag\FrozenParameterBag; | ||
|
||
/** | ||
* This class has been auto-generated | ||
* by the Symfony Dependency Injection Component. | ||
* | ||
* @final since Symfony 3.3 | ||
*/ | ||
class Symfony_DI_PhpDumper_Test_Aliases_Deprecation extends Container | ||
{ | ||
private $parameters; | ||
private $targetDirs = []; | ||
|
||
public function __construct() | ||
{ | ||
$this->services = $this->privates = []; | ||
$this->methodMap = [ | ||
'foo' => 'getFooService', | ||
'alias_for_foo_deprecated' => 'getAliasForFooDeprecatedService', | ||
]; | ||
$this->aliases = [ | ||
'alias_for_foo_non_deprecated' => 'foo', | ||
]; | ||
} | ||
|
||
public function compile() | ||
{ | ||
throw new LogicException('You cannot compile a dumped container that was already compiled.'); | ||
} | ||
|
||
public function isCompiled() | ||
{ | ||
return true; | ||
} | ||
|
||
public function getRemovedIds() | ||
{ | ||
return [ | ||
'Psr\\Container\\ContainerInterface' => true, | ||
'Symfony\\Component\\DependencyInjection\\ContainerInterface' => true, | ||
]; | ||
} | ||
|
||
/** | ||
* Gets the public 'foo' shared service. | ||
* | ||
* @return \stdClass | ||
*/ | ||
protected function getFooService() | ||
{ | ||
return $this->services['foo'] = new \stdClass(); | ||
} | ||
|
||
/** | ||
* Gets the public 'alias_for_foo_deprecated' alias. | ||
* | ||
* @return object The "foo" service. | ||
*/ | ||
protected function getAliasForFooDeprecatedService() | ||
{ | ||
@trigger_error('The "alias_for_foo_deprecated" service alias is deprecated. You should stop using it, as it will soon be removed.', E_USER_DEPRECATED); | ||
|
||
return $this->get('foo'); | ||
} | ||
} |