8000 Fix inconsistent return points. · symfony/symfony@c26c535 · GitHub
[go: up one dir, main page]

Skip to content

Commit c26c535

Browse files
derrabusnicolas-grekas
authored andcommitted
Fix inconsistent return points.
1 parent c1e0c1b commit c26c535

File tree

25 files changed

+62
-48
lines changed

25 files changed

+62
-48
lines changed

src/Symfony/Bridge/Doctrine/PropertyInfo/DoctrineExtractor.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,8 @@ public function getTypes($class, $property, array $context = [])
168168
return $builtinType ? [new Type($builtinType, $nullable)] : null;
169169
}
170170
}
171+
172+
return null;
171173
}
172174

173175
/**

src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,8 @@ public static function collectDeprecations($outputFile)
107107
}
108108

109109
$deprecations[] = [error_reporting(), $msg, $file];
110+
111+
return null;
110112
});
111113

112114
register_shutdown_function(function () use ($outputFile, &$deprecations) {
@@ -125,7 +127,7 @@ public function handleError($type, $msg, $file, $line, $context = [])
125127

126128
$deprecation = new Deprecation($msg, debug_backtrace(), $file);
127129
if ($deprecation->isMuted()) {
128-
return;
130+
return null;
129131
}
130132
$group = 'other';
131133

@@ -164,6 +166,8 @@ public function handleError($type, $msg, $file, $line, $context = [])
164166
}
165167

166168
++$this->deprecations[$group.'Count'];
169+
170+
return null;
167171
}
168172

169173
/**

src/Symfony/Bundle/FrameworkBundle/Command/DebugAutowiringCommand.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,8 @@ protected function execute(InputInterface $input, OutputInterface $output)
145145
}
146146

147147
$io->newLine();
148+
149+
return null;
148150
}
149151

150152
private function getFileLink(string $class): string

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

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,14 @@ public function getName()
3939

4040
public function __call($method, $arguments = [])
4141
{
42-
if (null !== $this->stopwatch) {
43-
if (method_exists($this->stopwatch, $method)) {
44-
return $this->stopwatch->{$method}(...$arguments);
45-
}
42+
if (null === $this->stopwatch) {
43+
return null;
44+
}
4645

47-
throw new \BadMethodCallException(sprintf('Method "%s" of Stopwatch does not exist', $method));
46+
if (method_exists($this->stopwatch, $method)) {
47+
return $this->stopwatch->{$method}(...$arguments);
4848
}
49+
50+
throw new \BadMethodCallException(sprintf('Method "%s" of Stopwatch does not exist', $method));
4951
}
5052
}

src/Symfony/Bundle/WebServerBundle/WebServerConfig.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ public function getDisplayAddress()
117117
return gethostbyname($localHostname).':'.$this->port;
118118
}
119119

120-
private function findFrontController($documentRoot, $env)
120+
private function findFrontController(string $documentRoot, string $env): ?string
121121
{
122122
$fileNames = $this->getFrontControllerFileNames($env);
123123

@@ -126,14 +126,16 @@ private function findFrontController($documentRoot, $env)
126126
return $fileName;
127127
}
128128
}
129+
130+
return null;
129131
}
130132

131-
private function getFrontControllerFileNames($env)
133+
private function getFrontControllerFileNames(string $env): array
132134
{
133135
return ['app_'.$env.'.php', 'app.php', 'index_'.$env.'.php', 'index.php'];
134136
}
135137

136-
private function findBestPort()
138+
private function findBestPort(): int
137139
{
138140
$port = 8000;
139141
while (false !== $fp = @fsockopen($this->hostname, $port, $errno, $errstr, 1)) {

src/Symfony/Component/Cache/Traits/ArrayTrait.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ private function freeze($value, $key)
131131
$message = sprintf('Failed to save key "{key}" of type %s: %s', $type, $e->getMessage());
132132
CacheItem::log($this->logger, $message, ['key' => $key, 'exception' => $e]);
133133

134-
return;
134+
return null;
135135
}
136136
// Keep value serialized if it contains any objects or any internal references
137137
if ('C' === $serialized[0] || 'O' === $serialized[0] || preg_match('/;[OCRr]:[1-9]/', $serialized)) {

src/Symfony/Component/Console/Output/ConsoleSectionOutput.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,9 @@ public function addContent(string $input)
9595
protected function doWrite($message, $newline)
9696
{
9797
if (!$this->isDecorated()) {
98-
return parent::doWrite($message, $newline);
98+
parent::doWrite($message, $newline);
99+
100+
return;
99101
}
100102

101103
$erasedContent = $this->popStreamContentUntilCurrentSection();

src/Symfony/Component/Debug/ErrorHandler.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -576,7 +576,9 @@ public function handleException($exception, array $error = null)
576576
$this->exceptionHandler = null;
577577
try {
578578
if (null !== $exceptionHandler) {
579-
return $exceptionHandler($exception);
579+
$exceptionHandler($exception);
< 10000 div aria-hidden="true" style="left:-2px" class="position-absolute top-0 d-flex user-select-none DiffLineTableCellParts-module__in-progress-comment-indicator--hx3m3">
580+
581+
return;
580582
}
581583
$handlerException = $handlerException ?: $exception;
582584
} catch (\Throwable $handlerException) {

src/Symfony/Component/DependencyInjection/Container.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,8 @@ private function make(string $id, int $invalidBehavior)
276276

277277
throw new ServiceNotFoundException($id, null, null, $alternatives);
278278
}
279+
280+
return null;
279281
}
280282

281283
/**

src/Symfony/Component/DependencyInjection/ContainerBuilder.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -592,7 +592,7 @@ private function doGet($id, $invalidBehavior = ContainerInterface::EXCEPTION_ON_
592592
$definition = $this->getDefinition($id);
593593
} catch (ServiceNotFoundException $e) {
594594
if (ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE < $invalidBehavior) {
595-
return;
595+
return null;
596596
}
597597

598598
throw $e;

src/Symfony/Component/DependencyInjection/Extension/Extension.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ public function getConfiguration(array $config, ContainerBuilder $container)
101101
return null;
102102
}
103103

104-
final protected function processConfiguration(ConfigurationInterface $configuration, array $configs)
104+
final protected function processConfiguration(ConfigurationInterface $configuration, array $configs): array
105105
{
106106
$processor = new Processor();
107107

src/Symfony/Component/DomCrawler/Crawler.php

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1063,9 +1063,7 @@ private function relativize(string $xpath): string
10631063
*/
10641064
public function getNode($position)
10651065
{
1066-
if (isset($this->nodes[$position])) {
1067-
return $this->nodes[$position];
1068-
}
1066+
return isset($this->nodes[$position]) ? $this->nodes[$position] : null;
10691067
}
10701068

