Permalink
Browse files

feature #23484 [DI] Remove remaining deprecated features (nicolas-gre…

…kas)

This PR was merged into the 4.0-dev branch.

Discussion
----------

[DI] Remove remaining deprecated features

| Q             | A
| ------------- | ---
| Branch?       | master
| Bug fix?      | no
| New feature?  | no
| BC breaks?    | yes
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | -
| License       | MIT
| Doc PR        | -

 * removed autowiring services based on the types they implement
 * removed the `DefinitionDecorator` class, replaced by `ChildDefinition`
 * removed the `AutowireServiceResource` class and related `AutowirePass::createResourceForClass()` method
 * removed `LoggingFormatter`, `Compiler::getLoggingFormatter()` and `addLogMessage()` class and methods, use the `ContainerBuilder::log()` method instead
 * removed `FactoryReturnTypePass`
 * removed `ContainerBuilder::addClassResource()`, use the `addObjectResource()` or the `getReflectionClass()` method instead.
 * removed support for top-level anonymous services
 * removed silent behavior for unused attributes and elements
 * Removed the "framework.validation.cache" configuration option. Configure the "cache.validator" service under "framework.cache.pools" instead.

Commits
-------

4bd7b92 [DI] Remove remaining deprecated features
  • Loading branch information...
fabpot committed Jul 12, 2017
2 parents 9290042 + 4bd7b92 commit 5161ec69c4f86b98d29608d3fca92e78acddadcd
Showing with 40 additions and 944 deletions.
  1. +1 −0 src/Symfony/Bundle/FrameworkBundle/CHANGELOG.md
  2. +1 −10 src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php
  3. +8 −0 src/Symfony/Component/DependencyInjection/CHANGELOG.md
  4. +0 −2 src/Symfony/Component/DependencyInjection/ChildDefinition.php
  5. +5 −63 src/Symfony/Component/DependencyInjection/Compiler/AutowirePass.php
  6. +0 −32 src/Symfony/Component/DependencyInjection/Compiler/Compiler.php
  7. +0 −108 src/Symfony/Component/DependencyInjection/Compiler/FactoryReturnTypePass.php
  8. +0 −54 src/Symfony/Component/DependencyInjection/Compiler/LoggingFormatter.php
  9. +1 −2 src/Symfony/Component/DependencyInjection/Compiler/PassConfig.php
  10. +0 −16 src/Symfony/Component/DependencyInjection/Compiler/ResolveClassPass.php
  11. +0 −78 src/Symfony/Component/DependencyInjection/Config/AutowireServiceResource.php
  12. +0 −16 src/Symfony/Component/DependencyInjection/ContainerBuilder.php
  13. +0 −29 src/Symfony/Component/DependencyInjection/DefinitionDecorator.php
  14. +6 −20 src/Symfony/Component/DependencyInjection/Loader/XmlFileLoader.php
  15. +0 −2 src/Symfony/Component/DependencyInjection/Loader/schema/dic/services/services-1.0.xsd
  16. +0 −6 src/Symfony/Component/DependencyInjection/Tests/ChildDefinitionTest.php
  17. +10 −87 src/Symfony/Component/DependencyInjection/Tests/Compiler/AutowirePassTest.php
  18. +0 −109 src/Symfony/Component/DependencyInjection/Tests/Compiler/FactoryReturnTypePassTest.php
  19. +0 −124 src/Symfony/Component/DependencyInjection/Tests/Config/AutowireServiceResourceTest.php
  20. +0 −26 src/Symfony/Component/DependencyInjection/Tests/ContainerBuilderTest.php
  21. +0 −132 src/Symfony/Component/DependencyInjection/Tests/DefinitionDecoratorTest.php
  22. +1 −6 ...Injection/Tests/Fixtures/xml/{legacy_invalid_alias_definition.xml → invalid_alias_definition.xml}
  23. +0 −3 src/Symfony/Component/DependencyInjection/Tests/Fixtures/xml/services5.xml
  24. +6 −18 src/Symfony/Component/DependencyInjection/Tests/Loader/XmlFileLoaderTest.php
  25. +1 −1 src/Symfony/Component/HttpFoundation/Request.php
