minor #33252 Fix inconsistent return points (derrabus)

This PR was merged into the 3.4 branch.

Discussion
----------

Fix inconsistent return points

| Q             | A
| ------------- | ---
| Branch?       | 3.4
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #17201 in preparation for #33228
| License       | MIT
| Doc PR        | N/A

Inconsistent return points in methods prevent adding return types. I thought, I'll give it a try and fix them. After this PR, PhpStorm's inspection still finds 39 issues, but as far as I can tell, they're either false positives or fixture code.

Commits
-------

f5b6ee9de1 Fix inconsistent return points.
This commit is contained in:
Nicolas Grekas 2019-08-20 15:34:30 +02:00
commit 8069b58299
131 changed files with 421 additions and 211 deletions

View File

@ -37,7 +37,7 @@ class DoctrineParserCache implements ParserCacheInterface
public function fetch($key)
{
if (false === $value = $this->cache->fetch($key)) {
return;
return null;
}
return $value;

View File

@ -118,6 +118,8 @@ class DoctrineOrmTypeGuesser implements FormTypeGuesserInterface
return new ValueGuess(!$mapping['joinColumns'][0]['nullable'], Guess::HIGH_CONFIDENCE);
}
return null;
}
/**
@ -137,6 +139,8 @@ class DoctrineOrmTypeGuesser implements FormTypeGuesserInterface
return new ValueGuess(null, Guess::MEDIUM_CONFIDENCE);
}
}
return null;
}
/**
@ -150,6 +154,8 @@ class DoctrineOrmTypeGuesser implements FormTypeGuesserInterface
return new ValueGuess(null, Guess::MEDIUM_CONFIDENCE);
}
}
return null;
}
protected function getMetadata($class)
@ -171,5 +177,7 @@ class DoctrineOrmTypeGuesser implements FormTypeGuesserInterface
// not an entity or mapped super class, using Doctrine ORM 2.2
}
}
return null;
}
}

View File

@ -157,6 +157,8 @@ abstract class DoctrineType extends AbstractType
return $doctrineChoiceLoader;
}
return null;
};
$choiceName = function (Options $options) {
@ -171,6 +173,7 @@ abstract class DoctrineType extends AbstractType
}
// Otherwise, an incrementing integer is used as name automatically
return null;
};
// The choices are always indexed by ID (see "choices" normalizer
@ -187,6 +190,7 @@ abstract class DoctrineType extends AbstractType
}
// Otherwise, an incrementing integer is used as value automatically
return null;
};
$emNormalizer = function (Options $options, $em) {

View File

@ -248,6 +248,8 @@ class DbalSessionHandler implements \SessionHandlerInterface
return "INSERT INTO $this->table ($this->idCol, $this->dataCol, $this->timeCol) VALUES (:id, :data, :time) ".
"ON CONFLICT ($this->idCol) DO UPDATE SET ($this->dataCol, $this->timeCol) = (EXCLUDED.$this->dataCol, EXCLUDED.$this->timeCol)";
}
return null;
}
private function getServerVersion()

View File

@ -42,9 +42,9 @@ class DoctrineExtractor implements PropertyListExtractorInterface, PropertyTypeE
try {
$metadata = $this->classMetadataFactory->getMetadataFor($class);
} catch (MappingException $exception) {
return;
return null;
} catch (OrmMappingException $exception) {
return;
return null;
}
$properties = array_merge($metadata->getFieldNames(), $metadata->getAssociationNames());
@ -68,9 +68,9 @@ class DoctrineExtractor implements PropertyListExtractorInterface, PropertyTypeE
try {
$metadata = $this->classMetadataFactory->getMetadataFor($class);
} catch (MappingException $exception) {
return;
return null;
} catch (OrmMappingException $exception) {
return;
return null;
}
if ($metadata->hasAssociation($property)) {
@ -162,6 +162,8 @@ class DoctrineExtractor implements PropertyListExtractorInterface, PropertyTypeE
return $builtinType ? [new Type($builtinType, $nullable)] : null;
}
}
return null;
}
/**
@ -225,5 +227,7 @@ class DoctrineExtractor implements PropertyListExtractorInterface, PropertyTypeE
case DBALType::OBJECT:
return Type::BUILTIN_TYPE_OBJECT;
}
return null;
}
}

View File

@ -47,7 +47,7 @@ class DoctrineFooType extends Type
public function convertToDatabaseValue($value, AbstractPlatform $platform)
{
if (null === $value) {
return;
return null;
}
if (!$value instanceof Foo) {
throw new ConversionException(sprintf('Expected %s, got %s', 'Symfony\Bridge\Doctrine\Tests\PropertyInfo\Fixtures\Foo', \gettype($value)));
@ -62,7 +62,7 @@ class DoctrineFooType extends Type
public function convertToPHPValue($value, AbstractPlatform $platform)
{
if (null === $value) {
return;
return null;
}
if (!\is_string($value)) {
throw ConversionException::conversionFailed($value, self::NAME);

View File

@ -25,6 +25,8 @@ class ClockMock
}
self::$now = is_numeric($enable) ? (float) $enable : ($enable ? microtime(true) : null);
return null;
}
public static function time()
@ -54,6 +56,8 @@ class ClockMock
}
self::$now += $us / 1000000;
return null;
}
public static function microtime($asFloat = false)

View File

@ -180,6 +180,8 @@ class DeprecationErrorHandler
++$ref;
}
++$deprecations[$group.'Count'];
return null;
};
$oldErrorHandler = set_error_handler($deprecationHandler);
@ -291,6 +293,8 @@ class DeprecationErrorHandler
return \call_user_func(DeprecationErrorHandler::getPhpUnitErrorHandler(), $type, $msg, $file, $line, $context);
}
$deprecations[] = array(error_reporting(), $msg, $file);
return null;
});
register_shutdown_function(function () use ($outputFile, &$deprecations) {

View File

@ -95,11 +95,7 @@ class CoverageListenerTrait
$sutFqcn = str_replace('\\Tests\\', '\\', $class);
$sutFqcn = preg_replace('{Test$}', '', $sutFqcn);
if (!class_exists($sutFqcn)) {
return;
}
return $sutFqcn;
return class_exists($sutFqcn) ? $sutFqcn : null;
}
public function __destruct()

View File

@ -357,6 +357,8 @@ class SymfonyTestsListenerTrait
$msg = 'Unsilenced deprecation: '.$msg;
}
$this->gatheredDeprecations[] = $msg;
return null;
}
/**

View File

@ -135,7 +135,7 @@ $argv = isset($_SERVER['argv']) ? $_SERVER['argv'] : array();
$argc = isset($_SERVER['argc']) ? $_SERVER['argc'] : 0;
if ($PHPUNIT_VERSION < 8.0) {
$argv = array_filter($argv, function ($v) use (&$argc) { if ('--do-not-cache-result' !== $v) return true; --$argc; });
$argv = array_filter($argv, function ($v) use (&$argc) { if ('--do-not-cache-result' !== $v) return true; --$argc; return false; });
} elseif (filter_var(getenv('SYMFONY_PHPUNIT_DISABLE_RESULT_CACHE'), FILTER_VALIDATE_BOOLEAN)) {
$argv[] = '--do-not-cache-result';
++$argc;

View File

@ -46,7 +46,7 @@ if (class_exists(Version::class) && version_compare(\defined(Version::class.'::V
$functionLoader = $functionLoader[0];
}
if (!\is_object($functionLoader)) {
return;
return null;
}
if ($functionLoader instanceof ClassLoader) {
return $functionLoader;
@ -57,6 +57,8 @@ if (class_exists(Version::class) && version_compare(\defined(Version::class.'::V
if ($functionLoader instanceof \Symfony\Component\ErrorHandler\DebugClassLoader) {
return $getComposerClassLoader($functionLoader->getClassLoader());
}
return null;
};
$classLoader = null;

View File

@ -83,9 +83,8 @@ class AppVariable
}
$user = $token->getUser();
if (\is_object($user)) {
return $user;
}
return \is_object($user) ? $user : null;
}
/**
@ -113,9 +112,7 @@ class AppVariable
throw new \RuntimeException('The "app.session" variable is not available.');
}
if ($request = $this->getRequest()) {
return $request->getSession();
}
return ($request = $this->getRequest()) ? $request->getSession() : null;
}
/**

View File

@ -220,16 +220,16 @@ EOF
return $entity;
}
if ('tests' === $type) {
return;
return null;
}
if ('functions' === $type || 'filters' === $type) {
$cb = $entity->getCallable();
if (null === $cb) {
return;
return null;
}
if (\is_array($cb)) {
if (!method_exists($cb[0], $cb[1])) {
return;
return null;
}
$refl = new \ReflectionMethod($cb[0], $cb[1]);
} elseif (\is_object($cb) && method_exists($cb, '__invoke')) {
@ -268,6 +268,8 @@ EOF
return $args;
}
return null;
}
private function getPrettyMetadata($type, $entity, $decorated)
@ -302,5 +304,7 @@ EOF
if ('filters' === $type) {
return $meta ? '('.implode(', ', $meta).')' : '';
}
return null;
}
}

View File

@ -55,7 +55,7 @@ class DumpExtension extends AbstractExtension
public function dump(Environment $env, $context)
{
if (!$env->isDebug()) {
return;
return null;
}
if (2 === \func_num_args()) {

View File

@ -115,7 +115,7 @@ class TranslationNodeVisitor extends AbstractNodeVisitor
} elseif ($arguments->hasNode($index)) {
$argument = $arguments->getNode($index);
} else {
return;
return null;
}
return $this->getReadDomainFromNode($argument);

View File

@ -71,6 +71,8 @@ class UndefinedCallableHandler
}
self::onUndefined($name, 'filter', self::$filterComponents[$name]);
return true;
}
public static function onUndefinedFunction($name)
@ -80,6 +82,8 @@ class UndefinedCallableHandler
}
self::onUndefined($name, 'function', self::$functionComponents[$name]);
return true;
}
private static function onUndefined($name, $type, $component)

View File

@ -86,7 +86,7 @@ EOF
'For dumping a specific option, add its path as the second argument of this command. (e.g. <comment>config:dump-reference FrameworkBundle profiler.matcher</comment> to dump the <comment>framework.profiler.matcher</comment> configuration)',
]);
return;
return null;
}
$extension = $this->findExtension($name);
@ -129,5 +129,7 @@ EOF
}
$io->writeln(null === $path ? $dumper->dump($configuration, $extension->getNamespace()) : $dumper->dumpAtPath($configuration, $path));
return null;
}
}

View File

@ -93,5 +93,7 @@ EOF
}
$io->table([], $tableRows);
return null;
}
}

View File

@ -154,10 +154,13 @@ EOF
}
}
/**
* @return callable|null
*/
private function extractCallable(Route $route)
{
if (!$route->hasDefault('_controller')) {
return;
return null;
}
$controller = $route->getDefault('_controller');
@ -178,5 +181,7 @@ EOF
return $controller;
} catch (\InvalidArgumentException $e) {
}
return null;
}
}