10711069
/**
@@ -1180,11 +1178,7 @@ private function discoverNamespace(\DOMXPath $domxpath, string $prefix): ?string
11801178
// ask for one namespace, otherwise we'd get a collection with an item for each node
11811179
$namespaces = $domxpath->query(sprintf('(//namespace::*[name()="%s"])[last()]', $this->defaultNamespacePrefix === $prefix ? '' : $prefix));
11821180

1183-
if ($node = $namespaces->item(0)) {
1184-
return $node->nodeValue;
1185-
}
1186-
1187-
return null;
1181+
return ($node = $namespaces->item(0)) ? $node->nodeValue : null;
11881182
}
11891183

11901184
private function findNamespacePrefixes(string $xpath): array

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public function __construct(bool $multiple = false)
3434
public function transform($intlTimeZone)
3535
{
3636
if (null === $intlTimeZone) {
37-
return;
37+
return null;
3838
}
3939

4040
if ($this->multiple) {

src/Symfony/Component/HttpClient/Response/CurlResponse.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,8 @@ public function __construct(CurlClientState $multi, $ch, array $options = null,
100100

101101
return 1; // Abort the request
102102
}
103+
104+
return null;
103105
});
104106
}
105107

src/Symfony/Component/HttpFoundation/Response.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ class Response
8888
const HTTP_NETWORK_AUTHENTICATION_REQUIRED = 511; // RFC6585
8989

9090
/**
91-
* @var \Symfony\Component\HttpFoundation\ResponseHeaderBag
91+
* @var ResponseHeaderBag
9292
*/
9393
public $headers;
9494

