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

Skip to content

Fix inconsistent return points #33009

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 7, 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
2 changes: 2 additions & 0 deletions src/Symfony/Bridge/Monolog/Logger.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,5 +73,7 @@ private function getDebugLogger()
return $handler;
}
}

return null;
}
}
6 changes: 4 additions & 2 deletions src/Symfony/Bundle/SecurityBundle/Security/FirewallMap.php
Original file line number Diff line number Diff line change
Expand Up @@ -135,14 +135,14 @@ public function getFirewallConfig(Request $request)
$context = $this->getFirewallContext($request);

if (null === $context) {
return;
return null;
}

return $context->getConfig();
}

/**
* @return FirewallContext
* @return FirewallContext|null
*/
private function getFirewallContext(Request $request)
{
Expand All @@ -164,5 +164,7 @@ private function getFirewallContext(Request $request)
return $this->container->get($contextId);
}
}

return null;
}
}
52 changes: 26 additions & 26 deletions src/Symfony/Component/Console/Terminal.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,25 +87,13 @@ private static function initDimensions()
*/
private static function getConsoleMode()
{
if (!\function_exists('proc_open')) {
return;
}
$info = self::readFromProcess('mode CON');

$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]];
}
if (null === $info || !preg_match('/--------+\r?\n.+?(\d+)\r?\n.+?(\d+)\r?\n/', $info, $matches)) {
return null;
}

return [(int) $matches[2], (int) $matches[1]];
}

/**
Expand All @@ -114,24 +102,36 @@ private static function getConsoleMode()
* @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 = [
1 => ['pipe', 'w'],
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;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ private function getAutowiredReference(TypedReference $reference, $deprecationMe
}

if (!$reference->canBeAutoregistered() || isset($this->types[$type]) || isset($this->ambiguousServiceTypes[$type])) {
return;
return null;
}

if (isset($this->autowired[$type])) {
Expand All @@ -328,6 +328,8 @@ private function getAutowiredReference(TypedReference $reference, $deprecationMe
if (!$this->strictMode) {
return $this->createAutowiredDefinition($type);
}

return null;
}

/**
Expand Down Expand Up @@ -425,7 +427,7 @@ private function set($type, $id)
private function createAutowiredDefinition($type)
{
if (!($typeHint = $this->container->getReflectionClass($type, false)) || !$typeHint->isInstantiable()) {
return;
return null;
}

$currentId = $this->currentId;
Expand All @@ -445,7 +447,7 @@ private function createAutowiredDefinition($type)
$this->lastFailure = $e->getMessage();
$this->container->log($this, $this->lastFailure);

return;
return null;
} finally {
$this->throwOnAutowiringException = $originalThrowSetting;
$this->currentId = $currentId;
Expand Down Expand Up @@ -518,7 +520,7 @@ private function createTypeAlternatives(TypedReference $reference)
} 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);
Expand Down Expand Up @@ -572,5 +574,7 @@ private function getAliasesSuggestionForType($type, $extraContext = null)
if ($aliases) {
return sprintf('Try changing the type-hint%s to "%s" instead.', $extraContext, $aliases[0]);
}

return null;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ private function parseDefinition(\DOMElement $service, $file, array $defaults)
$alias->setPublic($defaults['public']);
}

return;
return null;
}

if ($this->isLoadingInstanceof) {
Expand Down
13 changes: 8 additions & 5 deletions src/Symfony/Component/HttpKernel/HttpCache/Store.php
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ public function lookup(Request $request)
$key = $this->getCacheKey($request);

if (!$entries = $this->getMetadata($key)) {
return;
return null;
}

// find a cached entry that matches the request.
Expand All @@ -148,7 +148,7 @@ public function lookup(Request $request)
}

if (null === $match) {
return;
return null;
}

$headers = $match[1];
Expand All @@ -159,6 +159,7 @@ public function lookup(Request $request)
// 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;
}

/**
Expand All @@ -180,7 +181,7 @@ public function write(Request $request, Response $response)
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.');
}

Expand Down Expand Up @@ -209,7 +210,7 @@ public function write(Request $request, Response $response)

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.');
}

Expand Down Expand Up @@ -248,7 +249,7 @@ public function invalidate(Request $request)
}
}

if ($modified && false === $this->save($key, serialize($entries))) {
if ($modified && !$this->save($key, serialize($entries))) {
throw new \RuntimeException('Unable to store the metadata.');
}
}
Expand Down Expand Up @@ -408,6 +409,8 @@ private function save($key, $data)
}

@chmod($path, 0666 & ~umask());

return true;
}

public function getPath($key)
Expand Down
2 changes: 2 additions & 0 deletions src/Symfony/Component/PropertyAccess/PropertyAccessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -840,6 +840,8 @@ private function findAdderAndRemover(\ReflectionClass $reflClass, array $singula
return [$addMethod, $removeMethod];
}
}

return null;
}

/**
Expand Down
4 changes: 2 additions & 2 deletions src/Symfony/Component/Routing/Loader/XmlFileLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ private function parseConfigs(\DOMElement $node, $path)
private function parseDefaultsConfig(\DOMElement $element, $path)
{
if ($this->isElementValueNull($element)) {
return;
return null;
}

// Check for existing element nodes in the default element. There can
Expand Down Expand Up @@ -298,7 +298,7 @@ private function parseDefaultsConfig(\DOMElement $element, $path)
private function parseDefaultNode(\DOMElement $node, $path)
{
if ($this->isElementValueNull($node)) {
return;
return null;
}

switch ($node->localName) {
Expand Down
4 changes: 4 additions & 0 deletions src/Symfony/Component/Serializer/Serializer.php
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,8 @@ private function getNormalizer($data, $format, array $context)
return $normalizer;
}
}

return null;
}

/**
Expand All @@ -262,6 +264,8 @@ private function getDenormalizer($data, $class, $format, array $context)
return $normalizer;
}
}

return null;
}

/**
Expand Down
0