View File

@ -149,5 +149,7 @@ EOF
return 1;
}
return null;
}
}

View File

@ -242,7 +242,7 @@ EOF
if (!\count($operation->getDomains())) {
$errorIo->warning('No translation messages were found.');
return;
return null;
}
$resultMessage = 'Translation files were successfully updated';
@ -307,6 +307,8 @@ EOF
}
$errorIo->success($resultMessage.'.');
return null;
}
private function filterCatalogue(MessageCatalogue $catalogue, $domain)

View File

@ -142,7 +142,9 @@ class JsonDescriptor extends Descriptor
protected function describeContainerAlias(Alias $alias, array $options = [], ContainerBuilder $builder = null)
{
if (!$builder) {
return $this->writeData($this->getContainerAliasData($alias), $options);
$this->writeData($this->getContainerAliasData($alias), $options);
return;
}
$this->writeData(

View File

@ -249,7 +249,9 @@ class MarkdownDescriptor extends Descriptor
."\n".'- Public: '.($alias->isPublic() && !$alias->isPrivate() ? 'yes' : 'no');
if (!isset($options['id'])) {
return $this->write($output);
$this->write($output);
return;
}
$this->write(sprintf("### %s\n\n%s\n", $options['id'], $output));

View File

@ -369,7 +369,7 @@ class TextDescriptor extends Descriptor
return;
}
return $this->describeContainerDefinition($builder->getDefinition((string) $alias), array_merge($options, ['id' => (string) $alias]));
$this->describeContainerDefinition($builder->getDefinition((string) $alias), array_merge($options, ['id' => (string) $alias]));
}
/**

View File

@ -98,7 +98,9 @@ class XmlDescriptor extends Descriptor
$dom->appendChild($dom->importNode($this->getContainerAliasDocument($alias, isset($options['id']) ? $options['id'] : null)->childNodes->item(0), true));
if (!$builder) {
return $this->writeDocument($dom);
$this->writeDocument($dom);
return;
}
$dom->appendChild($dom->importNode($this->getContainerDefinitionDocument($builder->getDefinition((string) $alias), (string) $alias)->childNodes->item(0), true));

View File

@ -34,10 +34,6 @@ class SessionListener extends AbstractSessionListener
protected function getSession()
{
if (!$this->container->has('session')) {
return;
}
return $this->container->get('session');
return $this->container->get('session', ContainerInterface::NULL_ON_INVALID_REFERENCE);
}
}

View File

@ -34,10 +34,6 @@ class TestSessionListener extends AbstractTestSessionListener
protected function getSession()
{
if (!$this->container->has('session')) {
return;
}
return $this->container->get('session');
return $this->container->get('session', ContainerInterface::NULL_ON_INVALID_REFERENCE);
}
}

View File

@ -45,15 +45,12 @@ class GlobalVariables
public function getUser()
{
if (!$token = $this->getToken()) {
return;
return null;
}
$user = $token->getUser();
if (!\is_object($user)) {
return;
}
return $user;
return \is_object($user) ? $user : null;
}
/**
@ -61,9 +58,7 @@ class GlobalVariables
*/
public function getRequest()
{
if ($this->container->has('request_stack')) {
return $this->container->get('request_stack')->getCurrentRequest();
}
return $this->container->has('request_stack') ? $this->container->get('request_stack')->getCurrentRequest() : null;
}
/**
@ -71,9 +66,7 @@ class GlobalVariables
*/
public function getSession()
{
if ($request = $this->getRequest()) {
return $request->getSession();
}
return ($request = $this->getRequest()) ? $request->getSession() : null;
}
/**

View File

@ -110,7 +110,7 @@ class CodeHelper extends Helper
* @param string $file A file path
* @param int $line The selected line number
*
* @return string An HTML string
* @return string|null An HTML string
*/
public function fileExcerpt($file, $line)
{
@ -138,6 +138,8 @@ class CodeHelper extends Helper
return '<ol start="'.max($line - 3, 1).'">'.implode("\n", $lines).'</ol>';
}
return null;
}
/**

View File

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

View File

@ -85,7 +85,9 @@ abstract class FrameworkExtensionTest extends TestCase
$container = $this->createContainerFromFile('property_accessor');
if (!method_exists(PropertyAccessor::class, 'createCache')) {
return $this->assertFalse($container->hasDefinition('cache.property_access'));
$this->assertFalse($container->hasDefinition('cache.property_access'));
return;
}
$cache = $container->getDefinition('cache.property_access');
@ -98,7 +100,9 @@ abstract class FrameworkExtensionTest extends TestCase
$container = $this->createContainerFromFile('property_accessor', ['kernel.debug' => true]);
if (!method_exists(PropertyAccessor::class, 'createCache')) {
return $this->assertFalse($container->hasDefinition('cache.property_access'));
$this->assertFalse($container->hasDefinition('cache.property_access'));
return;
}
$cache = $container->getDefinition('cache.property_access');

View File

@ -109,5 +109,7 @@ EOF
}
$output->writeln('ACL tables have been initialized successfully.');
return null;
}
}

View File

@ -168,6 +168,8 @@ EOF
}
$errorIo->success('Password encoding succeeded');
return null;
}
/**

View File

@ -49,5 +49,7 @@ class ContainerAwareRuntimeLoader implements RuntimeLoaderInterface
if (null !== $this->logger) {
$this->logger->warning(sprintf('Class "%s" is not configured as a Twig runtime. Add the "twig.runtime" tag to the related service in the container.', $class));
}
return null;
}
}

View File

@ -98,9 +98,7 @@ class ProfilerControllerTest extends TestCase
->expects($this->exactly(2))
->method('loadProfile')
->willReturnCallback(function ($token) {
if ('found' == $token) {
return new Profile($token);
}
return 'found' == $token ? new Profile($token) : null;
})
;

View File

@ -155,5 +155,7 @@ EOF
return 1;
}
return null;
}
}

View File

@ -88,5 +88,7 @@ EOF
return 1;
}
}
return null;
}
}

View File

@ -62,5 +62,7 @@ EOF
return 1;
}
return null;
}
}

View File

@ -101,6 +101,12 @@ class WebServerConfig
return $this->hostname.':'.$this->port;
}
/**
* @param string $documentRoot
* @param string $env
*
* @return string|null
*/
private function findFrontController($documentRoot, $env)
{
$fileNames = $this->getFrontControllerFileNames($env);
@ -110,13 +116,23 @@ class WebServerConfig
return $fileName;
}
}
return null;
}
/**
* @param string $env
*
* @return array
*/
private function getFrontControllerFileNames($env)
{
return ['app_'.$env.'.php', 'app.php', 'index_'.$env.'.php', 'index.php'];
}
/**
* @return int
*/
private function findBestPort()
{
$port = 8000;

View File

@ -60,6 +60,8 @@ class CookieJar
}
}
}
return null;
}
/**

View File

@ -177,6 +177,8 @@ class TagAwareAdapter implements TagAwareAdapterInterface, PruneableInterface, R
foreach ($this->getItems([$key]) as $item) {
return $item;
}
return null;
}
/**

View File

@ -113,6 +113,8 @@ class ApcClassLoader
return true;
}
return null;
}
/**

View File

@ -161,6 +161,8 @@ class ClassLoader
return true;
}
return null;
}
/**
@ -203,5 +205,7 @@ class ClassLoader
if ($this->useIncludePath && $file = stream_resolve_include_path($classPath)) {
return $file;
}
return null;
}
}

View File

@ -63,8 +63,6 @@ class MapClassLoader
*/
public function findFile($class)
{
if (isset($this->map[$class])) {
return $this->map[$class];
}
return isset($this->map[$class]) ? $this->map[$class] : null;
}
}

