8000 Fix inconsistent return points. · symfony/symfony@78e37cf · GitHub
[go: up one dir, main page]

Skip to content

Commit 78e37cf

Browse files
committed
Fix inconsistent return points.
1 parent 4123465 commit 78e37cf

File tree

9 files changed

+57
-40
lines changed

9 files changed

+57
-40
lines changed

src/Symfony/Bridge/Monolog/Logger.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,5 +73,7 @@ private function getDebugLogger()
7373
return $handler;
7474
}
7575
}
76+
77+
return null;
7678
}
7779
}

src/Symfony/Bundle/SecurityBundle/Security/FirewallMap.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,14 +135,14 @@ public function getFirewallConfig(Request $request)
135135
$context = $this->getFirewallContext($request);
136136

137137
if (null === $context) {
138-
return;
138+
return null;
139139
}
140140

141141
return $context->getConfig();
142142
}
143143

144144
/**
145-
* @return FirewallContext
145+
* @return FirewallContext|null
146146
*/
147147
private function getFirewallContext(Request $request)
148148
{
@@ -164,5 +164,7 @@ private function getFirewallContext(Request $request)
164164
return $this->container->get($contextId);
165165
}
166166
}
167+
168+
return null;
167169
}
168170
}

src/Symfony/Component/Console/Terminal.php

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -87,25 +87,13 @@ private static function initDimensions()
8787
*/
8888
private static function getConsoleMode()
8989
{
90-
if (!\function_exists('proc_open')) {
91-
return;
92-
}
90+
$info = self::readFromProcess('mode CON');
9391

94-
$descriptorspec = [
95-
1 => ['pipe', 'w'],
96-
2 => ['pipe', 'w'],
97-
];
98-
$process = proc_open('mode CON', $descriptorspec, $pipes, null, null, ['suppress_errors' => true]);
99-
if (\is_resource($process)) {
100-
$info = stream_get_contents($pipes[1]);
101-
fclose($pipes[1]);
102-
fclose($pipes[2]);
103-
proc_close($process);
104-
105-
if (preg_match('/--------+\r?\n.+?(\d+)\r?\n.+?(\d+)\r?\n/', $info, $matches)) {
106-
return [(int) $matches[2], (int) $matches[1]];
107-
}
92+
if (null === $info || !preg_match('/--------+\r?\n.+?(\d+)\r?\n.+?(\d+)\r?\n/', $info, $matches)) {
93+
return null;
10894
}
95+
96+
return [(int)$matches[2], (int)$matches[1]];
10997
}
11098

11199
/**
@@ -114,24 +102,36 @@ private static function getConsoleMode()
114102
* @return string|null
115103
*/
116104
private static function getSttyColumns()
105+
{
106+
return self::readFromProcess('stty -a | grep columns');
107+
}
108+
109+
/**
110+
* @param string $command
111+
*
112+
* @return string|null
113+
*/
114+
private static function readFromProcess($command)
117115
{
118116
if (!\function_exists('proc_open')) {
119-
return;
117+
return null;
120118
}
121119

122120
$descriptorspec = [
123121
1 => ['pipe', 'w'],
124122
2 => ['pipe', 'w'],
125123
];
126124

127-
$process = proc_open('stty -a | grep columns', $descriptorspec, $pipes, null, null, ['suppress_errors' => true]);
128-
if (\is_resource($process)) {
129-
$info = stream_get_contents($pipes[1]);
130-
fclose($pipes[1]);
131-
fclose($pipes[2]);
132-
proc_close($process);
133-
134-
return $info;
125+
$process = proc_open($command, $descriptorspec, $pipes, null, null, ['suppress_errors' => true]);
126+
if (!\is_resource($process)) {
127+
return null;
135128
}
129+
130+
$info = stream_get_contents($pipes[1]);
131+
fclose($pipes[1]);
132+
fclose($pipes[2]);
133+
proc_close($process);
134+
135+
return $info;
136136
}
137137
}

src/Symfony/Component/DependencyInjection/Compiler/AutowirePass.php

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,7 @@ private function getAutowiredReference(TypedReference $reference, $deprecationMe
318318
}
319319

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

324324
if (isset($this->autowired[$type])) {
@@ -328,6 +328,8 @@ private function getAutowiredReference(TypedReference $reference, $deprecationMe
328328
if (!$this->strictMode) {
329329
return $this->createAutowiredDefinition($type);
330330
}
331+
332+
return null;
331333
}
332334

333335
/**
@@ -425,7 +427,7 @@ private function set($type, $id)
425427
private function createAutowiredDefinition($type)
426428
{
427429
if (!($typeHint = $this->container->getReflectionClass($type, false)) || !$typeHint->isInstantiable()) {
428-
return;
430+
return null;
429431
}
430432

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

448-
return;
450+
return null;
449451
} finally {
450452
$this->throwOnAutowiringException = $originalThrowSetting;
451453
$this->currentId = $currentId;
@@ -518,7 +520,7 @@ private function createTypeAlternatives(TypedReference $reference)
518520
} elseif ($reference->getRequiringClass() && !$reference->canBeAutoregistered() && !$this->strictMode) {
519521
return ' It cannot be auto-registered because it is from a different root namespace.';
520522
} else {
521-
return;
523+
return null;
522524
}
523525

524526
return sprintf(' You should maybe alias this %s to %s.', class_exists($type, false) ? 'class' : 'interface', $message);
@@ -572,5 +574,7 @@ private function getAliasesSuggestionForType($type, $extraContext = null)
572574
if ($aliases) {
573575
return sprintf('Try changing the type-hint%s to "%s" instead.', $extraContext, $aliases[0]);
574576
}
577+
578+
return null;
575579
}
576580
}

src/Symfony/Component/DependencyInjection/Loader/XmlFileLoader.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ private function parseDefinition(\DOMElement $service, $file, array $defaults)
211211
$alias->setPublic($defaults['public']);
212212
}
213213

214-
return;
214+
return null;
215215
}
216216

217217
if ($this->isLoadingInstanceof) {

src/Symfony/Component/HttpKernel/HttpCache/Store.php

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ public function lookup(Request $request)
134134
$key = $this->getCacheKey($request);
135135

136136
if (!$entries = $this->getMetadata($key)) {
137-
return;
137+
return null;
138138
}
139139

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

150150
if (null === $match) {
151-
return;
151+
return null;
152152
}
153153

154154
$headers = $match[1];
@@ -159,6 +159,7 @@ public function lookup(Request $request)
159159
// TODO the metaStore referenced an entity that doesn't exist in
160160
// the entityStore. We definitely want to return nil but we should
161161
// also purge the entry from the meta-store when this is detected.
162+
return null;
162163
}
163164

164165
/**
@@ -180,7 +181,7 @@ public function write(Request $request, Response $response)
180181
if (!$response->headers->has('X-Content-Digest')) {
181182
$digest = $this->generateContentDigest($response);
182183

183-
if (false === $this->save($digest, $response->getContent())) {
184+
if (!$this->save($digest, $response->getContent())) {
184185
throw new \RuntimeException('Unable to store the entity.');
185186
}
186187

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

210211
array_unshift($entries, [$storedEnv, $headers]);
211212

212-
if (false === $this->save($key, serialize($entries))) {
213+
if (!$this->save($key, serialize($entries))) {
213214
throw new \RuntimeException('Unable to store the metadata.');
214215
}
215216

@@ -248,7 +249,7 @@ public function invalidate(Request $request)
248249
}
249250
}
250251

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

410411
@chmod($path, 0666 & ~umask());
412+
413+
return true;
411414
}
412415

413416
public function getPath($key)

src/Symfony/Component/PropertyAccess/PropertyAccessor.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -840,6 +840,8 @@ private function findAdderAndRemover(\ReflectionClass $reflClass, array $singula
840840
return [$addMethod, $removeMethod];
841841
}
842842
}
843+
844+
return null;
843845
}
844846

845847
/**

src/Symfony/Component/Routing/Loader/XmlFileLoader.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ private function parseConfigs(\DOMElement $node, $path)
261261
private function parseDefaultsConfig(\DOMElement $element, $path)
262262
{
263263
if ($this->isElementValueNull($element)) {
264-
return;
264+
return null;
265265
}
266266

267267
// Check for existing element nodes in the default element. There can
@@ -298,7 +298,7 @@ private function parseDefaultsConfig(\DOMElement $element, $path)
298298
private function parseDefaultNode(\DOMElement $node, $path)
299299
{
300300
if ($this->isElementValueNull($node)) {
301-
return;
301+
return null;
302302
}
303303

304304
switch ($node->localName) {

src/Symfony/Component/Serializer/Serializer.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,8 @@ private function getNormalizer($data, $format, array $context)
243243
return $normalizer;
244244
}
245245
}
246+
247+
return null;
246248
}
247249

248250
/**
@@ -262,6 +264,8 @@ private function getDenormalizer($data, $class, $format, array $context)
262264
return $normalizer;
263265
}
264266
}
267+
268+
return null;
265269
}
266270

267271
/**

0 commit comments

Comments
 (0)
0