Skip to content

[7.0] Remove remaining deprecated code paths #50873

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 5, 2023
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
232 changes: 93 additions & 139 deletions .github/expected-missing-return-types.diff

Large diffs are not rendered by default.

80 changes: 76 additions & 4 deletions UPGRADE-7.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ Cache

* Add parameter `$isSameDatabase` to `DoctrineDbalAdapter::configureSchema()`

Config
------

* Require explicit argument when calling `NodeBuilder::setParent()`

Console
-------

Expand Down Expand Up @@ -41,7 +46,7 @@ Console
}
```

* Passing null to `*Command::setApplication()`, `*FormatterStyle::setForeground/setBackground()`, `Helper::setHelpSet()`, `Input*::setDefault()` and `Question::setAutocompleterCallback/setValidator()` must be done explicitly
* Require explicit argument when calling `*Command::setApplication()`, `*FormatterStyle::setForeground/setBackground()`, `Helper::setHelpSet()`, `Input*::setDefault()` and `Question::setAutocompleterCallback/setValidator()`
* Remove `StringInput::REGEX_STRING`
* Add method `__toString()` to `InputInterface`

Expand All @@ -52,7 +57,7 @@ DependencyInjection
* Remove `ProxyHelper`, use `Symfony\Component\VarExporter\ProxyHelper` instead
* Remove `ReferenceSetArgumentTrait`
* Remove support of `@required` annotation, use the `Symfony\Contracts\Service\Attribute\Required` attribute instead
* Passing `null` to `ContainerAwareTrait::setContainer()` must be done explicitly
* Require explicit argument when calling `ContainerAwareTrait::setContainer()`
* Remove `PhpDumper` options `inline_factories_parameter` and `inline_class_loader_parameter`, use options `inline_factories` and `inline_class_loader` instead
* Parameter names of `ParameterBag` cannot be numerics
* Remove `ContainerAwareInterface` and `ContainerAwareTrait`, use dependency injection instead
Expand Down Expand Up @@ -82,10 +87,34 @@ Filesystem

* Add argument `$lock` to `Filesystem::appendToFile()`

Form
----

* Throw when using `DateTime` or `DateTimeImmutable` model data with a different timezone than configured with the
`model_timezone` option in `DateType`, `DateTimeType`, and `TimeType`
* Make the "widget" option of date/time form types default to "single_text"
* Require explicit argument when calling `Button/Form::setParent()`, `ButtonBuilder/FormConfigBuilder::setDataMapper()`, `TransformationFailedException::setInvalidMessage()`

FrameworkBundle
---------------

* Remove command `translation:update`, use `translation:extract` instead
* Make the `http_method_override` config option default to `false`
* Remove the `Symfony\Component\Serializer\Normalizer\ObjectNormalizer` and
`Symfony\Component\Serializer\Normalizer\PropertyNormalizer` autowiring aliases, type-hint against
`Symfony\Component\Serializer\Normalizer\NormalizerInterface` or implement `NormalizerAwareInterface` instead
* Remove the `Http\Client\HttpClient` service, use `Psr\Http\Client\ClientInterface` instead
* Remove `AbstractController::renderForm()`, use `render()` instead

*Before*
```php
$this->renderForm(..., ['form' => $form]);
```

*After*
```php
$this->render(..., ['form' => $form]);
```

HttpFoundation
--------------
Expand All @@ -99,6 +128,7 @@ HttpFoundation
* Replace `ExpressionRequestMatcher` with `RequestMatcher\ExpressionRequestMatcher`
* Remove `Request::getContentType()`, use `Request::getContentTypeFormat()` instead
* Throw an `InvalidArgumentException` when calling `Request::create()` with a malformed URI
* Require explicit argument when calling `JsonResponse::setCallback()`, `Response::setExpires/setLastModified/setEtag()`, `MockArraySessionStorage/NativeSessionStorage::setMetadataBag()`, `NativeSessionStorage::setSaveHandler()`

HttpClient
----------
Expand All @@ -114,28 +144,42 @@ HttpKernel
* Remove `AbstractSurrogate::$phpEscapeMap`
* Remove `HttpKernelInterface::MASTER_REQUEST`
* Remove `terminate_on_cache_hit` option from `HttpCache`
* Require explicit argument when calling `ConfigDataCollector::setKernel()`, `RouterListener::setCurrentRequest()`

Lock
----

* Add parameter `$isSameDatabase` to `DoctrineDbalStore::configureSchema()`
* Remove the `gcProbablity` (notice the typo) option, use `gcProbability` instead

Mailer
------

* Remove the OhMySmtp bridge in favor of the MailPace bridge

Messenger
---------

* Add parameter `$isSameDatabase` to `DoctrineTransport::configureSchema()`
* Remove `MessageHandlerInterface` and `MessageSubscriberInterface`, use `#[AsMessageHandler]` instead
* Remove `StopWorkerOnSigtermSignalListener` in favor of
`StopWorkerOnSignalsListener` and make it configurable with SIGINT and
* Remove `Symfony\Component\Messenger\Transport\InMemoryTransport` and
`Symfony\Component\Messenger\Transport\InMemoryTransportFactory` in favor of
`Symfony\Component\Messenger\Transport\InMemory\InMemoryTransport` and
`Symfony\Component\Messenger\Transport\InMemory\InMemoryTransportFactory`