View File

@ -55,6 +55,8 @@ class Psr4ClassLoader
}
}
}
return null;
}
/**

View File

@ -112,6 +112,8 @@ class WinCacheClassLoader
return true;
}
return null;
}
/**

View File

@ -106,6 +106,8 @@ class XcacheClassLoader
return true;
}
return null;
}
/**

View File

@ -306,5 +306,7 @@ class XmlReferenceDumper
if (\is_array($value)) {
return implode(',', $value);
}
return '';
}
}

View File

@ -168,5 +168,7 @@ abstract class FileLoader extends Loader
throw new FileLoaderLoadException($resource, $sourceResource, null, $e, $type);
}
}
return null;
}
}

View File

@ -40,7 +40,9 @@ class ErrorListener implements EventSubscriberInterface
$error = $event->getError();
if (!$inputString = $this->getInputString($event)) {
return $this->logger->error('An error occurred while using the console. Message: "{message}"', ['exception' => $error, 'message' => $error->getMessage()]);
$this->logger->error('An error occurred while using the console. Message: "{message}"', ['exception' => $error, 'message' => $error->getMessage()]);
return;
}
$this->logger->error('Error thrown while running command "{command}". Message: "{message}"', ['exception' => $error, 'command' => $inputString, 'message' => $error->getMessage()]);
@ -59,7 +61,9 @@ class ErrorListener implements EventSubscriberInterface
}
if (!$inputString = $this->getInputString($event)) {
return $this->logger->debug('The console exited with code "{code}"', ['code' => $exitCode]);
$this->logger->debug('The console exited with code "{code}"', ['code' => $exitCode]);
return;
}
$this->logger->debug('Command "{command}" exited with code "{code}"', ['command' => $inputString, 'code' => $exitCode]);

View File

@ -288,6 +288,8 @@ class ArgvInput extends Input
return $token;
}
return null;
}
/**

View File

@ -46,6 +46,8 @@ class ArrayInput extends Input
return $value;
}
return null;
}
/**

View File

@ -355,7 +355,9 @@ class SymfonyStyle extends OutputStyle
$chars = substr(str_replace(PHP_EOL, "\n", $this->bufferedOutput->fetch()), -2);
if (!isset($chars[0])) {
return $this->newLine(); //empty history, so we should start with a new line.
$this->newLine(); //empty history, so we should start with a new line.
return;
}
//Prepend new line for each non LF chars (This means no blank line was output before)
$this->newLine(2 - substr_count($chars, "\n"));

View File

@ -73,6 +73,8 @@ class TokenizerEscaping
if (0x10000 > $c) {
return \chr(0xE0 | $c >> 12).\chr(0x80 | $c >> 6 & 0x3F).\chr(0x80 | $c & 0x3F);
}
return '';
}, $value);
}
}

View File

@ -317,6 +317,12 @@ class DebugClassLoader
return $deprecations;
}
/**
* @param string $file
* @param string $class
*
* @return array|null
*/
public function checkCase(\ReflectionClass $refl, $file, $class)
{
$real = explode('\\', $class.strrchr($file, '.'));
@ -333,7 +339,7 @@ class DebugClassLoader
array_splice($tail, 0, $i + 1);
if (!$tail) {
return;
return null;
}
$tail = \DIRECTORY_SEPARATOR.implode(\DIRECTORY_SEPARATOR, $tail);
@ -349,6 +355,8 @@ class DebugClassLoader
) {
return [substr($tail, -$tailLen + 1), substr($real, -$tailLen + 1), substr($real, 0, -$tailLen + 1)];
}
return null;
}
/**

View File

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

View File

@ -71,6 +71,8 @@ class ClassNotFoundFatalErrorHandler implements FatalErrorHandlerInterface
return new ClassNotFoundException($message, $exception);
}
return null;
}
/**
@ -196,6 +198,8 @@ class ClassNotFoundFatalErrorHandler implements FatalErrorHandlerInterface
return $candidate;
}
}
return null;
}
/**

View File

@ -439,5 +439,7 @@ class ClassLoader
} elseif ('Test\\'.__NAMESPACE__.'\UseTraitWithInternalMethod' === $class) {
eval('namespace Test\\'.__NAMESPACE__.'; class UseTraitWithInternalMethod { use \\'.__NAMESPACE__.'\Fixtures\TraitWithInternalMethod; }');
}
return null;
}
}

View File

@ -156,7 +156,7 @@ class AnalyzeServiceReferencesPass extends AbstractRecursivePass implements Repe
}
if (!$this->container->hasDefinition($id)) {
return;
return null;
}
return $this->container->normalizeId($id);

View File

@ -81,5 +81,7 @@ class CheckArgumentsValidityPass extends AbstractRecursivePass
}
}
}
return null;
}
}

View File

@ -354,7 +354,7 @@ class ContainerBuilder extends Container implements TaggedContainerInterface
public function getReflectionClass($class, $throw = true)
{
if (!$class = $this->getParameterBag()->resolveValue($class)) {
return;
return null;
}
if (isset(self::$internalTypes[$class])) {
@ -621,7 +621,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

@ -65,7 +65,7 @@ class EnvVarProcessor implements EnvVarProcessorInterface
if (false !== $i || 'string' !== $prefix) {
if (null === $env = $getEnv($name)) {
return;
return null;
}
} elseif (isset($_ENV[$name])) {
$env = $_ENV[$name];
@ -77,7 +77,7 @@ class EnvVarProcessor implements EnvVarProcessorInterface
}
if (null === $env = $this->container->getParameter("env($name)")) {
return;
return null;
}
}

View File

@ -84,11 +84,12 @@ abstract class Extension implements ExtensionInterface, ConfigurationExtensionIn
$class = $container->getReflectionClass($class);
$constructor = $class ? $class->getConstructor() : null;
if ($class && (!$constructor || !$constructor->getNumberOfRequiredParameters())) {
return $class->newInstance();
}
return $class && (!$constructor || !$constructor->getNumberOfRequiredParameters()) ? $class->newInstance() : null;
}
/**
* @return array
*/
final protected function processConfiguration(ConfigurationInterface $configuration, array $configs)
{
$processor = new Processor();

View File

@ -58,8 +58,7 @@ class ProxyHelper
if ('self' === $lcName) {
return $prefix.$r->getDeclaringClass()->name;
}
if ($parent = $r->getDeclaringClass()->getParentClass()) {
return $prefix.$parent->name;
}
return ($parent = $r->getDeclaringClass()->getParentClass()) ? $prefix.$parent->name : null;
}
}

