Skip to content
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
52 changes: 52 additions & 0 deletions UPGRADE-6.2.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,31 @@
UPGRADE FROM 6.1 to 6.2
=======================

Config
------

* Deprecate calling `NodeBuilder::setParent()` without any arguments

Console
-------

* Deprecate calling `*Command::setApplication()`, `*FormatterStyle::setForeground/setBackground()`, `Helper::setHelpSet()`, `Input*::setDefault()`, `Question::setAutocompleterCallback/setValidator()`without any arguments
* Change the signature of `OutputFormatterStyleInterface::setForeground/setBackground()` to `setForeground/setBackground(?string)`
* Change the signature of `HelperInterface::setHelperSet()` to `setHelperSet(?HelperSet)`

DependencyInjection
-------------------

* Change the signature of `ContainerAwareInterface::setContainer()` to `setContainer(?ContainerInterface)`
* Deprecate calling `ContainerAwareTrait::setContainer()` without arguments

Form
----

* Deprecate calling `Button/Form::setParent()`, `ButtonBuilder/FormConfigBuilder::setDataMapper()`, `TransformationFailedException::setInvalidMessage()` without arguments
* Change the signature of `FormConfigBuilderInterface::setDataMapper()` to `setDataMapper(?DataMapperInterface)`
* Change the signature of `FormInterface::setParent()` to `setParent(?self)`

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

Expand All @@ -13,11 +38,13 @@ HttpFoundation
--------------

* Deprecate `Request::getContentType()`, use `Request::getContentTypeFormat()` instead
* Deprecate calling `JsonResponse::setCallback()`, `Response::setExpires/setLastModified/setEtag()`, `MockArraySessionStorage/NativeSessionStorage::setMetadataBag()`, `NativeSessionStorage::setSaveHandler()` without arguments

HttpKernel
----------

* Deprecate `ArgumentValueResolverInterface`, use `ValueResolverInterface` instead
* Deprecate calling `ConfigDataCollector::setKernel()`, `RouterListener::setCurrentRequest()` without arguments

Ldap
----
Expand All @@ -29,6 +56,16 @@ Mailer

* Deprecate the `OhMySMTP` transport, use `MailPace` instead

Mime
----

* Deprecate calling `Message::setBody()` without arguments

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

* Deprecate calling `PropertyAccessorBuilder::setCacheItemPool()` without arguments

Security
--------

Expand All @@ -37,12 +74,26 @@ Security
* Deprecate the `Symfony\Component\Security\Core\Security` class and service, use `Symfony\Bundle\SecurityBundle\Security\Security` instead
* Passing empty username or password parameter when using `JsonLoginAuthenticator` is not supported anymore
* Add `$lifetime` parameter to `LoginLinkHandlerInterface::createLoginLink()`
* Change the signature of `TokenStorageInterface::setToken()` to `setToken(?TokenInterface $token)`
* Deprecate calling `TokenStorage::setToken()` or `UsageTrackingTokenStorage::setToken()` without arguments

Serializer
----------

* Deprecate calling `AttributeMetadata::setSerializedName()`, `ClassMetadata::setClassDiscriminatorMapping()` without arguments
* Change the signature of `AttributeMetadataInterface::setSerializedName()` to `setSerializedName(?string)`
* Change the signature of `ClassMetadataInterface::setClassDiscriminatorMapping()` to `setClassDiscriminatorMapping(?ClassDiscriminatorMapping)`

Validator
---------

* Deprecate the `loose` e-mail validation mode, use `html5` instead

VarDumper
---------

* Deprecate calling `VarDumper::setHandler()` without arguments

Workflow
--------

