8000 Fix inconsistent return points by derrabus · Pull Request #33254 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

Fix inconsistent return points #33254

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 20, 2019
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
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,8 @@ public function getTypes($class, $property, array $context = [])
return $builtinType ? [new Type($builtinType, $nullable)] : null;
}
}

return null;
}

/**
Expand Down
6 changes: 5 additions & 1 deletion src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,8 @@ public static function collectDeprecations($outputFile)
}

$deprecations[] = [error_reporting(), $msg, $file];

return null;
});

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

$deprecation = new Deprecation($msg, debug_backtrace(), $file);
if ($deprecation->isMuted()) {
return;
return null;
}
$group = 'other';

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

++$this->deprecations[$group.'Count'];

return null;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,8 @@ protected function execute(InputInterface $input, OutputInterface $output)
}

$io->newLine();

return null;
}

private function getFileLink(string $class): string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,14 @@ public function getName()

public function __call($method, $arguments = [])
{
if (null !== $this->stopwatch) {
if (method_exists($this->stopwatch, $method)) {
return $this->stopwatch->{$method}(...$arguments);
}
if (null === $this->stopwatch) {
return null;
}

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

throw new \BadMethodCallException(sprintf('Method "%s" of Stopwatch does not exist', $method));
}
}
8 changes: 5 additions & 3 deletions src/Symfony/Bundle/WebServerBundle/WebServerConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ public function getDisplayAddress()
return gethostbyname($localHostname).':'.$this->port;
}

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

Expand All @@ -126,14 +126,16 @@ private function findFrontController($documentRoot, $env)
return $fileName;
}
}

return null;
}

private function getFrontControllerFileNames($env)
private function getFrontControllerFileNames(string $env): array
{
return ['app_'.$env.'.php', 'app.php', 'index_'.$env.'.php', 'index.php'];
}

private function findBestPort()
private function findBestPort(): int
{
$port = 8000;
while (false !== $fp = @fsockopen($this->hostname, $port, $errno, $errstr, 1)) {
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Component/Cache/Traits/ArrayTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ private function freeze($value, $key)
$message = sprintf('Failed to save key "{key}" of type %s: %s', $type, $e->getMessage());
CacheItem::log($this->logger, $message, ['key' => $key, 'exception' => $e]);

return;
return null;
}
// Keep value serialized if it contains any objects or any internal references
if ('C' === $serialized[0] || 'O' === $serialized[0] || preg_match('/;[OCRr]:[1-9]/', $serialized)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,9 @@ public function addContent(string $input)
protected function doWrite($message, $newline)
{
if (!$this->isDecorated()) {
return parent::doWrite($message, $newline);
parent::doWrite($message, $newline);

return;
}

$erasedContent = $this->popStreamContentUntilCurrentSection();
Expand Down
4 changes: 3 additions & 1 deletion src/Symfony/Component/Debug/ErrorHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -576,7 +576,9 @@ public function handleException($exception, array $error = null)
$this->exceptionHandler = null;
try {
if (null !== $exceptionHandler) {
return $exceptionHandler($exception);
$exceptionHandler($exception);

return;
}
$handlerException = $handlerException ?: $exception;
} catch (\Throwable $handlerException) {
Expand Down
2 changes: 2 additions & 0 deletions src/Symfony/Component/DependencyInjection/Container.php
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,8 @@ private function make(string $id, int $invalidBehavior)

throw new ServiceNotFoundException($id, null, null, $alternatives);
}

return null;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -592,7 +592,7 @@ private function doGet($id, $invalidBehavior = ContainerInterface::EXCEPTION_ON_
$definition = $this->getDefinition($id);
} catch (ServiceNotFoundException $e) {
if (ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE < $invalidBehavior) {
return;
return null;
}

throw $e;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ public function getConfiguration(array $config, ContainerBuilder $container)
return null;
}

final protected function processConfiguration(ConfigurationInterface $configuration, array $configs)
final protected function processConfiguration(ConfigurationInterface $configuration, array $configs): array
{
$processor = new Processor();

Expand Down
10 changes: 2 additions & 8 deletions src/Symfony/Component/DomCrawler/Crawler.php
Original file line number Diff line number Diff line change
Expand Up @@ -1063,9 +1063,7 @@ private function relativize(string $xpath): string
*/
public function getNode($position)
{
if (isset($this->nodes[$position])) {
return $this->nodes[$position];
}
return isset($this->nodes[$position]) ? $this->nodes[$position] : null;
}

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

if ($node = $namespaces->item(0)) {
return $node->nodeValue;
}

return null;
return ($node = $namespaces->item(0)) ? $node->nodeValue : null;
}

private function findNamespacePrefixes(string $xpath): array
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public function __construct(bool $multiple = false)
public function transform($intlTimeZone)
{
if (null === $intlTimeZone) {
return;
return null;
}

if ($this->multiple) {
Expand Down
2 changes: 2 additions & 0 deletions src/Symfony/Component/HttpClient/Response/CurlResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,8 @@ public function __construct(CurlClientState $multi, $ch, array $options = null,

return 1; // Abort the request
}

return null;
});
}

Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Component/HttpFoundation/Response.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ class Response
const HTTP_NETWORK_AUTHENTICATION_REQUIRED = 511; // RFC6585

/**
* @var \Symfony\Component\HttpFoundation\ResponseHeaderBag
* @var ResponseHeaderBag
*/
public $headers;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public function warmUp($cacheDir)
if (isset($collectedLogs[$message])) {
++$collectedLogs[$message]['count'];

return;
return null;
}