View File

@ -1053,9 +1053,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;
}
/**
@ -1115,7 +1113,7 @@ class Crawler implements \Countable, \IteratorAggregate
/**
* @param string $prefix
*
* @return string
* @return string|null
*
* @throws \InvalidArgumentException
*/
@ -1128,9 +1126,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 ($node = $namespaces->item(0)) ? $node->nodeValue : null;
}
/**

View File

@ -72,9 +72,8 @@ abstract class FormField
}
$labels = $xpath->query('ancestor::label[1]', $this->node);
if ($labels->length > 0) {
return $labels->item(0);
}
return $labels->length > 0 ? $labels->item(0) : null;
}
/**

View File

@ -79,7 +79,7 @@ class EventDispatcher implements EventDispatcherInterface
public function getListenerPriority($eventName, $listener)
{
if (empty($this->listeners[$eventName])) {
return;
return null;
}
if (\is_array($listener) && isset($listener[0]) && $listener[0] instanceof \Closure) {
@ -97,6 +97,8 @@ class EventDispatcher implements EventDispatcherInterface
}
}
}
return null;
}
/**

View File

@ -21,7 +21,7 @@ class FilesystemTestCase extends TestCase
protected $longPathNamesWindows = [];
/**
* @var \Symfony\Component\Filesystem\Filesystem
* @var Filesystem
*/
protected $filesystem = null;
@ -110,9 +110,8 @@ class FilesystemTestCase extends TestCase
$this->markAsSkippedIfPosixIsMissing();
$infos = stat($filepath);
if ($datas = posix_getpwuid($infos['uid'])) {
return $datas['name'];
}
return ($datas = posix_getpwuid($infos['uid'])) ? $datas['name'] : null;
}
protected function getFileGroup($filepath)