src/Symfony/Component/HttpKernel/CacheWarmer/CacheWarmerAggregate.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public function warmUp($cacheDir)
6060
if (isset($collectedLogs[$message])) {
6161
++$collectedLogs[$message]['count'];
6262

63-
return;
63+
return null;
6464
}
6565

6666
$backtrace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 3);
@@ -80,6 +80,8 @@ public function warmUp($cacheDir)
8080
'trace' => $backtrace,
8181
'count' => 1,
8282
];
83+
84+
return null;
8385
});
8486
}
8587

src/Symfony/Component/HttpKernel/ControllerMetadata/ArgumentMetadataFactory.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ public function createArgumentMetadata($controller)
4848
private function getType(\ReflectionParameter $parameter, \ReflectionFunctionAbstract $function)
4949
{
5050
if (!$type = $parameter->getType()) {
51-
return;
51+
return null;
5252
}
5353
$name = $type->getName();
5454
$lcName = strtolower($name);
@@ -57,13 +57,15 @@ private function getType(\ReflectionParameter $parameter, \ReflectionFunctionAbs
5757
return $name;
5858
}
5959
if (!$function instanceof \ReflectionMethod) {
60-
return;
60+
return null;
6161
}
6262
if ('self' === $lcName) {
6363
return $function->getDeclaringClass()->name;
6464
}
6565
if ($parent = $function->getDeclaringClass()->getParentClass()) {
6666
return $parent->name;
6767
}
68+
69+
return null;
6870
}
6971
}

src/Symfony/Component/HttpKernel/Debug/FileLinkFormatter.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,5 +101,7 @@ private function getFileLinkFormat()
101101
];
102102
}
103103
}
104+
105+
return null;
104106
}
105107
}

