Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 561ad17

Browse filesBrowse files
minor #32074 Add BC layer for updated constructor types (nicolas-grekas)
This PR was merged into the 4.4 branch. Discussion ---------- Add BC layer for updated constructor types | Q | A | ------------- | --- | Branch? | 4.4 | Bug fix? | no | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | - | License | MIT | Doc PR | - Reverts some CS changes done in #32066 + replaces its BC breaks by a BC layer. Our CI is too good, it bites us hard when we break our own rules :) Commits ------- c34fcd9 Add BC layer for updated constructor types
2 parents 67f99ce + c34fcd9 commit 561ad17
Copy full SHA for 561ad17

File tree

7 files changed

+31
-13
lines changed
Filter options

7 files changed

+31
-13
lines changed

‎src/Symfony/Component/Config/Definition/BaseNode.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Config/Definition/BaseNode.php
+1-4Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,7 @@ abstract class BaseNode implements NodeInterface
4747
*/
4848
public function __construct(?string $name, NodeInterface $parent = null, string $pathSeparator = self::DEFAULT_PATH_SEPARATOR)
4949
{
50-
if (null === $name) {
51-
$name = '';
52-
}
53-
if (false !== strpos($name, $pathSeparator)) {
50+
if (false !== strpos($name = (string) $name, $pathSeparator)) {
5451
throw new \InvalidArgumentException('The name must not contain "'.$pathSeparator.'".');
5552
}
5653

‎src/Symfony/Component/Config/Definition/Builder/NodeDefinition.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Config/Definition/Builder/NodeDefinition.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ abstract class NodeDefinition implements NodeParentInterface
4141
public function __construct(?string $name, NodeParentInterface $parent = null)
4242
{
4343
$this->parent = $parent;
44-
$this->name = $name ?? '';
44+
$this->name = $name;
4545
}
4646

4747
/**

‎src/Symfony/Component/Form/FormConfigBuilder.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Form/FormConfigBuilder.php
+5-3Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ public function __construct(?string $name, ?string $dataClass, EventDispatcherIn
123123
throw new InvalidArgumentException(sprintf('Class "%s" not found. Is the "data_class" form option set correctly?', $dataClass));
124124
}
125125

126-
$this->name = $name ?? '';
126+
$this->name = (string) $name;
127127
$this->dataClass = $dataClass;
128128
$this->dispatcher = $dispatcher;
129129
$this->options = $options;
@@ -772,7 +772,7 @@ public function getFormConfig()
772772
* @throws UnexpectedTypeException if the name is not a string or an integer
773773
* @throws InvalidArgumentException if the name contains invalid characters
774774
*
775-
* @internal since Symfony 4.4
775+
* @internal since Symfony 4.4, to be removed in 5.0
776776
*/
777777
public static function validateName($name)
778778
{
@@ -794,8 +794,10 @@ public static function validateName($name)
794794
* * starts with a letter, digit or underscore
795795
* * contains only letters, digits, numbers, underscores ("_"),
796796
* hyphens ("-") and colons (":")
797+
*
798+
* @final since Symfony 4.4
797799
*/
798-
final public static function isValidName(?string $name): bool
800+
public static function isValidName(?string $name): bool
799801
{
800802
return '' === $name || null === $name || preg_match('/^[a-zA-Z0-9_][a-zA-Z0-9_\-:]*$/D', $name);
801803
}

‎src/Symfony/Component/Form/FormError.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Form/FormError.php
+6-1Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,13 @@ class FormError
4747
*
4848
* @see \Symfony\Component\Translation\Translator
4949
*/
50-
public function __construct(string $message, string $messageTemplate = null, array $messageParameters = [], int $messagePluralization = null, $cause = null)
50+
public function __construct(?string $message, string $messageTemplate = null, array $messageParameters = [], int $messagePluralization = null, $cause = null)
5151
{
52+
if (null === $message) {
53+
@trigger_error(sprintf('Passing a null message when instantiating a "%s" is deprecated since Symfony 4.4.', __CLASS__), E_USER_DEPRECATED);
54+
$message = '';
55+
}
56+
5257
$this->message = $message;
5358
$this->messageTemplate = $messageTemplate ?: $message;
5459
$this->messageParameters = $messageParameters;

‎src/Symfony/Component/HttpFoundation/RedirectResponse.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/HttpFoundation/RedirectResponse.php
+7-2Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,13 @@ class RedirectResponse extends Response
3232
*
3333
* @see http://tools.ietf.org/html/rfc2616#section-10.3
3434
*/
35-
public function __construct(string $url, int $status = 302, array $headers = [])
35+
public function __construct(?string $url, int $status = 302, array $headers = [])
3636
{
37+
if (null === $url) {
38+
@trigger_error(sprintf('Passing a null url when instantiating a "%s" is deprecated since Symfony 4.4.', __CLASS__), E_USER_DEPRECATED);
39+
$url = '';
40+
}
41+
3742
parent::__construct('', $status, $headers);
3843

3944
$this->setTargetUrl($url);
@@ -82,7 +87,7 @@ public function getTargetUrl()
8287
*/
8388
public function setTargetUrl($url)
8489
{
85-
if ('' == $url) {
90+
if ('' === ($url ?? '')) {
8691
throw new \InvalidArgumentException('Cannot redirect to an empty URL.');
8792
}
8893

‎src/Symfony/Component/Validator/ConstraintViolation.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Validator/ConstraintViolation.php
+6-1Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,13 @@ class ConstraintViolation implements ConstraintViolationInterface
4949
* caused the violation
5050
* @param mixed $cause The cause of the violation
5151
*/
52-
public function __construct(string $message, ?string $messageTemplate, array $parameters, $root, ?string $propertyPath, $invalidValue, int $plural = null, $code = null, Constraint $constraint = null, $cause = null)
52+
public function __construct(?string $message, ?string $messageTemplate, array $parameters, $root, ?string $propertyPath, $invalidValue, int $plural = null, $code = null, Constraint $constraint = null, $cause = null)
5353
{
54+
if (null === $message) {
55+
@trigger_error(sprintf('Passing a null message when instantiating a "%s" is deprecated since Symfony 4.4.', __CLASS__), E_USER_DEPRECATED);
56+
$message = '';
57+
}
58+
5459
$this->message = $message;
5560
$this->messageTemplate = $messageTemplate;
5661
$this->parameters = $parameters;

‎src/Symfony/Component/Validator/Violation/ConstraintViolationBuilder.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Validator/Violation/ConstraintViolationBuilder.php
+5-1Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,12 @@ class ConstraintViolationBuilder implements ConstraintViolationBuilderInterface
4747
/**
4848
* @param TranslatorInterface $translator
4949
*/
50-
public function __construct(ConstraintViolationList $violations, Constraint $constraint, string $message, array $parameters, $root, string $propertyPath, $invalidValue, $translator, string $translationDomain = null)
50+
public function __construct(ConstraintViolationList $violations, Constraint $constraint, ?string $message, array $parameters, $root, string $propertyPath, $invalidValue, $translator, string $translationDomain = null)
5151
{
52+
if (null === $message) {
53+
@trigger_error(sprintf('Passing a null message when instantiating a "%s" is deprecated since Symfony 4.4.', __CLASS__), E_USER_DEPRECATED);
54+
$message = '';
55+
}
5256
if (!$translator instanceof LegacyTranslatorInterface && !$translator instanceof TranslatorInterface) {
5357
throw new \TypeError(sprintf('Argument 8 passed to %s() must be an instance of %s, %s given.', __METHOD__, TranslatorInterface::class, \is_object($translator) ? \get_class($translator) : \gettype($translator)));
5458
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.