Fix inconsistent return points.

This commit is contained in:
Alexander M. Turek 2019-08-07 13:13:33 +02:00
parent 41234653d5
commit 1a83f9beed
9 changed files with 57 additions and 40 deletions

View File

@ -73,5 +73,7 @@ class Logger extends BaseLogger implements DebugLoggerInterface
return $handler;
}
}
return null;
}
}

View File

@ -135,14 +135,14 @@ class _FirewallMap
$context = $this->getFirewallContext($request);
if (null === $context) {
return;
return null;
}
return $context->getConfig();
}
/**
* @return FirewallContext
* @return FirewallContext|null
*/
private function getFirewallContext(Request $request)
{
@ -164,5 +164,7 @@ class _FirewallMap
return $this->container->get($contextId);
}
}
return null;
}
}

View File

@ -87,25 +87,13 @@ class Terminal
*/
private static function getConsoleMode()
{
if (!\function_exists('proc_open')) {
return;
$info = self::readFromProcess('mode CON');
if (null === $info || !preg_match('/--------+\r?\n.+?(\d+)\r?\n.+?(\d+)\r?\n/', $info, $matches)) {
return null;
}
$descriptorspec = [
1 => ['pipe', 'w'],
2 => ['pipe', 'w'],
];
$process = proc_open('mode CON', $descriptorspec, $pipes, null, null, ['suppress_errors' => true]);
if (\is_resource($process)) {
$info = stream_get_contents($pipes[1]);
fclose($pipes[1]);
fclose($pipes[2]);
proc_close($process);
if (preg_match('/--------+\r?\n.+?(\d+)\r?\n.+?(\d+)\r?\n/', $info, $matches)) {
return [(int) $matches[2], (int) $matches[1]];
}
}
return [(int) $matches[2], (int) $matches[1]];
}
/**
@ -114,9 +102,19 @@ class Terminal
* @return string|null
*/
private static function getSttyColumns()
{
return self::readFromProcess('stty -a | grep columns');
}
/**
* @param string $command
*
* @return string|null
*/
private static function readFromProcess($command)
{
if (!\function_exists('proc_open')) {
return;
return null;
}
$descriptorspec = [
@ -124,14 +122,16 @@ class Terminal
2 => ['pipe', 'w'],
];
$process = proc_open('stty -a | grep columns', $descriptorspec, $pipes, null, null, ['suppress_errors' => true]);
if (\is_resource($process)) {
$info = stream_get_contents($pipes[1]);
fclose($pipes[1]);
fclose($pipes[2]);
proc_close($process);
return $info;
$process = proc_open($command, $descriptorspec, $pipes, null, null, ['suppress_errors' => true]);
if (!\is_resource($process)) {
return null;
}
$info = stream_get_contents($pipes[1]);
fclose($pipes[1]);
fclose($pipes[2]);
proc_close($process);
return $info;
}
}

View File

@ -318,7 +318,7 @@ class AutowirePass extends AbstractRecursivePass
}
if (!$reference->canBeAutoregistered() || isset($this->types[$type]) || isset($this->ambiguousServiceTypes[$type])) {
return;
return null;
}
if (isset($this->autowired[$type])) {
@ -328,6 +328,8 @@ class AutowirePass extends AbstractRecursivePass
if (!$this->strictMode) {
return $this->createAutowiredDefinition($type);
}
return null;
}
/**
@ -425,7 +427,7 @@ class AutowirePass extends AbstractRecursivePass
private function createAutowiredDefinition($type)
{
if (!($typeHint = $this->container->getReflectionClass($type, false)) || !$typeHint->isInstantiable()) {
return;
return null;
}
$currentId = $this->currentId;
@ -445,7 +447,7 @@ class AutowirePass extends AbstractRecursivePass
$this->lastFailure = $e->getMessage();
$this->container->log($this, $this->lastFailure);
return;
return null;
} finally {
$this->throwOnAutowiringException = $originalThrowSetting;
$this->currentId = $currentId;
@ -518,7 +520,7 @@ class AutowirePass extends AbstractRecursivePass
} elseif ($reference->getRequiringClass() && !$reference->canBeAutoregistered() && !$this->strictMode) {
return ' It cannot be auto-registered because it is from a different root namespace.';
} else {
return;
return '';
}
return sprintf(' You should maybe alias this %s to %s.', class_exists($type, false) ? 'class' : 'interface', $message);
@ -572,5 +574,7 @@ class AutowirePass extends AbstractRecursivePass
if ($aliases) {
return sprintf('Try changing the type-hint%s to "%s" instead.', $extraContext, $aliases[0]);
}
return null;
}
}

View File

@ -211,7 +211,7 @@ class XmlFileLoader extends FileLoader
$alias->setPublic($defaults['public']);
}
return;
return null;
}
if ($this->isLoadingInstanceof) {

View File

@ -134,7 +134,7 @@ class Store implements StoreInterface
$key = $this->getCacheKey($request);
if (!$entries = $this->getMetadata($key)) {
return;
return null;
}
// find a cached entry that matches the request.
@ -148,7 +148,7 @@ class Store implements StoreInterface
}
if (null === $match) {
return;
return null;
}
$headers = $match[1];
@ -159,6 +159,7 @@ class Store implements StoreInterface
// TODO the metaStore referenced an entity that doesn't exist in
// the entityStore. We definitely want to return nil but we should
// also purge the entry from the meta-store when this is detected.
return null;
}
/**
@ -180,7 +181,7 @@ class Store implements StoreInterface
if (!$response->headers->has('X-Content-Digest')) {
$digest = $this->generateContentDigest($response);
if (false === $this->save($digest, $response->getContent())) {
if (!$this->save($digest, $response->getContent())) {
throw new \RuntimeException('Unable to store the entity.');
}
@ -209,7 +210,7 @@ class Store implements StoreInterface
array_unshift($entries, [$storedEnv, $headers]);
if (false === $this->save($key, serialize($entries))) {
if (!$this->save($key, serialize($entries))) {
throw new \RuntimeException('Unable to store the metadata.');
}
@ -248,7 +249,7 @@ class Store implements StoreInterface
}
}
if ($modified && false === $this->save($key, serialize($entries))) {
if ($modified && !$this->save($key, serialize($entries))) {
throw new \RuntimeException('Unable to store the metadata.');
}
}
@ -408,6 +409,8 @@ class Store implements StoreInterface
}
@chmod($path, 0666 & ~umask());
return true;
}
public function getPath($key)

View File

@ -840,6 +840,8 @@ class PropertyAccessor implements PropertyAccessorInterface
return [$addMethod, $removeMethod];
}
}
return null;
}
/**

View File

@ -261,7 +261,7 @@ class XmlFileLoader extends FileLoader
private function parseDefaultsConfig(\DOMElement $element, $path)
{
if ($this->isElementValueNull($element)) {
return;
return null;
}
// Check for existing element nodes in the default element. There can
@ -298,7 +298,7 @@ class XmlFileLoader extends FileLoader
private function parseDefaultNode(\DOMElement $node, $path)
{
if ($this->isElementValueNull($node)) {
return;
return null;
}
switch ($node->localName) {

View File

@ -243,6 +243,8 @@ class Serializer implements SerializerInterface, NormalizerInterface, Denormaliz
return $normalizer;
}
}
return null;
}
/**
@ -262,6 +264,8 @@ class Serializer implements SerializerInterface, NormalizerInterface, Denormaliz
return $normalizer;
}
}
return null;
}
/**