View File

@ -140,6 +140,7 @@ abstract class AbstractExtension implements FormExtensionInterface
*/
protected function loadTypeGuesser()
{
return null;
}
/**

View File

@ -80,9 +80,7 @@ class PropertyAccessDecorator implements ChoiceListFactoryInterface
// when such values are passed to
// ChoiceListInterface::getValuesForChoices(). Handle this case
// so that the call to getValue() doesn't break.
if (\is_object($choice) || \is_array($choice)) {
return $accessor->getValue($choice, $value);
}
return \is_object($choice) || \is_array($choice) ? $accessor->getValue($choice, $value) : null;
};
}
@ -113,9 +111,7 @@ class PropertyAccessDecorator implements ChoiceListFactoryInterface
// when such values are passed to
// ChoiceListInterface::getValuesForChoices(). Handle this case
// so that the call to getValue() doesn't break.
if (\is_object($choice) || \is_array($choice)) {
return $accessor->getValue($choice, $value);
}
return \is_object($choice) || \is_array($choice) ? $accessor->getValue($choice, $value) : null;
};
}
@ -191,6 +187,7 @@ class PropertyAccessDecorator implements ChoiceListFactoryInterface
return $accessor->getValue($choice, $groupBy);
} catch (UnexpectedTypeException $e) {
// Don't group if path is not readable
return null;
}
};
}

View File

@ -73,7 +73,7 @@ class ArrayToPartsTransformer implements DataTransformerInterface
if (\count($emptyKeys) > 0) {
if (\count($emptyKeys) === \count($this->partMapping)) {
// All parts empty
return;
return null;
}
throw new TransformationFailedException(sprintf('The keys "%s" should not be empty', implode('", "', $emptyKeys)));

View File

@ -42,7 +42,7 @@ class ChoiceToValueTransformer implements DataTransformerInterface
if (1 !== \count($choices)) {
if (null === $value || '' === $value) {
return;
return null;
}
throw new TransformationFailedException(sprintf('The choice "%s" does not exist or is not unique', $value));

View File

@ -34,7 +34,7 @@ class DateTimeZoneToStringTransformer implements DataTransformerInterface
public function transform($dateTimeZone)
{
if (null === $dateTimeZone) {
return;
return null;
}
if ($this->multiple) {
@ -58,7 +58,7 @@ class DateTimeZoneToStringTransformer implements DataTransformerInterface
public function reverseTransform($value)
{
if (null === $value) {
return;
return null;
}
if ($this->multiple) {

View File

@ -251,7 +251,7 @@ class ChoiceType extends AbstractType
{
$emptyData = function (Options $options) {
if ($options['expanded'] && !$options['multiple']) {
return;
return null;
}
if ($options['multiple']) {
@ -284,13 +284,13 @@ class ChoiceType extends AbstractType
$placeholderNormalizer = function (Options $options, $placeholder) {
if ($options['multiple']) {
// never use an empty value for this case
return;
return null;
} elseif ($options['required'] && ($options['expanded'] || isset($options['attr']['size']) && $options['attr']['size'] > 1)) {
// placeholder for required radio buttons or a select with size > 1 does not make sense
return;
return null;
} elseif (false === $placeholder) {
// an empty value should be added but the user decided otherwise
return;
return null;
} elseif ($options['expanded'] && '' === $placeholder) {
// never use an empty label for radio buttons
return 'None';
@ -380,9 +380,6 @@ class ChoiceType extends AbstractType
}
}
/**
* @return mixed
*/
private function addSubForm(FormBuilderInterface $builder, $name, ChoiceView $choiceView, array $options)
{
$choiceOpts = [

View File

@ -36,7 +36,7 @@ abstract class BaseValidatorExtension extends AbstractTypeExtension
}
if (empty($groups)) {
return;
return null;
}
if (\is_callable($groups)) {

View File

@ -153,6 +153,8 @@ class ValidatorTypeGuesser implements FormTypeGuesserInterface
case 'Symfony\Component\Validator\Constraints\IsFalse':
return new TypeGuess('Symfony\Component\Form\Extension\Core\Type\CheckboxType', [], Guess::MEDIUM_CONFIDENCE);
}
return null;
}
/**
@ -168,6 +170,8 @@ class ValidatorTypeGuesser implements FormTypeGuesserInterface
case 'Symfony\Component\Validator\Constraints\IsTrue':
return new ValueGuess(true, Guess::HIGH_CONFIDENCE);
}
return null;
}
/**
@ -196,6 +200,8 @@ class ValidatorTypeGuesser implements FormTypeGuesserInterface
}
break;
}
return null;
}
/**
@ -232,6 +238,8 @@ class ValidatorTypeGuesser implements FormTypeGuesserInterface
}
break;
}
return null;
}
/**

View File

@ -54,9 +54,7 @@ class MappingRule
*/
public function match($propertyPath)
{
if ($propertyPath === $this->propertyPath) {
return $this->getTarget();
}
return $propertyPath === $this->propertyPath ? $this->getTarget() : null;
}
/**

View File

@ -757,9 +757,7 @@ class Form implements \IteratorAggregate, FormInterface
return $this->clickedButton;
}
if ($this->parent && method_exists($this->parent, 'getClickedButton')) {
return $this->parent->getClickedButton();
}
return $this->parent && method_exists($this->parent, 'getClickedButton') ? $this->parent->getClickedButton() : null;
}
/**

View File

@ -53,5 +53,7 @@ class StringUtil
if (preg_match('~([^\\\\]+?)(type)?$~i', $fqcn, $matches)) {
return strtolower(preg_replace(['/([A-Z]+)([A-Z][a-z])/', '/([a-z\d])([A-Z])/'], ['\\1_\\2', '\\1_\\2'], $matches[1]));
}
return null;
}
}

View File

@ -90,5 +90,7 @@ class ExtensionGuesser implements ExtensionGuesserInterface
return $extension;
}
}
return null;
}
}

View File

@ -129,5 +129,7 @@ class MimeTypeGuesser implements MimeTypeGuesserInterface
if (2 === \count($this->guessers) && !FileBinaryMimeTypeGuesser::isSupported() && !FileinfoMimeTypeGuesser::isSupported()) {
throw new \LogicException('Unable to guess the mime type as no guessers are available (Did you enable the php_fileinfo extension?)');
}
return null;
}
}

View File

@ -97,49 +97,49 @@ class Request
/**
* Custom parameters.
*
* @var \Symfony\Component\HttpFoundation\ParameterBag
* @var ParameterBag
*/
public $attributes;
/**
* Request body parameters ($_POST).
*
* @var \Symfony\Component\HttpFoundation\ParameterBag
* @var ParameterBag
*/
public $request;
/**
* Query string parameters ($_GET).
*
* @var \Symfony\Component\HttpFoundation\ParameterBag
* @var ParameterBag
*/
public $query;
/**
* Server and execution environment parameters ($_SERVER).
*
* @var \Symfony\Component\HttpFoundation\ServerBag
* @var ServerBag
*/
public $server;
/**
* Uploaded files ($_FILES).
*
* @var \Symfony\Component\HttpFoundation\FileBag
* @var FileBag
*/
public $files;
/**
* Cookies ($_COOKIE).
*
* @var \Symfony\Component\HttpFoundation\ParameterBag
* @var ParameterBag
*/
public $cookies;
/**
* Headers (taken from the $_SERVER).
*
* @var \Symfony\Component\HttpFoundation\HeaderBag
* @var HeaderBag
*/
public $headers;
@ -199,7 +199,7 @@ class Request
protected $format;
/**
* @var \Symfony\Component\HttpFoundation\Session\SessionInterface
* @var SessionInterface
*/
protected $session;
@ -1449,6 +1449,8 @@ class Request
return $format;
}
}
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;
@ -790,6 +790,8 @@ class Response
if (null !== $this->getExpires()) {
return (int) $this->getExpires()->format('U') - (int) $this->getDate()->format('U');
}
return null;
}
/**
@ -846,6 +848,8 @@ class Response
if (null !== $maxAge = $this->getMaxAge()) {
return $maxAge - $this->getAge();
}
return null;
}
/**

View File

@ -87,9 +87,7 @@ abstract class Bundle implements BundleInterface
}
}
if ($this->extension) {
return $this->extension;
}
return $this->extension ?: null;
}
/**
@ -199,9 +197,7 @@ abstract class Bundle implements BundleInterface
*/
protected function createContainerExtension()
{
if (class_exists($class = $this->getContainerExtensionClass())) {
return new $class();
}
return class_exists($class = $this->getContainerExtensionClass()) ? new $class() : null;
}
private function parseClassName()