$backtrace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 3);
Expand All @@ -80,6 +80,8 @@ public function warmUp($cacheDir)
'trace' => $backtrace,
'count' => 1,
];

return null;
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public function createArgumentMetadata($controller)
private function getType(\ReflectionParameter $parameter, \ReflectionFunctionAbstract $function)
{
if (!$type = $parameter->getType()) {
return;
return null;
}
$name = $type->getName();
$lcName = strtolower($name);
Expand All @@ -57,13 +57,15 @@ private function getType(\ReflectionParameter $parameter, \ReflectionFunctionAbs
return $name;
}
if (!$function instanceof \ReflectionMethod) {
return;
return null;
}
if ('self' === $lcName) {
return $function->getDeclaringClass()->name;
}
if ($parent = $function->getDeclaringClass()->getParentClass()) {
return $parent->name;
}

return null;
}
}
2 changes: 2 additions & 0 deletions src/Symfony/Component/HttpKernel/Debug/FileLinkFormatter.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,5 +101,7 @@ private function getFileLinkFormat()
];
}
}

return null;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -84,13 +84,13 @@ protected function generateDataForLocale(BundleEntryReaderInterface $reader, $te
// Don't generate aliases, as they are resolved during runtime
// Unless an alias is needed as fallback for de-duplication purposes
if (isset($this->localeAliases[$displayLocale]) && !$this->generatingFallback) {
return;
return null;
}

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

if (!isset($localeBundle['zoneStrings']) || null === $localeBundle['zoneStrings']) {
return;
return null;
}

$data = [
Expand All @@ -115,7 +115,7 @@ protected function generateDataForLocale(BundleEntryReaderInterface $reader, $te
$data['Meta'] = array_diff($data['Meta'], $fallback['Meta']);
}
if (!$data['Names'] && !$data['Meta']) {
return;
return null;
}

$this->zoneIds = array_merge($this->zoneIds, array_keys($data['Names']));
Expand Down
6 changes: 1 addition & 5 deletions src/Symfony/Component/Intl/Locale.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,11 +104,7 @@ public static function getFallback($locale): ?string

// Don't return default fallback for "root", "meta" or others
// Normal locales have two or three letters
if (\strlen($locale) < 4) {
return self::$defaultFallback;
}

return null;
return \strlen($locale) < 4 ? self::$defaultFallback : null;
}

/**
Expand Down
12 changes: 4 additions & 8 deletions src/Symfony/Component/Process/Process.php
Original file line number Diff line number Diff line change
Expand Up @@ -1304,25 +1304,21 @@ private function getDescriptors(): array
protected function buildCallback(callable $callback = null)
{
if ($this->outputDisabled) {
return function ($type, $data) use ($callback) {
if (null !== $callback) {
return $callback($type, $data);
}
return function ($type, $data) use ($callback): bool {
return null !== $callback && $callback($type, $data);
};
}

$out = self::OUT;

return function ($type, $data) use ($callback, $out) {
return function ($type, $data) use ($callback, $out): bool {
if ($out == $type) {
$this->addOutput($data);
} else {
$this->addErrorOutput($data);
}

if (null !== $callback) {
return $callback($type, $data);
}
return null !== $callback && $callback($type, $data);
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,8 @@ public function getTypes($class, $property, array $context = [])
if ($fromDefaultValue = $this->extractFromDefaultValue($class, $property)) {
return $fromDefaultValue;
}

return null;
}

/**
Expand Down
6 changes: 3 additions & 3 deletions src/Symfony/Component/Yaml/Inline.php
Original file line number Diff line number Diff line change
Expand Up @@ -566,7 +566,7 @@ private static function evaluateScalar(string $scalar, int $flags, array $refere
case 'null' === $scalarLower:
case '' === $scalar:
case '~' === $scalar:
return;
return null;
case 'true' === $scalarLower:
return true;
case 'false' === $scalarLower:
Expand All @@ -586,7 +586,7 @@ private static function evaluateScalar(string $scalar, int $flags, array $refere
throw new ParseException('Object support when parsing a YAML file has been disabled.', self::$parsedLineNumber + 1, $scalar, self::$parsedFilename);
}

return;
return null;
case 0 === strpos($scalar, '!php/const'):
if (self::$constantSupport) {
$i = 0;
Expand All @@ -600,7 +600,7 @@ private static function evaluateScalar(string $scalar, int $flags, array $refere
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);
}

return;
return null;
case 0 === strpos($scalar, '!!float '):
return (float) substr($scalar, 8);
case 0 === strpos($scalar, '!!binary '):
Expand Down
2 changes: 0 additions & 2 deletions src/Symfony/Component/Yaml/Parser.php
Original file line number Diff line number Diff line change
Expand Up @@ -739,8 +739,6 @@ private function parseValue(string $value, int $flags, string $context)
* @param string $style The style indicator that was used to begin this block scalar (| or >)
* @param string $chomping The chomping indicator that was used to begin this block scalar (+ or -)
* @param int $indentation The indentation indicator that was used to begin this block scalar
*
* @return string The text value
*/
private function parseBlockScalar(string $style, string $chomping = '', int $indentation = 0): string
{
Expand Down
2 changes: 2 additions & 0 deletions src/Symfony/Contracts/Service/ServiceSubscriberTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,5 +57,7 @@ public function setContainer(ContainerInterface $container)
if (\is_callable(['parent', __FUNCTION__])) {
return parent::setContainer($container);
}

return null;
}
}
0