src/Symfony/Component/Intl/Data/Generator/TimezoneDataGenerator.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,13 +84,13 @@ protected function generateDataForLocale(BundleEntryReaderInterface $reader, $te
8484
// Don't generate aliases, as they are resolved during runtime
8585
// Unless an alias is needed as fallback for de-duplication purposes
8686
if (isset($this->localeAliases[$displayLocale]) && !$this->generatingFallback) {
87-
return;
87+
return null;
8888
}
8989

9090
$localeBundle = $reader->read($tempDir, $displayLocale);
9191

9292
if (!isset($localeBundle['zoneStrings']) || null === $localeBundle['zoneStrings']) {
93-
return;
93+
return null;
9494
}
9595

9696
$data = [
@@ -115,7 +115,7 @@ protected function generateDataForLocale(BundleEntryReaderInterface $reader, $te
115115
$data['Meta'] = array_diff($data['Meta'], $fallback['Meta']);
116116
}
117117
if (!$data['Names'] && !$data['Meta']) {
118-
return;
118+
return null;
119119
}
120120

121121
$this->zoneIds = array_merge($this->zoneIds, array_keys($data['Names']));

src/Symfony/Component/Intl/Locale.php

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -104,11 +104,7 @@ public static function getFallback($locale): ?string
104104

105105
// Don't return default fallback for "root", "meta" or others
106106
// Normal locales have two or three letters
107-
if (\strlen($locale) < 4) {
108-
return self::$defaultFallback;
109-
}
110-
111-
return null;
107+
return \strlen($locale) < 4 ? self::$defaultFallback : null;
112108
}
113109

114110
/**

src/Symfony/Component/Process/Process.php

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1304,25 +1304,21 @@ private function getDescriptors(): array
13041304
protected function buildCallback(callable $callback = null)
13051305
{
13061306
if ($this->outputDisabled) {
1307-
return function ($type, $data) use ($callback) {
1308-
if (null !== $callback) {
1309-
return $callback($type, $data);
1310-
}
1307+
return function ($type, $data) use ($callback): bool {
1308+
return null !== $callback && $callback($type, $data);
13111309
};
13121310
}
13131311

13141312
$out = self::OUT;
13151313

1316-
return function ($type, $data) use ($callback, $out) {
1314+
return function ($type, $data) use ($callback, $out): bool {
13171315
if ($out == $type) {
13181316
$this->addOutput($data);
13191317
} else {
13201318
$this->addErrorOutput($data);
13211319
}
13221320

1323-
if (null !== $callback) {
1324-
return $callback($type, $data);
1325-
}
1321+
return null !== $callback && $callback($type, $data);
13261322
};
13271323
}
13281324

src/Symfony/Component/PropertyInfo/Extractor/ReflectionExtractor.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,8 @@ public function getTypes($class, $property, array $context = [])
151151
if ($fromDefaultValue = $this->extractFromDefaultValue($class, $property)) {
152152
return $fromDefaultValue;
153153
}
154+
155+
return null;
154156
}
155157

156158
/**

src/Symfony/Component/Yaml/Inline.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -566,7 +566,7 @@ private static function evaluateScalar(string $scalar, int $flags, array $refere
566566
case 'null' === $scalarLower:
567567
case '' === $scalar:
568568
case '~' === $scalar:
569-
return;
569+
return null;
570570
case 'true' === $scalarLower:
571571
return true;
572572
case 'false' === $scalarLower:
@@ -586,7 +586,7 @@ private static function evaluateScalar(string $scalar, int $flags, array $refere
586586
throw new ParseException('Object support when parsing a YAML file has been disabled.', self::$parsedLineNumber + 1, $scalar, self::$parsedFilename);
587587
}
588588

589-
return;
589+
return null;
590590
case 0 === strpos($scalar, '!php/const'):
591591
if (self::$constantSupport) {
592592
$i = 0;
@@ -600,7 +600,7 @@ private static function evaluateScalar(string $scalar, int $flags, array $refere
600600
throw new ParseException(sprintf('The string "%s" could not be parsed as a constant. Have you forgotten to pass the "Yaml::PARSE_CONSTANT" flag to the parser?', $scalar), self::$parsedLineNumber + 1, $scalar, self::$parsedFilename);
601601
}
602602

603-
return;
603+
return null;
604604
case 0 === strpos($scalar, '!!float '):
605605
return (float) substr($scalar, 8);
606606
case 0 === strpos($scalar, '!!binary '):

src/Symfony/Component/Yaml/Parser.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -739,8 +739,6 @@ private function parseValue(string $value, int $flags, string $context)
739739
* @param string $style The style indicator that was used to begin this block scalar (| or >)
740740
* @param string $chomping The chomping indicator that was used to begin this block scalar (+ or -)
741741
* @param int $indentation The indentation indicator that was used to begin this block scalar
742-
*
743-
* @return string The text value
744742
*/
745743
private function parseBlockScalar(string $style, string $chomping = '', int $indentation = 0): string
746744
{

src/Symfony/Contracts/Service/ServiceSubscriberTrait.php

Original file line numberDiff line numberDiff line change
@@ -57,5 +57,7 @@ public function setContainer(ContainerInterface $container)
5757
if (\is_callable(['parent', __FUNCTION__])) {
5858
return parent::setContainer($container);
5959
}
60+
61+
return null;
6062
}
6163
}

0 commit comments

Comments
 (0)
0