View File

@ -103,17 +103,17 @@ final class ArgumentMetadataFactory implements ArgumentMetadataFactoryInterface
{
if ($this->supportsParameterType) {
if (!$type = $parameter->getType()) {
return;
return null;
}
$name = $type instanceof \ReflectionNamedType ? $type->getName() : $type->__toString();
if ('array' === $name && !$type->isBuiltin()) {
// Special case for HHVM with variadics
return;
return null;
}
} elseif (preg_match('/^(?:[^ ]++ ){4}([a-zA-Z_\x7F-\xFF][^ ]++)/', $parameter, $name)) {
$name = $name[1];
} else {
return;
return null;
}
$lcName = strtolower($name);
@ -121,7 +121,7 @@ final class ArgumentMetadataFactory implements ArgumentMetadataFactoryInterface
return $name;
}
if (!$function instanceof \ReflectionMethod) {
return;
return null;
}
if ('self' === $lcName) {
return $function->getDeclaringClass()->name;
@ -129,5 +129,7 @@ final class ArgumentMetadataFactory implements ArgumentMetadataFactoryInterface
if ($parent = $function->getDeclaringClass()->getParentClass()) {
return $parent->name;
}
return null;
}
}

View File

@ -102,7 +102,7 @@ class FileLinkFormatter implements \Serializable
$request = $this->requestStack->getMasterRequest();
if ($request instanceof Request) {
if ($this->urlFormat instanceof \Closure && !$this->urlFormat = \call_user_func($this->urlFormat)) {
return;
return null;
}
return [
@ -111,5 +111,7 @@ class FileLinkFormatter implements \Serializable
];
}
}
return null;
}
}

