Skip to content

Commit 7d0795d

Browse files
Merge branch '3.4' into 4.3
* 3.4: Fix return statements [TwigBridge] add missing dep Add false type to ChoiceListFactoryInterface::createView $label argument
2 parents cca22c4 + e6b52cc commit 7d0795d

File tree

58 files changed

+102
-104
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+102
-104
lines changed

src/Symfony/Bridge/Doctrine/Form/ChoiceList/IdReader.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ public function isIntId(): bool
9191
public function getIdValue($object)
9292
{
9393
if (!$object) {
94-
return;
94+
return null;
9595
}
9696

9797
if (!$this->om->contains($object)) {

src/Symfony/Bridge/Doctrine/Form/DoctrineOrmTypeGuesser.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ public function guessRequired($class, $property)
9999
$classMetadatas = $this->getMetadata($class);
100100

101101
if (!$classMetadatas) {
102-
return;
102+
return null;
103103
}
104104

105105
/** @var ClassMetadataInfo $classMetadata */

src/Symfony/Bridge/Twig/AppVariable.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ public function getToken()
6868
/**
6969
* Returns the current user.
7070
*
71-
* @return mixed
71+
* @return object|null
7272
*
7373
* @see TokenInterface::getUser()
7474
*/
@@ -79,7 +79,7 @@ public function getUser()
7979
}
8080

8181
if (!$token = $tokenStorage->getToken()) {
82-
return;
82+
return null;
8383
}
8484

8585
$user = $token->getUser();

src/Symfony/Bridge/Twig/composer.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
},
2323
"require-dev": {
2424
"egulias/email-validator": "^2.0",
25+
"fig/link-util": "^1.0",
2526
"symfony/asset": "~3.4|~4.0",
2627
"symfony/dependency-injection": "~3.4|~4.0",
2728
"symfony/finder": "~3.4|~4.0",

src/Symfony/Bundle/FrameworkBundle/Controller/ControllerTrait.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,7 @@ protected function getDoctrine(): ManagerRegistry
351351
/**
352352
* Get a user from the Security Token Storage.
353353
*
354-
* @return mixed
354+
* @return object|null
355355
*
356356
* @throws \LogicException If SecurityBundle is not available
357357
*
@@ -366,12 +366,12 @@ protected function getUser()
366366
}
367367

368368
if (null === $token = $this->container->get('security.token_storage')->getToken()) {
369-
return;
369+
return null;
370370
}
371371

372372
if (!\is_object($user = $token->getUser())) {
373373
// e.g. anonymous authentication
374-
return;
374+
return null;
375375
}
376376

377377
return $user;

src/Symfony/Bundle/FrameworkBundle/Templating/GlobalVariables.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public function __construct(ContainerInterface $container)
4040
public function getToken()
4141
{
4242
if (!$this->container->has('security.token_storage')) {
43-
return;
43+
return null;
4444
}
4545

4646
return $this->container->get('security.token_storage')->getToken();

src/Symfony/Bundle/FrameworkBundle/Templating/Helper/CodeHelper.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ public function fileExcerpt($file, $line)
126126

127127
// Check if the file is an application/octet-stream (eg. Phar file) because highlight_file cannot parse these files
128128
if ('application/octet-stream' === $finfo->file($file, FILEINFO_MIME_TYPE)) {
129-
return;
129+
return '';
130130
}
131131
}
132132

src/Symfony/Component/BrowserKit/Client.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -533,7 +533,7 @@ protected function filterResponse($response)
533533
protected function createCrawlerFromContent($uri, $content, $type)
534534
{
535535
if (!class_exists('Symfony\Component\DomCrawler\Crawler')) {
536-
return;
536+
return null;
537537
}
538538

539539
$crawler = new Crawler(null, $uri);

src/Symfony/Component/Config/Util/XmlUtils.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ public static function phpize($value)
219219

220220
switch (true) {
221221
case 'null' === $lowercaseValue:
222-
return;
222+
return null;
223223
case ctype_digit($value):
224224
$raw = $value;
225225
$cast = (int) $value;

src/Symfony/Component/Console/Application.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -472,7 +472,7 @@ public function add(Command $command)
472472
if (!$command->isEnabled()) {
473473
$command->setApplication(null);
474474

475-
return;
475+
return null;
476476
}
477477

478478
if (null === $command->getDefinition()) {

src/Symfony/Component/CssSelector/Parser/TokenStream.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ public function getNextIdentifierOrStar()
155155
}
156156

157157
if ($next->isDelimiter(['*'])) {
158-
return;
158+
return null;
159159
}
160160

161161
throw SyntaxErrorException::unexpectedToken('identifier or "*"', $next);

src/Symfony/Component/Debug/ErrorHandler.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -443,7 +443,7 @@ public function handleError($type, $message, $file, $line)
443443
self::$silencedErrorCache[$id][$message] = $errorAsException;
444444
}
445445
if (null === $lightTrace) {
446-
return;
446+
return true;
447447
}
448448
} else {
449449
$errorAsException = new \ErrorException($logMessage, 0, $type, $file, $line);

src/Symfony/Component/Debug/FatalErrorHandler/ClassNotFoundFatalErrorHandler.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,11 @@ public function handleError(array $error, FatalErrorException $exception)
3333
$notFoundSuffix = '\' not found';
3434
$notFoundSuffixLen = \strlen($notFoundSuffix);
3535
if ($notFoundSuffixLen > $messageLen) {
36-
return;
36+
return null;
3737
}
3838

3939
if (0 !== substr_compare($error['message'], $notFoundSuffix, -$notFoundSuffixLen)) {
40-
return;
40+
return null;
4141
}
4242

4343
foreach (['class', 'interface', 'trait'] as $typeName) {

src/Symfony/Component/Debug/FatalErrorHandler/UndefinedFunctionFatalErrorHandler.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,17 +30,17 @@ public function handleError(array $error, FatalErrorException $exception)
3030
$notFoundSuffix = '()';
3131
$notFoundSuffixLen = \strlen($notFoundSuffix);
3232
if ($notFoundSuffixLen > $messageLen) {
33-
return;
33+
return null;
3434
}
3535

3636
if (0 !== substr_compare($error['message'], $notFoundSuffix, -$notFoundSuffixLen)) {
37-
return;
37+
return null;
3838
}
3939

4040
$prefix = 'Call to undefined function ';
4141
$prefixLen = \strlen($prefix);
4242
if (0 !== strpos($error['message'], $prefix)) {
43-
return;
43+
return null;
4444
}
4545

4646
$fullyQualifiedFunctionName = substr($error['message'], $prefixLen, -$notFoundSuffixLen);

src/Symfony/Component/Debug/FatalErrorHandler/UndefinedMethodFatalErrorHandler.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public function handleError(array $error, FatalErrorException $exception)
2828
{
2929
preg_match('/^Call to undefined method (.*)::(.*)\(\)$/', $error['message'], $matches);
3030
if (!$matches) {
31-
return;
31+
return null;
3232
}
3333

3434
$className = $matches[1];

src/Symfony/Component/DependencyInjection/LazyProxy/ProxyHelper.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public static function getTypeHint(\ReflectionFunctionAbstract $r, \ReflectionPa
2929
$type = $r->getReturnType();
3030
}
3131
if (!$type) {
32-
return;
32+
return null;
3333
}
3434
if (!\is_string($type)) {
3535
$name = $type->getName();
@@ -45,7 +45,7 @@ public static function getTypeHint(\ReflectionFunctionAbstract $r, \ReflectionPa
4545
return $prefix.$name;
4646
}
4747
if (!$r instanceof \ReflectionMethod) {
48-
return;
48+
return null;
4949
}
5050
if ('self' === $lcName) {
5151
return $prefix.$r->getDeclaringClass()->name;

src/Symfony/Component/Filesystem/Filesystem.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -414,12 +414,12 @@ private function linkException($origin, $target, $linkType)
414414
public function readlink($path, $canonicalize = false)
415415
{
416416
if (!$canonicalize && !is_link($path)) {
417-
return;
417+
return null;
418418
}
419419

420420
if ($canonicalize) {
421421
if (!$this->exists($path)) {
422-
return;
422+
return null;
423423
}
424424

425425
if ('\\' === \DIRECTORY_SEPARATOR) {

src/Symfony/Component/Form/ChoiceList/Factory/ChoiceListFactoryInterface.php

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -78,14 +78,11 @@ public function createListFromLoader(ChoiceLoaderInterface $loader, $value = nul
7878
* attributes that should be added to the respective choice.
7979
*
8080
* @param array|callable|null $preferredChoices The preferred choices
81-
* @param callable|null $label The callable generating the
82-
* choice labels
83-
* @param callable|null $index The callable generating the
84-
* view indices
85-
* @param callable|null $groupBy The callable generating the
86-
* group names
87-
* @param array|callable|null $attr The callable generating the
88-
* HTML attributes
81+
* @param callable|false|null $label The callable generating the choice labels;
82+
* pass false to discard the label
83+
* @param callable|null $index The callable generating the view indices
84+
* @param callable|null $groupBy The callable generating the group names
85+
* @param array|callable|null $attr The callable generating the HTML attributes
8986
*
9087
* @return ChoiceListView The choice list view
9188
*/

src/Symfony/Component/Form/Extension/Core/DataTransformer/BooleanToStringTransformer.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,14 +45,14 @@ public function __construct(string $trueValue, array $falseValues = [null])
4545
*
4646
* @param bool $value Boolean value
4747
*
48-
* @return string String value
48+
* @return string|null String value
4949
*
5050
* @throws TransformationFailedException if the given value is not a Boolean
5151
*/
5252
public function transform($value)
5353
{
5454
if (null === $value) {
55-
return;
55+
return null;
5656
}
5757

5858
if (!\is_bool($value)) {

src/Symfony/Component/Form/Extension/Core/DataTransformer/DateIntervalToArrayTransformer.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -106,21 +106,21 @@ public function transform($dateInterval)
106106
*
107107
* @param array $value Interval array
108108
*
109-
* @return \DateInterval Normalized date interval
109+
* @return \DateInterval|null Normalized date interval
110110
*
111111
* @throws UnexpectedTypeException if the given value is not an array
112112
* @throws TransformationFailedException if the value could not be transformed
113113
*/
114114
public function reverseTransform($value)
115115
{
116116
if (null === $value) {
117-
return;
117+
return null;
118118
}
119119
if (!\is_array($value)) {
120120
throw new UnexpectedTypeException($value, 'array');
121121
}
122122
if ('' === implode('', $value)) {
123-
return;
123+
return null;
124124
}
125125
$emptyFields = [];
126126
foreach ($this->fields as $field) {

src/Symfony/Component/Form/Extension/Core/DataTransformer/DateIntervalToStringTransformer.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,21 +62,21 @@ public function transform($value)
6262
*
6363
* @param string $value An ISO 8601 or date string like date interval presentation
6464
*
65-
* @return \DateInterval An instance of \DateInterval
65+
* @return \DateInterval|null An instance of \DateInterval
6666
*
6767
* @throws UnexpectedTypeException if the given value is not a string
6868
* @throws TransformationFailedException if the date interval could not be parsed
6969
*/
7070
public function reverseTransform($value)
7171
{
7272
if (null === $value) {
73-
return;
73+
return null;
7474
}
7575
if (!\is_string($value)) {
7676
throw new UnexpectedTypeException($value, 'string');
7777
}
7878
if ('' === $value) {
79-
return;
79+
return null;
8080
}
8181
if (!$this->isISO8601($value)) {
8282
throw new TransformationFailedException('Non ISO 8601 date strings are not supported yet');

src/Symfony/Component/Form/Extension/Core/DataTransformer/DateTimeToArrayTransformer.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -103,23 +103,23 @@ public function transform($dateTime)
103103
*
104104
* @param array $value Localized date
105105
*
106-
* @return \DateTime Normalized date
106+
* @return \DateTime|null Normalized date
107107
*
108108
* @throws TransformationFailedException If the given value is not an array,
109109
* if the value could not be transformed
110110
*/
111111
public function reverseTransform($value)
112112
{
113113
if (null === $value) {
114-
return;
114+
return null;
115115
}
116116

117117
if (!\is_array($value)) {
118118
throw new TransformationFailedException('Expected an array.');
119119
}
120120

121121
if ('' === implode('', $value)) {
122-
return;
122+
return null;
123123
}
124124

125125
$emptyFields = [];

src/Symfony/Component/Form/Extension/Core/DataTransformer/DateTimeToHtml5LocalDateTimeTransformer.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ public function transform($dateTime)
6666
*
6767
* @param string $dateTimeLocal Formatted string
6868
*
69-
* @return \DateTime Normalized date
69+
* @return \DateTime|null Normalized date
7070
*
7171
* @throws TransformationFailedException If the given value is not a string,
7272
* if the value could not be transformed
@@ -78,7 +78,7 @@ public function reverseTransform($dateTimeLocal)
7878
}
7979

8080
if ('' === $dateTimeLocal) {
81-
return;
81+
return null;
8282
}
8383

8484
// to maintain backwards compatibility we do not strictly validate the submitted date

src/Symfony/Component/Form/Extension/Core/DataTransformer/DateTimeToLocalizedStringTransformer.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ public function transform($dateTime)
9999
*
100100
* @param string|array $value Localized date string/array
101101
*
102-
* @return \DateTime Normalized date
102+
* @return \DateTime|null Normalized date
103103
*
104104
* @throws TransformationFailedException if the given value is not a string,
105105
* if the date could not be parsed
@@ -111,7 +111,7 @@ public function reverseTransform($value)
111111
}
112112

113113
if ('' === $value) {
114-
return;
114+
return null;
115115
}
116116

117117
// date-only patterns require parsing to be done in UTC, as midnight might not exist in the local timezone due

src/Symfony/Component/Form/Extension/Core/DataTransformer/DateTimeToRfc3339Transformer.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ public function transform($dateTime)
5353
*
5454
* @param string $rfc3339 Formatted string
5555
*
56-
* @return \DateTime Normalized date
56+
* @return \DateTime|null Normalized date
5757
*
5858
* @throws TransformationFailedException If the given value is not a string,
5959
* if the value could not be transformed
@@ -65,7 +65,7 @@ public function reverseTransform($rfc3339)
6565
}
6666

6767
if ('' === $rfc3339) {
68-
return;
68+
return null;
6969
}
7070

7171
if (!preg_match('/^(\d{4})-(\d{2})-(\d{2})T\d{2}:\d{2}(?::\d{2})?(?:\.\d+)?(?:Z|(?:(?:\+|-)\d{2}:\d{2}))$/', $rfc3339, $matches)) {

src/Symfony/Component/Form/Extension/Core/DataTransformer/DateTimeToStringTransformer.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,15 +101,15 @@ public function transform($dateTime)
101101
*
102102
* @param string $value A value as produced by PHP's date() function
103103
*
104-
* @return \DateTime An instance of \DateTime
104+
* @return \DateTime|null An instance of \DateTime
105105
*
106106
* @throws TransformationFailedException If the given value is not a string,
107107
* or could not be transformed
108108
*/
109109
public function reverseTransform($value)
110110
{
111111
if (empty($value)) {
112-
return;
112+
return null;
113113
}
114114

115115
if (!\is_string($value)) {

0 commit comments

Comments
 (0)