Skip to content

[DI] Remove remaining deprecated features #23484

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

Merged
merged 1 commit into from
Jul 12, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/Symfony/Bundle/FrameworkBundle/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
-----
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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')));
}
}
Expand Down
8 changes: 8 additions & 0 deletions src/Symfony/Component/DependencyInjection/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
-----
Expand Down
2 changes: 0 additions & 2 deletions src/Symfony/Component/DependencyInjection/ChildDefinition.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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}
*/
Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -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();
Expand Down
32 changes: 0 additions & 32 deletions src/Symfony/Component/DependencyInjection/Compiler/Compiler.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand All @@ -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
*/
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public function __construct()

$this->beforeOptimizationPasses = array(
100 => array(
$resolveClassPass = new ResolveClassPass(),
new ResolveClassPass(),
new ResolveInstanceofConditionalsPass(),
),
);
Expand All @@ -53,7 +53,6 @@ public function __construct()
new DecoratorServicePass(),
new ResolveParameterPlaceHoldersPass(false),
new ResolveFactoryClassPass(),
new FactoryReturnTypePass($resolveClassPass),
new CheckDefinitionValidityPass(),
new RegisterServiceSubscribersPass(),
new ResolveNamedArgumentsPass(),
Expand Down
Loading