Sync UPGRADE-3.0.md with 3.4

This commit is contained in:
Nicolas Grekas 2018-02-22 13:34:56 +01:00
parent a1a2a0ad69
commit 3a42da3c5f
1 changed files with 131 additions and 8 deletions

View File

@ -127,8 +127,14 @@ UPGRADE FROM 2.x to 3.0
$table->render(); $table->render();
``` ```
* Parameters of `renderException()` method of the
`Symfony\Component\Console\Application` are type hinted.
You must add the type hint to your implementations.
### DependencyInjection ### DependencyInjection
* The method `remove` was added to `Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface`.
* The concept of scopes was removed, the removed methods are: * The concept of scopes was removed, the removed methods are:
- `Symfony\Component\DependencyInjection\ContainerBuilder::getScopes()` - `Symfony\Component\DependencyInjection\ContainerBuilder::getScopes()`
@ -211,6 +217,22 @@ UPGRADE FROM 2.x to 3.0
removed: `ContainerBuilder::synchronize()`, `Definition::isSynchronized()`, removed: `ContainerBuilder::synchronize()`, `Definition::isSynchronized()`,
and `Definition::setSynchronized()`. and `Definition::setSynchronized()`.
### DomCrawler
* The interface of the `Symfony\Component\DomCrawler\Crawler` changed. It does no longer implement `\Iterator` but `\IteratorAggregate`. If you rely on methods of the `\Iterator` interface, call the `getIterator` method of the `\IteratorAggregate` interface before. No changes are required in a `\Traversable`-aware control structure, such as `foreach`.
Before:
```php
$crawler->current();
```
After:
```php
$crawler->getIterator()->current();
```
### DoctrineBridge ### DoctrineBridge
* The `property` option of `DoctrineType` was removed in favor of the `choice_label` option. * The `property` option of `DoctrineType` was removed in favor of the `choice_label` option.
@ -236,11 +258,22 @@ UPGRADE FROM 2.x to 3.0
### EventDispatcher ### EventDispatcher
* The method `getListenerPriority($eventName, $listener)` has been added to the
`EventDispatcherInterface`.
* The interface `Symfony\Component\EventDispatcher\Debug\TraceableEventDispatcherInterface` * The interface `Symfony\Component\EventDispatcher\Debug\TraceableEventDispatcherInterface`
extends `Symfony\Component\EventDispatcher\EventDispatcherInterface`. extends `Symfony\Component\EventDispatcher\EventDispatcherInterface`.
### Form ### Form
* The `getBlockPrefix()` method was added to the `FormTypeInterface` in replacement of
the `getName()` method which has been removed.
* The `configureOptions()` method was added to the `FormTypeInterface` in replacement
of the `setDefaultOptions()` method which has been removed.
* The `getBlockPrefix()` method was added to the `ResolvedFormTypeInterface` in
replacement of the `getName()` method which has been removed.
* The option `options` of the `CollectionType` has been removed in favor * The option `options` of the `CollectionType` has been removed in favor
of the `entry_options` option. of the `entry_options` option.
@ -380,8 +413,8 @@ UPGRADE FROM 2.x to 3.0
$form = $this->createForm(MyType::class); $form = $this->createForm(MyType::class);
``` ```
* Passing custom data to forms now needs to be done * Passing custom data to forms now needs to be done
through the options resolver. through the options resolver.
In the controller: In the controller:
@ -392,7 +425,7 @@ UPGRADE FROM 2.x to 3.0
'method' => 'PUT', 'method' => 'PUT',
)); ));
``` ```
After: After:
```php ```php
$form = $this->createForm(MyType::class, $entity, array( $form = $this->createForm(MyType::class, $entity, array(
'action' => $this->generateUrl('action_route'), 'action' => $this->generateUrl('action_route'),
@ -401,13 +434,13 @@ UPGRADE FROM 2.x to 3.0
)); ));
``` ```
In the form type: In the form type:
Before: Before:
```php ```php
class MyType extends AbstractType class MyType extends AbstractType
{ {
private $value; private $value;
public function __construct($variableValue) public function __construct($variableValue)
{ {
$this->value = $value; $this->value = $value;
@ -415,7 +448,7 @@ UPGRADE FROM 2.x to 3.0
// ... // ...
} }
``` ```
After: After:
```php ```php
public function buildForm(FormBuilderInterface $builder, array $options) public function buildForm(FormBuilderInterface $builder, array $options)
@ -423,7 +456,7 @@ UPGRADE FROM 2.x to 3.0
$value = $options['custom_value']; $value = $options['custom_value'];
// ... // ...
} }
public function configureOptions(OptionsResolver $resolver) public function configureOptions(OptionsResolver $resolver)
{ {
$resolver->setDefaults(array( $resolver->setDefaults(array(
@ -431,7 +464,7 @@ UPGRADE FROM 2.x to 3.0
)); ));
} }
``` ```
* The alias option of the `form.type_extension` tag was removed in favor of * The alias option of the `form.type_extension` tag was removed in favor of
the `extended_type`/`extended-type` option. the `extended_type`/`extended-type` option.
@ -690,6 +723,11 @@ UPGRADE FROM 2.x to 3.0
be removed in Symfony 3.0. Use the `debug:config`, `debug:container`, be removed in Symfony 3.0. Use the `debug:config`, `debug:container`,
`debug:router`, `debug:translation` and `lint:yaml` commands instead. `debug:router`, `debug:translation` and `lint:yaml` commands instead.
* The base `Controller`class is now abstract.
* The visibility of all methods of the base `Controller` class has been changed from
`public` to `protected`.
* The `getRequest` method of the base `Controller` class has been deprecated * The `getRequest` method of the base `Controller` class has been deprecated
since Symfony 2.4 and must be therefore removed in 3.0. The only reliable since Symfony 2.4 and must be therefore removed in 3.0. The only reliable
way to get the `Request` object is to inject it in the action method. way to get the `Request` object is to inject it in the action method.
@ -816,6 +854,8 @@ UPGRADE FROM 2.x to 3.0
* The `RouterApacheDumperCommand` was removed. * The `RouterApacheDumperCommand` was removed.
* The `createEsi` method of `Symfony\Bundle\FrameworkBundle\HttpCache\HttpCache` was removed. Use `createSurrogate` instead.
* The `templating.helper.router` service was moved to `templating_php.xml`. You * The `templating.helper.router` service was moved to `templating_php.xml`. You
have to ensure that the PHP templating engine is enabled to be able to use it: have to ensure that the PHP templating engine is enabled to be able to use it:
@ -1009,6 +1049,12 @@ UPGRADE FROM 2.x to 3.0
### Security ### Security
* The `vote()` method from the `VoterInterface` was changed to now accept arbitrary
types and not only objects. You can rely on the new abstract `Voter` class introduced
in 2.8 to ease integrating your own voters.
* The `AbstractVoter` class was removed in favor of the new `Voter` class.
* The `Resources/` directory was moved to `Core/Resources/` * The `Resources/` directory was moved to `Core/Resources/`
* The `key` settings of `anonymous`, `remember_me` and `http_digest` are * The `key` settings of `anonymous`, `remember_me` and `http_digest` are
@ -1206,6 +1252,68 @@ UPGRADE FROM 2.x to 3.0
* The `Translator::setFallbackLocale()` method has been removed in favor of * The `Translator::setFallbackLocale()` method has been removed in favor of
`Translator::setFallbackLocales()`. `Translator::setFallbackLocales()`.
* The visibility of the `locale` property has been changed from protected to private. Rely on `getLocale` and `setLocale`
instead.
Before:
```php
class CustomTranslator extends Translator
{
public function fooMethod()
{
// get locale
$locale = $this->locale;
// update locale
$this->locale = $locale;
}
}
```
After:
```php
class CustomTranslator extends Translator
{
public function fooMethod()
{
// get locale
$locale = $this->getLocale();
// update locale
$this->setLocale($locale);
}
}
```
* The method `FileDumper::format()` was removed. You should use
`FileDumper::formatCatalogue()` instead.
Before:
```php
class CustomDumper extends FileDumper
{
protected function format(MessageCatalogue $messages, $domain)
{
...
}
}
```
After:
```php
class CustomDumper extends FileDumper
{
public function formatCatalogue(MessageCatalogue $messages, $domain, array $options = array())
{
...
}
}
```
* The `getMessages()` method of the `Symfony\Component\Translation\Translator` * The `getMessages()` method of the `Symfony\Component\Translation\Translator`
class was removed. You should use the `getCatalogue()` method of the class was removed. You should use the `getCatalogue()` method of the
`Symfony\Component\Translation\TranslatorBagInterface`. `Symfony\Component\Translation\TranslatorBagInterface`.
@ -1768,8 +1876,23 @@ UPGRADE FROM 2.x to 3.0
`Process::setInput()` and `Process::getInput()` that works the same way. `Process::setInput()` and `Process::getInput()` that works the same way.
* `Process::setInput()` and `ProcessBuilder::setInput()` do not accept non-scalar types. * `Process::setInput()` and `ProcessBuilder::setInput()` do not accept non-scalar types.
### Monolog Bridge
* `Symfony\Bridge\Monolog\Logger::emerg()` was removed. Use `emergency()` which is PSR-3 compatible.
* `Symfony\Bridge\Monolog\Logger::crit()` was removed. Use `critical()` which is PSR-3 compatible.
* `Symfony\Bridge\Monolog\Logger::err()` was removed. Use `error()` which is PSR-3 compatible.
* `Symfony\Bridge\Monolog\Logger::warn()` was removed. Use `warning()` which is PSR-3 compatible.
### Swiftmailer Bridge
* `Symfony\Bridge\Swiftmailer\DataCollector\MessageDataCollector` was removed. Use the `Symfony\Bundle\SwiftmailerBundle\DataCollector\MessageDataCollector` class instead.
### HttpFoundation ### HttpFoundation
* The precedence of parameters returned from `Request::get()` changed from "GET, PATH, BODY" to "PATH, GET, BODY"
* `Symfony\Component\HttpFoundation\Session\Flash\FlashBagInterface` no longer implements the `IteratorAggregate` interface. Use the `all()` method instead of iterating over the flash bag.
* Removed the feature that allowed finding deep items in `ParameterBag::get()`. * Removed the feature that allowed finding deep items in `ParameterBag::get()`.
This may affect you when getting parameters from the `Request` class: This may affect you when getting parameters from the `Request` class: