Skip to content
Permalink
Browse files

Leverage trigger_deprecation() from symfony/deprecation-contracts

  • Loading branch information
nicolas-grekas committed Feb 1, 2020
1 parent 55e2c5b commit 3e35d8e9e3d4357e8ea26b718529d8eb78749e49
Showing with 81 additions and 71 deletions.
  1. +1 −1 composer.json
  2. +2 −2 src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php
  3. +1 −1 src/Symfony/Bundle/FrameworkBundle/Kernel/MicroKernelTrait.php
  4. +1 −1 src/Symfony/Component/Config/Definition/ArrayNode.php
  5. +1 −0 src/Symfony/Component/Config/composer.json
  6. +1 −1 src/Symfony/Component/DependencyInjection/Compiler/ResolveReferencesToAliasesPass.php
  7. +4 −4 src/Symfony/Component/DependencyInjection/ContainerBuilder.php
  8. +2 −2 src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php
  9. +1 −1 src/Symfony/Component/DependencyInjection/Tests/Fixtures/DeprecatedClass.php
  10. +1 −1 src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/container_alias_deprecation.php
  11. +2 −2 src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services9_as_files.txt
  12. +2 −2 src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services9_compiled.php
  13. +2 −2 src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services9_inlined_factories.txt
  14. +2 −2 src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_errored_definition.php
  15. +1 −0 src/Symfony/Component/DependencyInjection/composer.json
  16. +1 −1 src/Symfony/Component/Dotenv/Dotenv.php
  17. +2 −1 src/Symfony/Component/Dotenv/composer.json
  18. +1 −1 src/Symfony/Component/EventDispatcher/LegacyEventDispatcherProxy.php
  19. +1 −0 src/Symfony/Component/EventDispatcher/composer.json
  20. +1 −1 src/Symfony/Component/Form/Extension/Core/Type/FormType.php
  21. +1 −1 src/Symfony/Component/Form/Form.php
  22. +1 −0 src/Symfony/Component/Form/composer.json
  23. +1 −1 src/Symfony/Component/HttpFoundation/JsonResponse.php
  24. +1 −1 src/Symfony/Component/HttpFoundation/RedirectResponse.php
  25. +1 −1 src/Symfony/Component/HttpFoundation/Response.php
  26. +1 −1 src/Symfony/Component/HttpFoundation/StreamedResponse.php
  27. +1 −0 src/Symfony/Component/HttpFoundation/composer.json
  28. +4 −4 src/Symfony/Component/Messenger/Bridge/Amqp/Tests/Transport/ConnectionTest.php
  29. +3 −3 src/Symfony/Component/Messenger/Bridge/Amqp/Transport/Connection.php
  30. +1 −1 src/Symfony/Component/Messenger/Bridge/Redis/Tests/Transport/ConnectionTest.php
  31. +1 −1 src/Symfony/Component/Messenger/Bridge/Redis/Transport/Connection.php
  32. +1 −1 src/Symfony/Component/Messenger/Transport/AmqpExt/AmqpFactory.php
  33. +1 −1 src/Symfony/Component/Messenger/Transport/AmqpExt/AmqpReceivedStamp.php
  34. +1 −1 src/Symfony/Component/Messenger/Transport/AmqpExt/AmqpReceiver.php
  35. +1 −1 src/Symfony/Component/Messenger/Transport/AmqpExt/AmqpSender.php
  36. +1 −1 src/Symfony/Component/Messenger/Transport/AmqpExt/AmqpStamp.php
  37. +1 −1 src/Symfony/Component/Messenger/Transport/AmqpExt/AmqpTransport.php
  38. +1 −1 src/Symfony/Component/Messenger/Transport/AmqpExt/AmqpTransportFactory.php
  39. +1 −1 src/Symfony/Component/Messenger/Transport/AmqpExt/Connection.php
  40. +1 −1 src/Symfony/Component/Messenger/Transport/Doctrine/Connection.php
  41. +1 −1 src/Symfony/Component/Messenger/Transport/Doctrine/DoctrineReceivedStamp.php
  42. +1 −1 src/Symfony/Component/Messenger/Transport/Doctrine/DoctrineReceiver.php
  43. +1 −1 src/Symfony/Component/Messenger/Transport/Doctrine/DoctrineSender.php
  44. +1 −1 src/Symfony/Component/Messenger/Transport/Doctrine/DoctrineTransport.php
  45. +1 −1 src/Symfony/Component/Messenger/Transport/Doctrine/DoctrineTransportFactory.php
  46. +1 −1 src/Symfony/Component/Messenger/Transport/RedisExt/Connection.php
  47. +1 −1 src/Symfony/Component/Messenger/Transport/RedisExt/RedisReceivedStamp.php
  48. +1 −1 src/Symfony/Component/Messenger/Transport/RedisExt/RedisReceiver.php
  49. +1 −1 src/Symfony/Component/Messenger/Transport/RedisExt/RedisSender.php
  50. +1 −1 src/Symfony/Component/Messenger/Transport/RedisExt/RedisTransport.php
  51. +1 −1 src/Symfony/Component/Messenger/Transport/RedisExt/RedisTransportFactory.php
  52. +1 −0 src/Symfony/Component/Messenger/composer.json
  53. +2 −2 src/Symfony/Component/OptionsResolver/OptionsResolver.php
  54. +2 −1 src/Symfony/Component/OptionsResolver/composer.json
  55. +2 −2 src/Symfony/Component/Routing/RouteCollection.php
  56. +1 −1 src/Symfony/Component/Routing/RouteCollectionBuilder.php
  57. +2 −1 src/Symfony/Component/Routing/composer.json
  58. +2 −2 src/Symfony/Component/Yaml/Inline.php
  59. +2 −2 src/Symfony/Component/Yaml/Tests/InlineTest.php
  60. +1 −0 src/Symfony/Component/Yaml/composer.json
