Fix inconsistent return points.

This commit is contained in:
Alexander M. Turek 2019-08-19 23:30:37 +02:00 committed by Nicolas Grekas
parent c1e0c1b05f
commit c26c53596e
25 changed files with 63 additions and 49 deletions

View File

@ -168,6 +168,8 @@ class DoctrineExtractor implements PropertyListExtractorInterface, PropertyTypeE
return $builtinType ? [new Type($builtinType, $nullable)] : null;
}
}
return null;
}
/**

View File

@ -107,6 +107,8 @@ class DeprecationErrorHandler
}
$deprecations[] = [error_reporting(), $msg, $file];
return null;
});
register_shutdown_function(function () use ($outputFile, &$deprecations) {
@ -125,7 +127,7 @@ class DeprecationErrorHandler
$deprecation = new Deprecation($msg, debug_backtrace(), $file);
if ($deprecation->isMuted()) {
return;
return null;
}
$group = 'other';
@ -164,6 +166,8 @@ class DeprecationErrorHandler
}
++$this->deprecations[$group.'Count'];
return null;
}
/**

View File

@ -145,6 +145,8 @@ EOF
}
$io->newLine();
return null;
}
private function getFileLink(string $class): string

View File

@ -39,12 +39,14 @@ class StopwatchHelper extends Helper
public function __call($method, $arguments = [])
{
if (null !== $this->stopwatch) {
if (method_exists($this->stopwatch, $method)) {
return $this->stopwatch->{$method}(...$arguments);
}
throw new \BadMethodCallException(sprintf('Method "%s" of Stopwatch does not exist', $method));
if (null === $this->stopwatch) {
return null;
}
if (method_exists($this->stopwatch, $method)) {
return $this->stopwatch->{$method}(...$arguments);
}
throw new \BadMethodCallException(sprintf('Method "%s" of Stopwatch does not exist', $method));
}
}

View File

@ -117,7 +117,7 @@ class WebServerConfig
return gethostbyname($localHostname).':'.$this->port;
}
private function findFrontController($documentRoot, $env)
private function findFrontController(string $documentRoot, string $env): ?string
{
$fileNames = $this->getFrontControllerFileNames($env);
@ -126,14 +126,16 @@ class WebServerConfig
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)) {

View File

@ -131,7 +131,7 @@ trait ArrayTrait
$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)) {

View File

@ -95,7 +95,9 @@ class ConsoleSectionOutput extends StreamOutput
protected function doWrite($message, $newline)
{
if (!$this->isDecorated()) {
return parent::doWrite($message, $newline);
parent::doWrite($message, $newline);
return;
}
$erasedContent = $this->popStreamContentUntilCurrentSection();

View File

@ -576,7 +576,9 @@ class ErrorHandler
$this->exceptionHandler = null;
try {
if (null !== $exceptionHandler) {
return $exceptionHandler($exception);
$exceptionHandler($exception);
return;
}
$handlerException = $handlerException ?: $exception;
} catch (\Throwable $handlerException) {

View File

@ -276,6 +276,8 @@ class Container implements ResettableContainerInterface
throw new ServiceNotFoundException($id, null, null, $alternatives);
}
return null;
}
/**

View File

@ -592,7 +592,7 @@ class ContainerBuilder extends Container implements TaggedContainerInterface
$definition = $this->getDefinition($id);
} catch (ServiceNotFoundException $e) {
if (ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE < $invalidBehavior) {
return;
return null;
}
throw $e;

View File

@ -101,7 +101,7 @@ abstract class Extension implements ExtensionInterface, ConfigurationExtensionIn
return null;
}
final protected function processConfiguration(ConfigurationInterface $configuration, array $configs)
final protected function processConfiguration(ConfigurationInterface $configuration, array $configs): array
{
$processor = new Processor();

View File

@ -1063,9 +1063,7 @@ class Crawler implements \Countable, \IteratorAggregate
*/
public function getNode($position)
{
if (isset($this->nodes[$position])) {
return $this->nodes[$position];
}
return isset($this->nodes[$position]) ? $this->nodes[$position] : null;
}
/**
@ -1180,11 +1178,7 @@ class Crawler implements \Countable, \IteratorAggregate
// 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

View File

@ -34,7 +34,7 @@ class IntlTimeZoneToStringTransformer implements DataTransformerInterface
public function transform($intlTimeZone)
{
if (null === $intlTimeZone) {
return;
return null;
}
if ($this->multiple) {

View File

@ -100,6 +100,8 @@ final class CurlResponse implements ResponseInterface
return 1; // Abort the request
}
return null;
});
}

View File

@ -88,7 +88,7 @@ class Response
const HTTP_NETWORK_AUTHENTICATION_REQUIRED = 511; // RFC6585
/**
* @var \Symfony\Component\HttpFoundation\ResponseHeaderBag
* @var ResponseHeaderBag
*/
public $headers;

View File

@ -60,7 +60,7 @@ class CacheWarmerAggregate implements CacheWarmerInterface
if (isset($collectedLogs[$message])) {
++$collectedLogs[$message]['count'];
return;
return null;
}
$backtrace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 3);
@ -80,6 +80,8 @@ class CacheWarmerAggregate implements CacheWarmerInterface
'trace' => $backtrace,
'count' => 1,
];
return null;
});
}

View File

@ -48,7 +48,7 @@ final class ArgumentMetadataFactory implements ArgumentMetadataFactoryInterface
private function getType(\ReflectionParameter $parameter, \ReflectionFunctionAbstract $function)
{
if (!$type = $parameter->getType()) {
return;
return null;
}
$name = $type->getName();
$lcName = strtolower($name);
@ -57,7 +57,7 @@ final class ArgumentMetadataFactory implements ArgumentMetadataFactoryInterface
return $name;
}
if (!$function instanceof \ReflectionMethod) {
return;
return null;
}
if ('self' === $lcName) {
return $function->getDeclaringClass()->name;
@ -65,5 +65,7 @@ final class ArgumentMetadataFactory implements ArgumentMetadataFactoryInterface
if ($parent = $function->getDeclaringClass()->getParentClass()) {
return $parent->name;
}
return null;
}
}

View File

@ -101,5 +101,7 @@ class FileLinkFormatter
];
}
}
return null;
}
}

View File

@ -84,13 +84,13 @@ class TimezoneDataGenerator extends AbstractDataGenerator
// 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 = [
@ -115,7 +115,7 @@ class TimezoneDataGenerator extends AbstractDataGenerator
$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']));

View File

@ -104,11 +104,7 @@ final class Locale extends \Locale
// 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;
}
/**

View File

@ -1304,25 +1304,21 @@ class Process implements \IteratorAggregate
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);
};
}

View File

@ -151,6 +151,8 @@ class ReflectionExtractor implements PropertyListExtractorInterface, PropertyTyp
if ($fromDefaultValue = $this->extractFromDefaultValue($class, $property)) {
return $fromDefaultValue;
}
return null;
}
/**

View File

@ -566,7 +566,7 @@ class Inline
case 'null' === $scalarLower:
case '' === $scalar:
case '~' === $scalar:
return;
return null;
case 'true' === $scalarLower:
return true;
case 'false' === $scalarLower:
@ -586,7 +586,7 @@ class Inline
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;
@ -600,7 +600,7 @@ class Inline
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 '):

View File

@ -739,8 +739,6 @@ class Parser
* @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
{

View File

@ -57,5 +57,7 @@ trait ServiceSubscriberTrait
if (\is_callable(['parent', __FUNCTION__])) {
return parent::setContainer($container);
}
return null;
}
}