@@ -19,6 +19,7 @@ CHANGELOG
* Removed absolute template paths support in the template name parser
* Removed support of the `KERNEL_DIR` environment variable with `KernelTestCase::getKernelClass()`.
* Removed the `KernelTestCase::getPhpUnitXmlDir()` and `KernelTestCase::getPhpUnitCliConfigArgument()` methods.
* Removed the "framework.validation.cache" configuration option. Configure the "cache.validator" service under "framework.cache.pools" instead.
3.4.0
-----
@@ -1050,16 +1050,7 @@ private function registerValidationConfiguration(array $config, ContainerBuilder
}
}
if (isset($config['cache']) && $config['cache']) {
@trigger_error('The "framework.validation.cache" option is deprecated since Symfony 3.2 and will be removed in 4.0. Configure the "cache.validator" service under "framework.cache.pools" instead.', E_USER_DEPRECATED);
$container->setParameter(
'validator.mapping.cache.prefix',
'validator_'.$this->getKernelRootHash($container)
);
$validatorBuilder->addMethodCall('setMetadataCache', array(new Reference($config['cache'])));
} elseif (!$container->getParameter('kernel.debug')) {
if (!$container->getParameter('kernel.debug')) {
$validatorBuilder->addMethodCall('setMetadataCache', array(new Reference('validator.mapping.cache.symfony')));
}
}
@@ -4,13 +4,21 @@ CHANGELOG
4.0.0
-----
* removed autowiring services based on the types they implement
* added a third `$methodName` argument to the `getProxyFactoryCode()` method
of the `DumperInterface`
* removed support for autowiring types
* removed `Container::isFrozen`
* removed support for dumping an ucompiled container in `PhpDumper`
* removed support for generating a dumped `Container` without populating the method map
* removed support for case insensitive service identifiers
* removed the `DefinitionDecorator` class, replaced by `ChildDefinition`
* removed the `AutowireServiceResource` class and related `AutowirePass::createResourceForClass()` method
* removed `LoggingFormatter`, `Compiler::getLoggingFormatter()` and `addLogMessage()` class and methods, use the `ContainerBuilder::log()` method instead
* removed `FactoryReturnTypePass`
* removed `ContainerBuilder::addClassResource()`, use the `addObjectResource()` or the `getReflectionClass()` method instead.
* removed support for top-level anonymous services
* removed silent behavior for unused attributes and elements
3.4.0
-----
@@ -121,5 +121,3 @@ public function setInstanceofConditionals(array $instanceof)
throw new BadMethodCallException('A ChildDefinition cannot have instanceof conditionals set on it.');
}
}
class_alias(ChildDefinition::class, DefinitionDecorator::class);
@@ -11,7 +11,6 @@
namespace Symfony\Component\DependencyInjection\Compiler;
use Symfony\Component\DependencyInjection\Config\AutowireServiceResource;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Definition;
use Symfony\Component\DependencyInjection\Exception\AutowiringFailedException;
@@ -67,30 +66,6 @@ public function process(ContainerBuilder $container)
}
}
/**
* Creates a resource to help know if this service has changed.
*
* @param \ReflectionClass $reflectionClass
*
* @return AutowireServiceResource
*
* @deprecated since version 3.3, to be removed in 4.0. Use ContainerBuilder::getReflectionClass() instead.
*/
public static function createResourceForClass(\ReflectionClass $reflectionClass)
{
@trigger_error('The '.__METHOD__.'() method is deprecated since version 3.3 and will be removed in 4.0. Use ContainerBuilder::getReflectionClass() instead.', E_USER_DEPRECATED);
$metadata = array();
foreach ($reflectionClass->getMethods(\ReflectionMethod::IS_PUBLIC) as $reflectionMethod) {
if (!$reflectionMethod->isStatic()) {
$metadata[$reflectionMethod->name] = self::getResourceMetadataForMethod($reflectionMethod);
}
}
return new AutowireServiceResource($reflectionClass->name, $reflectionClass->getFileName(), $metadata);
}
/**
* {@inheritdoc}
*/
@@ -323,24 +298,15 @@ private function getAutowiredReference(TypedReference $reference, $deprecationMe
return $reference;
}
if (null === $this->types) {
$this->populateAvailableTypes();
if (!$reference->canBeAutoregistered()) {
return;
}
if (isset($this->types[$type])) {
$message = 'Autowiring services based on the types they implement is deprecated since Symfony 3.3 and won\'t be supported in version 4.0.';
if ($aliasSuggestion = $this->getAliasesSuggestionForType($type = $reference->getType(), $deprecationMessage)) {
$message .= ' '.$aliasSuggestion;
} else {
$message .= sprintf(' You should %s the "%s" service to "%s" instead.', isset($this->types[$this->types[$type]]) ? 'alias' : 'rename (or alias)', $this->types[$type], $type);
}
@trigger_error($message, E_USER_DEPRECATED);
return new TypedReference($this->types[$type], $type);
if (null === $this->types) {
$this->populateAvailableTypes();
}
if (!$reference->canBeAutoregistered() || isset($this->types[$type]) || isset($this->ambiguousServiceTypes[$type])) {
if (isset($this->types[$type]) || isset($this->ambiguousServiceTypes[$type])) {
return;
}
@@ -499,30 +465,6 @@ private function createTypeAlternatives(TypedReference $reference)
return sprintf(' You should maybe alias this %s to %s.', class_exists($type, false) ? 'class' : 'interface', $message);
}
/**
* @deprecated since version 3.3, to be removed in 4.0.
*/
private static function getResourceMetadataForMethod(\ReflectionMethod $method)
{
$methodArgumentsMetadata = array();
foreach ($method->getParameters() as $parameter) {
try {
$class = $parameter->getClass();
} catch (\ReflectionException $e) {
// type-hint is against a non-existent class
$class = false;
}
$methodArgumentsMetadata[] = array(
'class' => $class,
'isOptional' => $parameter->isOptional(),
'defaultValue' => ($parameter->isOptional() && !$parameter->isVariadic()) ? $parameter->getDefaultValue() : null,
);
}
return $methodArgumentsMetadata;
}
private function getAliasesSuggestionForType($type, $extraContext = null)
{
$aliases = array();
@@ -52,24 +52,6 @@ public function getServiceReferenceGraph()
return $this->serviceReferenceGraph;
}
/**
* Returns the logging formatter which can be used by compilation passes.
*
* @return LoggingFormatter
*
* @deprecated since version 3.3, to be removed in 4.0. Use the ContainerBuilder::log() method instead.
*/
public function getLoggingFormatter()
{
if (null === $this->loggingFormatter) {
@trigger_error(sprintf('The %s() method is deprecated since version 3.3 and will be removed in 4.0. Use the ContainerBuilder::log() method instead.', __METHOD__), E_USER_DEPRECATED);
$this->loggingFormatter = new LoggingFormatter();
}
return $this->loggingFormatter;
}
/**
* Adds a pass to the PassConfig.
*
@@ -82,20 +64,6 @@ public function addPass(CompilerPassInterface $pass, $type = PassConfig::TYPE_BE
$this->passConfig->addPass($pass, $type, $priority);
}
/**
* Adds a log message.
*
* @param string $string The log message
*
* @deprecated since version 3.3, to be removed in 4.0. Use the ContainerBuilder::log() method instead.
*/
public function addLogMessage($string)
{
@trigger_error(sprintf('The %s() method is deprecated since version 3.3 and will be removed in 4.0. Use the ContainerBuilder::log() method instead.', __METHOD__), E_USER_DEPRECATED);
$this->log[] = $string;
}
/**
* @final
*/
@@ -1,108 +0,0 @@
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\DependencyInjection\Compiler;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Definition;
use Symfony\Component\DependencyInjection\Reference;
/**
* @author Guilhem N. <egetick@gmail.com>
*
* @deprecated since version 3.3, to be removed in 4.0.
*/
class FactoryReturnTypePass implements CompilerPassInterface
{
private $resolveClassPass;
public function __construct(ResolveClassPass $resolveClassPass = null)
{
if (null === $resolveClassPass) {
@trigger_error('The '.__CLASS__.' class is deprecated since version 3.3 and will be removed in 4.0.', E_USER_DEPRECATED);
}
$this->resolveClassPass = $resolveClassPass;
}
/**
* {@inheritdoc}
*/
public function process(ContainerBuilder $container)
{
$resolveClassPassChanges = null !== $this->resolveClassPass ? $this->resolveClassPass->getChanges() : array();
foreach ($container->getDefinitions() as $id => $definition) {
$this->updateDefinition($container, $id, $definition, $resolveClassPassChanges);
}
}
private function updateDefinition(ContainerBuilder $container, $id, Definition $definition, array $resolveClassPassChanges, array $previous = array())
{
// circular reference
$lcId = strtolower($id);
if (isset($previous[$lcId])) {
return;
}
$factory = $definition->getFactory();
if (null === $factory || (!isset($resolveClassPassChanges[$lcId]) && null !== $definition->getClass())) {
return;
}
$class = null;
if (is_string($factory)) {
try {
$m = new \ReflectionFunction($factory);
if (false !== $m->getFileName() && file_exists($m->getFileName())) {
$container->fileExists($m->getFileName());
}
} catch (\ReflectionException $e) {
return;
}
} else {
if ($factory[0] instanceof Reference) {
$previous[$lcId] = true;
$factoryDefinition = $container->findDefinition((string) $factory[0]);
$this->updateDefinition($container, $factory[0], $factoryDefinition, $resolveClassPassChanges, $previous);
$class = $factoryDefinition->getClass();
} else {
$class = $factory[0];
}
if (!$m = $container->getReflectionClass($class)) {
return;
}
try {
$m = $m->getMethod($factory[1]);
} catch (\ReflectionException $e) {
return;
}
}
$returnType = $m->getReturnType();
if (null !== $returnType && !$returnType->isBuiltin()) {
$returnType = $returnType->getName();
if (null !== $class) {
$declaringClass = $m->getDeclaringClass()->getName();
if ('self' === strtolower($returnType)) {
$returnType = $declaringClass;
} elseif ('parent' === strtolower($returnType)) {
$returnType = get_parent_class($declaringClass) ?: null;
}
}
if (null !== $returnType && (!isset($resolveClassPassChanges[$lcId]) || $returnType !== $resolveClassPassChanges[$lcId])) {
@trigger_error(sprintf('Relying on its factory\'s return-type to define the class of service "%s" is deprecated since Symfony 3.3 and won\'t work in 4.0. Set the "class" attribute to "%s" on the service definition instead.', $id, $returnType), E_USER_DEPRECATED);
}
$definition->setClass($returnType);
}
}
}
@@ -1,54 +0,0 @@
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\DependencyInjection\Compiler;
@trigger_error('The '.__NAMESPACE__.'\LoggingFormatter class is deprecated since version 3.3 and will be removed in 4.0. Use the ContainerBuilder::log() method instead.', E_USER_DEPRECATED);
/**
* Used to format logging messages during the compilation.
*
* @author Johannes M. Schmitt <schmittjoh@gmail.com>
*
* @deprecated since version 3.3, to be removed in 4.0. Use the ContainerBuilder::log() method instead.
*/
class LoggingFormatter
{
public function formatRemoveService(CompilerPassInterface $pass, $id, $reason)
{
return $this->format($pass, sprintf('Removed service "%s"; reason: %s.', $id, $reason));
}
public function formatInlineService(CompilerPassInterface $pass, $id, $target)
{
return $this->format($pass, sprintf('Inlined service "%s" to "%s".', $id, $target));
}
public function formatUpdateReference(CompilerPassInterface $pass, $serviceId, $oldDestId, $newDestId)
{
return $this->format($pass, sprintf('Changed reference of service "%s" previously pointing to "%s" to "%s".', $serviceId, $oldDestId, $newDestId));
}
public function formatResolveInheritance(CompilerPassInterface $pass, $childId, $parentId)
{
return $this->format($pass, sprintf('Resolving inheritance for "%s" (parent: %s).', $childId, $parentId));
}
public function formatUnusedAutowiringPatterns(CompilerPassInterface $pass, $id, array $patterns)
{
return $this->format($pass, sprintf('Autowiring\'s patterns "%s" for service "%s" don\'t match any method.', implode('", "', $patterns), $id));
}
public function format(CompilerPassInterface $pass, $message)
{
return sprintf('%s: %s', get_class($pass), $message);
}
}
@@ -41,7 +41,7 @@ public function __construct()
$this->beforeOptimizationPasses = array(
100 => array(
$resolveClassPass = new ResolveClassPass(),
new ResolveClassPass(),
new ResolveInstanceofConditionalsPass(),
),
);
@@ -53,7 +53,6 @@ public function __construct()
new DecoratorServicePass(),
new ResolveParameterPlaceHoldersPass(false),
new ResolveFactoryClassPass(),
new FactoryReturnTypePass($resolveClassPass),
new CheckDefinitionValidityPass(),
new RegisterServiceSubscribersPass(),
new ResolveNamedArgumentsPass(),
Oops, something went wrong.

0 comments on commit 5161ec6

Please sign in to comment.