Mime
----

* Remove `Email::attachPart()` method, use `Email::addPart()` instead
* Parameter `$body` is now required (at least null) in `Message::setBody()`
* Require explicit argument when calling `Message::setBody()`

PropertyAccess
--------------

* Add method `isNullSafe()` to `PropertyPathInterface`
* Require explicit argument when calling `PropertyAccessorBuilder::setCacheItemPool()`

ProxyManagerBridge
------------------
Expand All @@ -152,6 +196,7 @@ Security

* Add argument `$badgeFqcn` to `Passport::addBadge()`
* Add argument `$lifetime` to `LoginLinkHandlerInterface::createLoginLink()`
* Require explicit argument when calling `TokenStorage::setToken()`

SecurityBundle
--------------
Expand Down Expand Up @@ -189,6 +234,7 @@ Serializer
}
}
```

* Remove `CacheableSupportsMethodInterface`, use `NormalizerInterface` and `DenormalizerInterface` instead

*Before*
Expand Down Expand Up @@ -233,9 +279,24 @@ Serializer
// ...
}
```
* First argument of `AttributeMetadata::setSerializedName()` is now required

* Require explicit argument when calling `AttributeMetadata::setSerializedName()` and `ClassMetadata::setClassDiscriminatorMapping()`
* Add argument `$context` to `NormalizerInterface::supportsNormalization()` and `DenormalizerInterface::supportsDenormalization()`

Translation
-----------

* Remove `PhpStringTokenParser`
* Remove `PhpExtractor` in favor of `PhpAstExtractor`

TwigBundle
----------

* Remove the `Twig_Environment` autowiring alias, use `Twig\Environment` instead
* Remove option `twig.autoescape`; create a class that implements your escaping strategy
(check `FileExtensionEscapingStrategy::guess()` for inspiration) and reference it using
the `twig.autoescape_service` option instead

Validator
---------

Expand All @@ -250,3 +311,14 @@ VarDumper
---------

* Add argument `$label` to `VarDumper::dump()`
* Require explicit argument when calling `VarDumper::setHandler()`

Workflow
--------

* Require explicit argument when calling `Definition::setInitialPlaces()`

Yaml
----

* Remove the `!php/const:` tag, use `!php/const` instead (without the colon)
1 change: 0 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,6 @@
"pda/pheanstalk": "^4.0",
"php-http/discovery": "^1.15",
"php-http/httplug": "^1.0|^2.0",
"php-http/message-factory": "^1.0",
"phpdocumentor/reflection-docblock": "^5.2",
"phpstan/phpdoc-parser": "^1.0",
"predis/predis": "^1.1|^2.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
use Symfony\Component\DependencyInjection\Reference;