@@ -26,7 +26,7 @@
"psr/event-dispatcher": "^1.0",
"psr/link": "^1.0",
"psr/log": "~1.0",
"symfony/contracts": "^2",
"symfony/contracts": "^2.1",
"symfony/polyfill-ctype": "~1.8",
"symfony/polyfill-intl-grapheme": "~1.0",
"symfony/polyfill-intl-icu": "~1.0",
@@ -214,7 +214,7 @@ public function load(array $configs, ContainerBuilder $container)
}

if (!\extension_loaded('intl') && !\defined('PHPUNIT_COMPOSER_INSTALL')) {
@trigger_error('Please install the "intl" PHP extension for best performance.', E_USER_DEPRECATED);
trigger_deprecation('', '', 'Please install the "intl" PHP extension for best performance.');
}
}

@@ -857,7 +857,7 @@ private function registerRouterConfiguration(array $config, ContainerBuilder $co
$loader->load('routing.xml');

if (null === $config['utf8']) {
@trigger_error('Not setting the "framework.router.utf8" configuration option is deprecated since Symfony 5.1, it will default to "true" in Symfony 6.0.', E_USER_DEPRECATED);
trigger_deprecation('symfony/framework-bundle', '5.1', 'Not setting the "framework.router.utf8" configuration option is deprecated, it will default to "true" in version 6.0.');
}

if ($config['utf8']) {
@@ -174,7 +174,7 @@ public function loadRoutes(LoaderInterface $loader)
}
}

@trigger_error(sprintf('Using type "%s" for argument 1 of method "%s:configureRoutes()" is deprecated since Symfony 5.1, use "%s" instead.', RouteCollectionBuilder::class, self::class, RoutingConfigurator::class), E_USER_DEPRECATED);
trigger_deprecation('symfony/framework-bundle', '5.1', 'Using type "%s" for argument 1 of method "%s:configureRoutes()" is deprecated, use "%s" instead.', RouteCollectionBuilder::class, self::class, RoutingConfigurator::class);

$routes = new RouteCollectionBuilder($loader);
$this->configureRoutes($routes);
@@ -227,7 +227,7 @@ protected function finalizeValue($value)
}

if ($child->isDeprecated()) {
@trigger_error($child->getDeprecationMessage($name, $this->getPath()), E_USER_DEPRECATED);
trigger_deprecation('', '', $child->getDeprecationMessage($name, $this->getPath()));
}