View File

@ -108,5 +108,7 @@ class FragmentHandler
}
$response->sendContent();
return null;
}
}

View File

@ -109,6 +109,8 @@ abstract class AbstractSurrogate implements SurrogateInterface
throw $e;
}
}
return null;
}
/**

View File

@ -111,5 +111,7 @@ class Esi extends AbstractSurrogate
// remove ESI/1.0 from the Surrogate-Control header
$this->removeFromControl($response);
return $response;
}
}

View File

@ -94,5 +94,7 @@ class Ssi extends AbstractSurrogate
// remove SSI/1.0 from the Surrogate-Control header
$this->removeFromControl($response);
return null;
}
}

View File

@ -607,7 +607,7 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl
if (isset($collectedLogs[$message])) {
++$collectedLogs[$message]['count'];
return;
return null;
}
$backtrace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 3);
@ -627,6 +627,8 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl
'trace' => $backtrace,
'count' => 1,
];
return null;
});
}

View File

@ -248,16 +248,19 @@ class Profiler
return $this->collectors[$name];
}
/**
* @return int|null
*/
private function getTimestamp($value)
{
if (null === $value || '' == $value) {
return;
return null;
}
try {
$value = new \DateTime(is_numeric($value) ? '@'.$value : $value);
} catch (\Exception $e) {
return;
return null;
}
return $value->getTimestamp();

View File

@ -88,7 +88,7 @@ class EsiTest extends TestCase
$request = Request::create('/');
$response = new Response();
$response->headers->set('Content-Type', 'text/plain');
$esi->process($request, $response);
$this->assertSame($response, $esi->process($request, $response));
$this->assertFalse($response->headers->has('x-body-eval'));
}
@ -99,7 +99,7 @@ class EsiTest extends TestCase
$request = Request::create('/');
$response = new Response('<esi:remove> <a href="http://www.example.com">www.example.com</a> </esi:remove> Keep this'."<esi:remove>\n <a>www.example.com</a> </esi:remove> And this");
$esi->process($request, $response);
$this->assertSame($response, $esi->process($request, $response));
$this->assertEquals(' Keep this And this', $response->getContent());
}
@ -110,7 +110,7 @@ class EsiTest extends TestCase
$request = Request::create('/');
$response = new Response('<esi:comment text="some comment &gt;" /> Keep this');
$esi->process($request, $response);
$this->assertSame($response, $esi->process($request, $response));
$this->assertEquals(' Keep this', $response->getContent());
}
@ -121,23 +121,23 @@ class EsiTest extends TestCase
$request = Request::create('/');
$response = new Response('foo <esi:comment text="some comment" /><esi:include src="..." alt="alt" onerror="continue" />');
$esi->process($request, $response);
$this->assertSame($response, $esi->process($request, $response));
$this->assertEquals('foo <?php echo $this->surrogate->handle($this, \'...\', \'alt\', true) ?>'."\n", $response->getContent());
$this->assertEquals('ESI', $response->headers->get('x-body-eval'));
$response = new Response('foo <esi:comment text="some comment" /><esi:include src="foo\'" alt="bar\'" onerror="continue" />');
$esi->process($request, $response);
$this->assertSame($response, $esi->process($request, $response));
$this->assertEquals('foo <?php echo $this->surrogate->handle($this, \'foo\\\'\', \'bar\\\'\', true) ?>'."\n", $response->getContent());
$response = new Response('foo <esi:include src="..." />');
$esi->process($request, $response);
$this->assertSame($response, $esi->process($request, $response));
$this->assertEquals('foo <?php echo $this->surrogate->handle($this, \'...\', \'\', false) ?>'."\n", $response->getContent());
$response = new Response('foo <esi:include src="..."></esi:include>');
$esi->process($request, $response);
$this->assertSame($response, $esi->process($request, $response));
$this->assertEquals('foo <?php echo $this->surrogate->handle($this, \'...\', \'\', false) ?>'."\n", $response->getContent());
}
@ -148,7 +148,7 @@ class EsiTest extends TestCase
$request = Request::create('/');
$response = new Response('<?php <? <% <script language=php>');
$esi->process($request, $response);
$this->assertSame($response, $esi->process($request, $response));
$this->assertEquals('<?php echo "<?"; ?>php <?php echo "<?"; ?> <?php echo "<%"; ?> <?php echo "<s"; ?>cript language=php>', $response->getContent());
}
@ -160,7 +160,7 @@ class EsiTest extends TestCase
$request = Request::create('/');
$response = new Response('foo <esi:include />');
$esi->process($request, $response);
$this->assertSame($response, $esi->process($request, $response));
}
public function testProcessRemoveSurrogateControlHeader()
@ -170,16 +170,16 @@ class EsiTest extends TestCase
$request = Request::create('/');
$response = new Response('foo <esi:include src="..." />');
$response->headers->set('Surrogate-Control', 'content="ESI/1.0"');
$esi->process($request, $response);
$this->assertSame($response, $esi->process($request, $response));
$this->assertEquals('ESI', $response->headers->get('x-body-eval'));
$response->headers->set('Surrogate-Control', 'no-store, content="ESI/1.0"');
$esi->process($request, $response);
$this->assertSame($response, $esi->process($request, $response));
$this->assertEquals('ESI', $response->headers->get('x-body-eval'));
$this->assertEquals('no-store', $response->headers->get('surrogate-control'));
$response->headers->set('Surrogate-Control', 'content="ESI/1.0", no-store');
$esi->process($request, $response);
$this->assertSame($response, $esi->process($request, $response));
$this->assertEquals('ESI', $response->headers->get('x-body-eval'));
$this->assertEquals('no-store', $response->headers->get('surrogate-control'));
}