Expand All @@ -52,3 +103,4 @@ Workflow
```
* The first argument of `WorkflowDumpCommand` should be a `ServiceLocator` of
all workflows indexed by names
* Deprecate calling `Definition::setInitialPlaces()` without arguments
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class ContainerAwareFixture implements FixtureInterface, ContainerAwareInterface
{
public $container;

public function setContainer(ContainerInterface $container = null)
public function setContainer(?ContainerInterface $container)
{
$this->container = $container;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ class ContainerAwareController implements ContainerAwareInterface
{
private $container;

public function setContainer(ContainerInterface $container = null)
public function setContainer(?ContainerInterface $container)
{
$this->container = $container;
}
Expand Down
5 changes: 5 additions & 0 deletions src/Symfony/Component/Config/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
CHANGELOG
=========

6.2
---

* Deprecate calling `NodeBuilder::setParent()` without any arguments

6.1
---

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ public function __construct()
*/
public function setParent(ParentNodeDefinitionInterface $parent = null): static
{
if (1 > \func_num_args()) {
trigger_deprecation('symfony/form', '6.2', 'Calling "%s()" without any arguments is deprecated, pass null explicitly instead.', __METHOD__);
}
$this->parent = $parent;

return $this;
Expand Down
7 changes: 5 additions & 2 deletions src/Symfony/Component/Console/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,11 @@ CHANGELOG
6.2
---

* Improve truecolor terminal detection in some cases
* Add support for 256 color terminals (conversion from Ansi24 to Ansi8 if terminal is capable of it)
* Improve truecolor terminal detection in some cases
* Add support for 256 color terminals (conversion from Ansi24 to Ansi8 if terminal is capable of it)
* Deprecate calling `*Command::setApplication()`, `*FormatterStyle::setForeground/setBackground()`, `Helper::setHelpSet()`, `Input*::setDefault()`, `Question::setAutocompleterCallback/setValidator()`without any arguments
* Change the signature of `OutputFormatterStyleInterface::setForeground/setBackground()` to `setForeground/setBackground(?string)`
* Change the signature of `HelperInterface::setHelperSet()` to `setHelperSet(?HelperSet)`

6.1
---
Expand Down
3 changes: 3 additions & 0 deletions src/Symfony/Component/Console/Command/Command.php
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,9 @@ public function ignoreValidationErrors()

public function setApplication(Application $application = null)
{
if (1 > \func_num_args()) {
trigger_deprecation('symfony/console', '6.2', 'Calling "%s()" without any arguments is deprecated, pass null explicitly instead.', __METHOD__);
}
$this->application = $application;
if ($application) {
$this->setHelperSet($application->getHelperSet());
Expand Down
3 changes: 3 additions & 0 deletions src/Symfony/Component/Console/Command/LazyCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ public function ignoreValidationErrors(): void

public function setApplication(Application $application = null): void
{
if (1 > \func_num_args()) {
trigger_deprecation('symfony/console', '6.2', 'Calling "%s()" without any arguments is deprecated, pass null explicitly instead.', __METHOD__);
}
if ($this->command instanceof parent) {
$this->command->setApplication($application);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,17 @@ public function apply(string $text): string

public function setBackground(string $color = null): void
{
if (1 > \func_num_args()) {
trigger_deprecation('symfony/console', '6.2', 'Calling "%s()" without any arguments is deprecated, pass null explicitly instead.', __METHOD__);
}
// do nothing
}

public function setForeground(string $color = null): void
{
if (1 > \func_num_args()) {
trigger_deprecation('symfony/console', '6.2', 'Calling "%s()" without any arguments is deprecated, pass null explicitly instead.', __METHOD__);
}
// do nothing
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,17 @@ public function __construct(string $foreground = null, string $background = null

public function setForeground(string $color = null)
{
if (1 > \func_num_args()) {
trigger_deprecation('symfony/console', '6.2', 'Calling "%s()" without any arguments is deprecated, pass null explicitly instead.', __METHOD__);
}
$this->color = new Color($this->foreground = $color ?: '', $this->background, $this->options);
}

public function setBackground(string $color = null)
{
if (1 > \func_num_args()) {
trigger_deprecation('symfony/console', '6.2', 'Calling "%s()" without any arguments is deprecated, pass null explicitly instead.', __METHOD__);
}
$this->color = new Color($this->foreground, $this->background = $color ?: '', $this->options);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@ interface OutputFormatterStyleInterface
/**
* Sets style foreground color.
*/
public function setForeground(string $color = null);
public function setForeground(?string $color);

/**
* Sets style background color.
*/
public function setBackground(string $color = null);
public function setBackground(?string $color);

/**
* Sets some specific style option.
Expand Down
3 changes: 3 additions & 0 deletions src/Symfony/Component/Console/Helper/Helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ abstract class Helper implements HelperInterface

public function setHelperSet(HelperSet $helperSet = null)
{
if (1 > \func_num_args()) {
trigger_deprecation('symfony/console', '6.2', 'Calling "%s()" without any arguments is deprecated, pass null explicitly instead.', __METHOD__);
}
$this->helperSet = $helperSet;
}

Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Component/Console/Helper/HelperInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ interface HelperInterface
/**
* Sets the helper set associated with this helper.
*/
public function setHelperSet(HelperSet $helperSet = null);
public function setHelperSet(?HelperSet $helperSet);

/**
* Gets the helper set associated with this helper.
Expand Down
3 changes: 3 additions & 0 deletions src/Symfony/Component/Console/Input/InputArgument.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,9 @@ public function isArray(): bool
*/
public function setDefault(string|bool|int|float|array $default = null)
{
if (1 > \func_num_args()) {
trigger_deprecation('symfony/console', '6.2', 'Calling "%s()" without any arguments is deprecated, pass null explicitly instead.', __METHOD__);
}
if ($this->isRequired() && null !== $default) {
throw new LogicException('Cannot set a default value except for InputArgument::OPTIONAL mode.');
}
Expand Down
3 changes: 3 additions & 0 deletions src/Symfony/Component/Console/Input/InputOption.php
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,9 @@ public function isNegatable(): bool

public function setDefault(string|bool|int|float|array $default = null)
{
if (1 > \func_num_args()) {
trigger_deprecation('symfony/console', '6.2', 'Calling "%s()" without any arguments is deprecated, pass null explicitly instead.', __METHOD__);
}
if (self::VALUE_NONE === (self::VALUE_NONE & $this->mode) && null !== $default) {
throw new LogicException('Cannot set a default value when using InputOption::VALUE_NONE mode.');
}
Expand Down
6 changes: 6 additions & 0 deletions src/Symfony/Component/Console/Question/Question.php
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,9 @@ public function getAutocompleterCallback(): ?callable
*/
public function setAutocompleterCallback(callable $callback = null): static
{
if (1 > \func_num_args()) {
trigger_deprecation('symfony/console', '6.2', 'Calling "%s()" without any arguments is deprecated, pass null explicitly instead.', __METHOD__);
}
if ($this->hidden && null !== $callback) {
throw new LogicException('A hidden question cannot use the autocompleter.');
}
Expand All @@ -194,6 +197,9 @@ public function setAutocompleterCallback(callable $callback = null): static
*/
public function setValidator(callable $validator = null): static
{
if (1 > \func_num_args()) {
trigger_deprecation('symfony/console', '6.2', 'Calling "%s()" without any arguments is deprecated, pass null explicitly instead.', __METHOD__);
}
$this->validator = null === $validator ? null : $validator(...);

return $this;
Expand Down
2 changes: 2 additions & 0 deletions src/Symfony/Component/DependencyInjection/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ CHANGELOG
* Add `enum` env var processor
* Add `shuffle` env var processor
* Allow #[When] to be extended
* Change the signature of `ContainerAwareInterface::setContainer()` to `setContainer(?ContainerInterface)`
* Deprecate calling `ContainerAwareTrait::setContainer()` without arguments

6.1
---
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,5 @@ interface ContainerAwareInterface
/**
* Sets the container.
*/
public function setContainer(ContainerInterface $container = null);
public function setContainer(?ContainerInterface $container);
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ trait ContainerAwareTrait

public function setContainer(ContainerInterface $container = null)
{
if (1 > \func_num_args()) {
trigger_deprecation('symfony/dependency-injection', '6.2', 'Calling "%s::%s()" without any arguments is deprecated, pass null explicitly instead.', __CLASS__, __FUNCTION__);
}

$this->container = $container;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
<?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\Tests;

use PHPUnit\Framework\TestCase;
use Symfony\Bridge\PhpUnit\ExpectDeprecationTrait;
use Symfony\Component\DependencyInjection\ContainerAwareInterface;
use Symfony\Component\DependencyInjection\ContainerAwareTrait;
use Symfony\Component\DependencyInjection\ContainerInterface;

class ContainerAwareTraitTest extends TestCase
{
use ExpectDeprecationTrait;

/**
* @group legacy
*/
public function testSetContainerLegacy()
{
$container = $this->createMock(ContainerInterface::class);

$dummy = new ContainerAwareDummy();
$dummy->setContainer($container);

self::assertSame($container, $dummy->getContainer());

$this->expectDeprecation('Since symfony/dependency-injection 6.2: Calling "Symfony\Component\DependencyInjection\Tests\ContainerAwareDummy::setContainer()" without any arguments is deprecated, pass null explicitly instead.');

$dummy->setContainer();
self::assertNull($dummy->getContainer());
}

public function testSetContainer()
{
$container = $this->createMock(ContainerInterface::class);

$dummy = new ContainerAwareDummy();
$dummy->setContainer($container);

self::assertSame($container, $dummy->getContainer());

$dummy->setContainer(null);
self::assertNull($dummy->getContainer());
}
}

class ContainerAwareDummy implements ContainerAwareInterface
{
use ContainerAwareTrait;

public function getContainer(): ?ContainerInterface
{
return $this->container;
}
}
3 changes: 3 additions & 0 deletions src/Symfony/Component/Form/Button.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,9 @@ public function offsetUnset(mixed $offset): void

public function setParent(FormInterface $parent = null): static
{
if (1 > \func_num_args()) {
trigger_deprecation('symfony/form', '6.2', 'Calling "%s()" without any arguments is deprecated, pass null explicitly instead.', __METHOD__);
}
if ($this->submitted) {
throw new AlreadySubmittedException('You cannot set the parent of a submitted button.');
}
Expand Down
4 changes: 4 additions & 0 deletions src/Symfony/Component/Form/ButtonBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,10 @@ public function setAttributes(array $attributes): static
*/
public function setDataMapper(DataMapperInterface $dataMapper = null): static
{
if (1 > \func_num_args()) {
trigger_deprecation('symfony/form', '6.2', 'Calling "%s()" without any arguments is deprecated, pass null explicitly instead.', __METHOD__);
}

throw new BadMethodCallException('Buttons do not support data mappers.');
}

Expand Down
Loading