try {
@@ -17,6 +17,7 @@
],
"require": {
"php": "^7.2.5",
"symfony/deprecation-contracts": "^2.1",
"symfony/filesystem": "^4.4|^5.0",
"symfony/polyfill-ctype": "~1.8"
},
@@ -62,7 +62,7 @@ private function getDefinitionId(string $id, ContainerBuilder $container): strin
$alias = $container->getAlias($id);

if ($alias->isDeprecated()) {
@trigger_error(sprintf('%s. It is being referenced by the "%s" %s.', rtrim($alias->getDeprecationMessage($id), '. '), $this->currentId, $container->hasDefinition($this->currentId) ? 'service' : 'alias'), E_USER_DEPRECATED);
trigger_deprecation('', '', '%s. It is being referenced by the "%s" %s.', rtrim($alias->getDeprecationMessage($id), '. '), $this->currentId, $container->hasDefinition($this->currentId) ? 'service' : 'alias');
}

$seen = [];
@@ -568,7 +568,7 @@ private function doGet(string $id, int $invalidBehavior = ContainerInterface::EX
$alias = $this->aliasDefinitions[$id];

if ($alias->isDeprecated()) {
@trigger_error($alias->getDeprecationMessage($id), E_USER_DEPRECATED);
trigger_deprecation('', '', $alias->getDeprecationMessage($id));
}

return $this->doGet((string) $alias, $invalidBehavior, $inlineServices, $isConstructorArgument);
@@ -1037,7 +1037,7 @@ private function createService(Definition $definition, array &$inlineServices, b
}

if ($definition->isDeprecated()) {
@trigger_error($definition->getDeprecationMessage($id), E_USER_DEPRECATED);
trigger_deprecation('', '', $definition->getDeprecationMessage($id));
}

if ($tryProxy && $definition->isLazy() && !$tryProxy = !($proxy = $this->proxyInstantiator) || $proxy instanceof RealServiceInstantiator) {
@@ -1080,7 +1080,7 @@ private function createService(Definition $definition, array &$inlineServices, b
$r = new \ReflectionClass($factory[0]);

if (0 < strpos($r->getDocComment(), "\n * @deprecated ")) {
@trigger_error(sprintf('The "%s" service relies on the deprecated "%s" factory class. It should either be deprecated or its factory upgraded.', $id, $r->name), E_USER_DEPRECATED);
trigger_deprecation('', '', 'The "%s" service relies on the deprecated "%s" factory class. It should either be deprecated or its factory upgraded.', $id, $r->name);
}
}
} else {
@@ -1089,7 +1089,7 @@ private function createService(Definition $definition, array &$inlineServices, b
$service = null === $r->getConstructor() ? $r->newInstance() : $r->newInstanceArgs($arguments);

if (!$definition->isDeprecated() && 0 < strpos($r->getDocComment(), "\n * @deprecated ")) {
@trigger_error(sprintf('The "%s" service relies on the deprecated "%s" class. It should either be deprecated or its implementation upgraded.', $id, $r->name), E_USER_DEPRECATED);
trigger_deprecation('', '', 'The "%s" service relies on the deprecated "%s" class. It should either be deprecated or its implementation upgraded.', $id, $r->name);
}
}

@@ -803,7 +803,7 @@ protected function {$methodName}($lazyInitialization)
$this->inlinedDefinitions = $this->getDefinitionsFromArguments([$definition], null, $this->serviceCalls);

if ($definition->isDeprecated()) {
$code .= sprintf(" @trigger_error(%s, E_USER_DEPRECATED);\n\n", $this->export($definition->getDeprecationMessage($id)));
$code .= sprintf(" trigger_deprecation('', '', %s);\n\n", $this->export($definition->getDeprecationMessage($id)));
}

if ($this->getProxyDumper()->isProxyCandidate($definition)) {
@@ -1312,7 +1312,7 @@ private function addDeprecatedAliases(): string
*/
protected function {$methodNameAlias}()
{
@trigger_error($messageExported, E_USER_DEPRECATED);
trigger_deprecation('', '', $messageExported);
return \$this->get($idExported);
}
@@ -11,7 +11,7 @@

namespace Symfony\Component\DependencyInjection\Tests\Fixtures;

@trigger_error('deprecated', E_USER_DEPRECATED);
trigger_deprecation('', '', 'deprecated');

class DeprecatedClass
{
@@ -66,7 +66,7 @@ protected function getFooService()
*/
protected function getAliasForFooDeprecatedService()
{
@trigger_error('The "alias_for_foo_deprecated" service alias is deprecated. You should stop using it, as it will be removed in the future.', E_USER_DEPRECATED);
trigger_deprecation('', '', 'The "alias_for_foo_deprecated" service alias is deprecated. You should stop using it, as it will be removed in the future.');

return $this->get('foo');
}
@@ -124,7 +124,7 @@ use Symfony\Component\DependencyInjection\Exception\RuntimeException;
// This file has been auto-generated by the Symfony Dependency Injection Component for internal use.
// Returns the public 'deprecated_service' shared service.

@trigger_error('The "deprecated_service" service is deprecated. You should stop using it, as it will be removed in the future.', E_USER_DEPRECATED);
trigger_deprecation('', '', 'The "deprecated_service" service is deprecated. You should stop using it, as it will be removed in the future.');

return $this->services['deprecated_service'] = new \stdClass();

@@ -156,7 +156,7 @@ use Symfony\Component\DependencyInjection\Exception\RuntimeException;
// This file has been auto-generated by the Symfony Dependency Injection Component for internal use.
// Returns the private 'factory_simple' shared service.

@trigger_error('The "factory_simple" service is deprecated. You should stop using it, as it will be removed in the future.', E_USER_DEPRECATED);
trigger_deprecation('', '', 'The "factory_simple" service is deprecated. You should stop using it, as it will be removed in the future.');

return new \SimpleFactoryClass('foo');

@@ -210,7 +210,7 @@ protected function getDecoratorServiceWithNameService()
*/
protected function getDeprecatedServiceService()
{
@trigger_error('The "deprecated_service" service is deprecated. You should stop using it, as it will be removed in the future.', E_USER_DEPRECATED);
trigger_deprecation('', '', 'The "deprecated_service" service is deprecated. You should stop using it, as it will be removed in the future.');

return $this->services['deprecated_service'] = new \stdClass();
}
@@ -404,7 +404,7 @@ protected function getTaggedIteratorService()
*/
protected function getFactorySimpleService()
{
@trigger_error('The "factory_simple" service is deprecated. You should stop using it, as it will be removed in the future.', E_USER_DEPRECATED);
trigger_deprecation('', '', 'The "factory_simple" service is deprecated. You should stop using it, as it will be removed in the future.');

return new \SimpleFactoryClass('foo');
}
@@ -231,7 +231,7 @@ class ProjectServiceContainer extends Container
*/
protected function getDeprecatedServiceService()
{
@trigger_error('The "deprecated_service" service is deprecated. You should stop using it, as it will be removed in the future.', E_USER_DEPRECATED);
trigger_deprecation('', '', 'The "deprecated_service" service is deprecated. You should stop using it, as it will be removed in the future.');

return $this->services['deprecated_service'] = new \stdClass();
}
@@ -453,7 +453,7 @@ class ProjectServiceContainer extends Container
*/
protected function getFactorySimpleService()
{
@trigger_error('The "factory_simple" service is deprecated. You should stop using it, as it will be removed in the future.', E_USER_DEPRECATED);
trigger_deprecation('', '', 'The "factory_simple" service is deprecated. You should stop using it, as it will be removed in the future.');

return new \SimpleFactoryClass('foo');
}
@@ -210,7 +210,7 @@ protected function getDecoratorServiceWithNameService()
*/
protected function getDeprecatedServiceService()
{
@trigger_error('The "deprecated_service" service is deprecated. You should stop using it, as it will be removed in the future.', E_USER_DEPRECATED);
trigger_deprecation('', '', 'The "deprecated_service" service is deprecated. You should stop using it, as it will be removed in the future.');

return $this->services['deprecated_service'] = new \stdClass();
}
@@ -404,7 +404,7 @@ protected function getTaggedIteratorService()
*/
protected function getFactorySimpleService()
{
@trigger_error('The "factory_simple" service is deprecated. You should stop using it, as it will be removed in the future.', E_USER_DEPRECATED);
trigger_deprecation('', '', 'The "factory_simple" service is deprecated. You should stop using it, as it will be removed in the future.');

return new \SimpleFactoryClass('foo');
}
@@ -18,6 +18,7 @@
"require": {
"php": "^7.2.5",
"psr/container": "^1.0",
"symfony/deprecation-contracts": "^2.1",
"symfony/service-contracts": "^1.1.6|^2"
},
"require-dev": {
@@ -46,7 +46,7 @@ final class Dotenv
public function __construct($envKey = 'APP_ENV', string $debugKey = 'APP_DEBUG')
{
if (\in_array($envKey = (string) $envKey, ['1', ''], true)) {
@trigger_error(sprintf('Passing a boolean to the constructor of "%s" is deprecated since Symfony 5.1, use "Dotenv::usePutenv()".', __CLASS__), E_USER_DEPRECATED);
trigger_deprecation('symfony/dotenv', '5.1', 'Passing a boolean to the constructor of "%s" is deprecated, use "Dotenv::usePutenv()".', __CLASS__);
$this->usePutenv = (bool) $envKey;
$envKey = 'APP_ENV';
}
@@ -16,7 +16,8 @@
}
],
"require": {
"php": "^7.2.5"
"php": "^7.2.5",
"symfony/deprecation-contracts": "^2.1"
},
"require-dev": {
"symfony/process": "^4.4|^5.0"
@@ -13,7 +13,7 @@

use Symfony\Contracts\EventDispatcher\EventDispatcherInterface;

@trigger_error(sprintf('%s is deprecated since Symfony 5.1, use the event dispatcher without the proxy.', LegacyEventDispatcherProxy::class), E_USER_DEPRECATED);
trigger_deprecation('symfony/event-dispatcher', '5.1', '%s is deprecated, use the event dispatcher without the proxy.', LegacyEventDispatcherProxy::class);

/**
* A helper class to provide BC/FC with the legacy signature of EventDispatcherInterface::dispatch().
@@ -17,6 +17,7 @@
],
"require": {
"php": "^7.2.5",
"symfony/deprecation-contracts": "^2.1",
"symfony/event-dispatcher-contracts": "^2"
},
"require-dev": {
@@ -61,7 +61,7 @@ public function buildForm(FormBuilderInterface $builder, array $options)
}

if (!method_exists($builder, 'setIsEmptyCallback')) {
@trigger_error(sprintf('Not implementing the "%s::setIsEmptyCallback()" method in "%s" is deprecated since Symfony 5.1.', FormConfigBuilderInterface::class, \get_class($builder)), E_USER_DEPRECATED);
trigger_deprecation('symfony/form', '5.1', 'Not implementing the "%s::setIsEmptyCallback()" method in "%s" is deprecated.', FormConfigBuilderInterface::class, \get_class($builder));

return;
}
@@ -727,7 +727,7 @@ public function isEmpty()
}

if (!method_exists($this->config, 'getIsEmptyCallback')) {
@trigger_error(sprintf('Not implementing the "%s::getIsEmptyCallback()" method in "%s" is deprecated since Symfony 5.1.', FormConfigInterface::class, \get_class($this->config)), E_USER_DEPRECATED);
trigger_deprecation('symfony/form', '5.1', 'Not implementing the "%s::getIsEmptyCallback()" method in "%s" is deprecated.', FormConfigInterface::class, \get_class($this->config));

$isEmptyCallback = null;
} else {
@@ -17,6 +17,7 @@
],
"require": {
"php": "^7.2.5",
"symfony/deprecation-contracts": "^2.1",
"symfony/event-dispatcher": "^4.4|^5.0",
"symfony/intl": "^4.4|^5.0",
"symfony/options-resolver": "^5.0",
@@ -68,7 +68,7 @@ public function __construct($data = null, int $status = 200, array $headers = []
*/
public static function create($data = null, int $status = 200, array $headers = [])
{
@trigger_error(sprintf('The "%s()" method is deprecated since Symfony 5.1; use __construct() instead.', __METHOD__), E_USER_DEPRECATED);
trigger_deprecation('symfony/http-foundation', '5.1', 'The "%s()" method is deprecated, use "new %s()" instead.', __METHOD__, \get_called_class());

return new static($data, $status, $headers);
}
@@ -58,7 +58,7 @@ public function __construct(string $url, int $status = 302, array $headers = [])
*/
public static function create($url = '', int $status = 302, array $headers = [])
{
@trigger_error(sprintf('The "%s()" method is deprecated since Symfony 5.1; use __construct() instead.', __METHOD__), E_USER_DEPRECATED);
trigger_deprecation('symfony/http-foundation', '5.1', 'The "%s()" method is deprecated, use "new %s()" instead.', __METHOD__, \get_called_class());

return new static($url, $status, $headers);
}
@@ -213,7 +213,7 @@ public function __construct(?string $content = '', int $status = 200, array $hea
*/
public static function create(?string $content = '', int $status = 200, array $headers = [])
{
@trigger_error(sprintf('The "%s()" method is deprecated since Symfony 5.1; use __construct() instead.', __METHOD__), E_USER_DEPRECATED);
trigger_deprecation('symfony/http-foundation', '5.1', 'The "%s()" method is deprecated, use "new %s()" instead.', __METHOD__, \get_called_class());

return new static($content, $status, $headers);
}
@@ -52,7 +52,7 @@ public function __construct(callable $callback = null, int $status = 200, array
*/
public static function create($callback = null, int $status = 200, array $headers = [])
{
@trigger_error(sprintf('The "%s()" method is deprecated since Symfony 5.1; use __construct() instead.', __METHOD__), E_USER_DEPRECATED);
trigger_deprecation('symfony/http-foundation', '5.1', 'The "%s()" method is deprecated, use "new %s()" instead.', __METHOD__, \get_called_class());

return new static($callback, $status, $headers);
}
@@ -17,6 +17,7 @@
],
"require": {
"php": "^7.2.5",
"symfony/deprecation-contracts": "^2.1",
"symfony/polyfill-mbstring": "~1.1"
},
"require-dev": {
@@ -104,7 +104,7 @@ public function testOptionsAreTakenIntoAccountAndOverwrittenByDsn()

/**
* @group legacy
* @expectedDeprecation Invalid option(s) "foo" passed to the AMQP Messenger transport. Passing invalid options is deprecated since Symfony 5.1.
* @expectedDeprecation Since symfony/messenger 5.1: Invalid option(s) "foo" passed to the AMQP Messenger transport. Passing invalid options is deprecated.
*/
public function testDeprecationIfInvalidOptionIsPassedWithDsn()
{
@@ -113,7 +113,7 @@ public function testDeprecationIfInvalidOptionIsPassedWithDsn()

/**
* @group legacy
* @expectedDeprecation Invalid option(s) "foo" passed to the AMQP Messenger transport. Passing invalid options is deprecated since Symfony 5.1.
* @expectedDeprecation Since symfony/messenger 5.1: Invalid option(s) "foo" passed to the AMQP Messenger transport. Passing invalid options is deprecated.
*/
public function testDeprecationIfInvalidOptionIsPassedAsArgument()
{
@@ -122,7 +122,7 @@ public function testDeprecationIfInvalidOptionIsPassedAsArgument()

/**
* @group legacy
* @expectedDeprecation Invalid queue option(s) "foo" passed to the AMQP Messenger transport. Passing invalid queue options is deprecated since Symfony 5.1.
* @expectedDeprecation Since symfony/messenger 5.1: Invalid queue option(s) "foo" passed to the AMQP Messenger transport. Passing invalid queue options is deprecated.
*/
public function testDeprecationIfInvalidQueueOptionIsPassed()
{
@@ -131,7 +131,7 @@ public function testDeprecationIfInvalidQueueOptionIsPassed()

/**
* @group legacy
* @expectedDeprecation Invalid exchange option(s) "foo" passed to the AMQP Messenger transport. Passing invalid exchange options is deprecated since Symfony 5.1.
* @expectedDeprecation Since symfony/messenger 5.1: Invalid exchange option(s) "foo" passed to the AMQP Messenger transport. Passing invalid exchange options is deprecated.
*/
public function testDeprecationIfInvalidExchangeOptionIsPassed()
{

0 comments on commit 3e35d8e

Please sign in to comment.
You can’t perform that action at this time.