/**
* Registers event listeners and subscribers to the available doctrine connections.
* Registers event listeners to the available doctrine connections.
*
* @author Jeremy Mikola <jmikola@gmail.com>
* @author Alexander <iam.asm89@gmail.com>
Expand All @@ -44,7 +44,7 @@ class RegisterEventListenersAndSubscribersPass implements CompilerPassInterface
/**
* @param string $managerTemplate sprintf() template for generating the event
* manager's service ID for a connection name
* @param string $tagPrefix Tag prefix for listeners and subscribers
* @param string $tagPrefix Tag prefix for listeners
*/
public function __construct(string $connectionsParameter, string $managerTemplate, string $tagPrefix)
{
Expand Down Expand Up @@ -72,18 +72,13 @@ public function process(ContainerBuilder $container): void

private function addTaggedServices(ContainerBuilder $container): array
{
$listenerTag = $this->tagPrefix.'.event_listener';
$subscriberTag = $this->tagPrefix.'.event_subscriber';
$listenerRefs = [];
$taggedServices = $this->findAndSortTags($subscriberTag, $listenerTag, $container);

$managerDefs = [];
foreach ($taggedServices as $taggedSubscriber) {
[$tagName, $id, $tag] = $taggedSubscriber;
foreach ($this->findAndSortTags($container) as [$id, $tag]) {
$connections = isset($tag['connection'])
? [$container->getParameterBag()->resolveValue($tag['connection'])]
: array_keys($this->connections);
if ($listenerTag === $tagName && !isset($tag['event'])) {
if (!isset($tag['event'])) {
throw new InvalidArgumentException(sprintf('Doctrine event listener "%s" must specify the "event" attribute.', $id));
}
foreach ($connections as $con) {
Expand All @@ -105,19 +100,10 @@ private function addTaggedServices(ContainerBuilder $container): array
if (ContainerAwareEventManager::class === $managerClass) {
$refs = $managerDef->getArguments()[1] ?? [];
$listenerRefs[$con][$id] = new Reference($id);
if ($subscriberTag === $tagName) {
trigger_deprecation('symfony/doctrine-bridge', '6.3', 'Registering "%s" as a Doctrine subscriber is deprecated. Register it as a listener instead, using e.g. the #[AsDoctrineListener] attribute.', $id);
$refs[] = $id;
} else {
$refs[] = [[$tag['event']], $id];
}
$refs[] = [[$tag['event']], $id];
$managerDef->setArgument(1, $refs);
} else {
if ($subscriberTag === $tagName) {
$managerDef->addMethodCall('addEventSubscriber', [new Reference($id)]);
} else {
$managerDef->addMethodCall('addEventListener', [[$tag['event']], new Reference($id)]);
}
$managerDef->addMethodCall('addEventListener', [[$tag['event']], new Reference($id)]);
}
}
}
Expand All @@ -144,21 +130,14 @@ private function getEventManagerDef(ContainerBuilder $container, string $name):
* @see https://bugs.php.net/53710
* @see https://bugs.php.net/60926
*/
private function findAndSortTags(string $subscriberTag, string $listenerTag, ContainerBuilder $container): array
private function findAndSortTags(ContainerBuilder $container): array
{
$sortedTags = [];
$taggedIds = [
$subscriberTag => $container->findTaggedServiceIds($subscriberTag, true),
$listenerTag => $container->findTaggedServiceIds($listenerTag, true),
];
$taggedIds[$subscriberTag] = array_diff_key($taggedIds[$subscriberTag], $taggedIds[$listenerTag]);

foreach ($taggedIds as $tagName => $serviceIds) {
foreach ($serviceIds as $serviceId => $tags) {
foreach ($tags as $attributes) {
$priority = $attributes['priority'] ?? 0;
$sortedTags[$priority][] = [$tagName, $serviceId, $attributes];
}

foreach ($container->findTaggedServiceIds($this->tagPrefix.'.event_listener', true) as $serviceId => $tags) {
foreach ($tags as $attributes) {
$priority = $attributes['priority'] ?? 0;
$sortedTags[$priority][] = [$serviceId, $attributes];
}
}

Expand Down
Loading