View File

@ -90,6 +90,8 @@ class CurrencyDataGenerator extends AbstractDataGenerator
return $data;
}
return null;
}
/**

View File

@ -134,6 +134,8 @@ class LanguageDataGenerator extends AbstractDataGenerator
return $data;
}
return null;
}
/**

View File

@ -104,6 +104,8 @@ class RegionDataGenerator extends AbstractDataGenerator
return $data;
}
return null;
}
/**

View File

@ -73,6 +73,8 @@ class ScriptDataGenerator extends AbstractDataGenerator
return $data;
}
return null;
}
/**

View File

@ -101,7 +101,7 @@ class FullTransformer
* @param string $dateChars The date characters to be replaced with a formatted ICU value
* @param \DateTime $dateTime A DateTime object to be used to generate the formatted value
*
* @return string The formatted value
* @return string|null The formatted value
*
* @throws NotImplementedException When it encounters a not implemented date character
*/
@ -123,6 +123,8 @@ class FullTransformer
if (false !== strpos($this->notImplementedChars, $dateChars[0])) {
throw new NotImplementedException(sprintf('Unimplemented date character "%s" in format "%s"', $dateChars[0], $this->pattern));
}
return null;
}
/**
@ -196,6 +198,8 @@ class FullTransformer
return "(?P<$captureName>".$transformer->getReverseMatchingRegExp($length).')';
}
return null;
}, $escapedPattern);
return $reverseMatchingRegExp;

View File

@ -104,9 +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 \strlen($locale) < 4 ? self::$defaultFallback : null;
}
/**

Some files were not shown because too many files have changed in this diff Show More