Skip to content

Commit b3d57a1

Browse files
[HttpFoundation] fix return type declarations
1 parent 9781d8d commit b3d57a1

15 files changed

+24
-26
lines changed

BinaryFileResponse.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -327,12 +327,12 @@ public function setContent($content)
327327
if (null !== $content) {
328328
throw new \LogicException('The content cannot be set on a BinaryFileResponse instance.');
329329
}
330+
331+
return $this;
330332
}
331333

332334
/**
333335
* {@inheritdoc}
334-
*
335-
* @return false
336336
*/
337337
public function getContent()
338338
{

FileBag.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,8 @@ protected function convertFileInformation($file)
7575
return $file;
7676
}
7777

78-
$file = $this->fixPhpFilesArray($file);
7978
if (\is_array($file)) {
79+
$file = $this->fixPhpFilesArray($file);
8080
$keys = array_keys($file);
8181
sort($keys);
8282

@@ -109,14 +109,12 @@ protected function convertFileInformation($file)
109109
* It's safe to pass an already converted array, in which case this method
110110
* just returns the original array unmodified.
111111
*
112+
* @param array $data
113+
*
112114
* @return array
113115
*/
114116
protected function fixPhpFilesArray($data)
115117
{
116-
if (!\is_array($data)) {
117-
return $data;
118-
}
119-
120118
$keys = array_keys($data);
121119
sort($keys);
122120

HeaderBag.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ public function get($key, $default = null, $first = true)
121121
}
122122

123123
if ($first) {
124-
return \count($headers[$key]) ? $headers[$key][0] : $default;
124+
return \count($headers[$key]) ? (string) $headers[$key][0] : $default;
125125
}
126126

127127
return $headers[$key];

Request.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -528,6 +528,10 @@ public function __toString()
528528
try {
529529
$content = $this->getContent();
530530
} catch (\LogicException $e) {
531+
if (\PHP_VERSION_ID >= 70400) {
532+
throw $e;
533+
}
534+
531535
return trigger_error($e, E_USER_ERROR);
532536
}
533537

@@ -912,7 +916,7 @@ public function getClientIps()
912916
* ("Client-Ip" for instance), configure it via the $trustedHeaderSet
913917
* argument of the Request::setTrustedProxies() method instead.
914918
*
915-
* @return string The client IP address
919+
* @return string|null The client IP address
916920
*
917921
* @see getClientIps()
918922
* @see https://wikipedia.org/wiki/X-Forwarded-For

Response.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -407,7 +407,7 @@ public function setContent($content)
407407
/**
408408
* Gets the current response content.
409409
*
410-
* @return string Content
410+
* @return string|false
411411
*/
412412
public function getContent()
413413
{

Session/Attribute/NamespacedAttributeBag.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ public function remove($name)
9797
* @param string $name Key name
9898
* @param bool $writeContext Write context, default false
9999
*
100-
* @return array
100+
* @return array|null
101101
*/
102102
protected function &resolveAttributePath($name, $writeContext = false)
103103
{

Session/Storage/Handler/MemcachedSessionHandler.php

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,6 @@ class MemcachedSessionHandler extends AbstractSessionHandler
4040
* * prefix: The prefix to use for the memcached keys in order to avoid collision
4141
* * expiretime: The time to live in seconds.
4242
*
43-
* @param \Memcached $memcached A \Memcached instance
44-
* @param array $options An associative array of Memcached options
45-
*
4643
* @throws \InvalidArgumentException When unsupported options are passed
4744
*/
4845
public function __construct(\Memcached $memcached, array $options = [])
@@ -58,7 +55,7 @@ public function __construct(\Memcached $memcached, array $options = [])
5855
}
5956

6057
/**
61-
* {@inheritdoc}
58+
* @return bool
6259
*/
6360
public function close()
6461
{
@@ -74,7 +71,7 @@ protected function doRead($sessionId)
7471
}
7572

7673
/**
77-
* {@inheritdoc}
74+
* @return bool
7875
*/
7976
public function updateTimestamp($sessionId, $data)
8077
{
@@ -102,7 +99,7 @@ protected function doDestroy($sessionId)
10299
}
103100

104101
/**
105-
* {@inheritdoc}
102+
* @return bool
106103
*/
107104
public function gc($maxlifetime)
108105
{

Session/Storage/Handler/NullSessionHandler.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ protected function doDestroy($sessionId)
6767
}
6868

6969
/**
70-
* {@inheritdoc}
70+
* @return bool
7171
*/
7272
public function gc($maxlifetime)
7373
{

Session/Storage/Handler/PdoSessionHandler.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@ public function read($sessionId)
286286
}
287287

288288
/**
289-
* {@inheritdoc}
289+
* @return bool
290290
*/
291291
public function gc($maxlifetime)
292292
{

Session/Storage/Handler/StrictSessionHandler.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ public function close()
9494
}
9595

9696
/**
97-
* {@inheritdoc}
97+
* @return bool
9898
*/
9999
public function gc($maxlifetime)
100100
{

Session/Storage/Proxy/AbstractProxy.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ abstract class AbstractProxy
3131
/**
3232
* Gets the session.save_handler name.
3333
*
34-
* @return string
34+
* @return string|null
3535
*/
3636
public function getSaveHandlerName()
3737
{

Session/Storage/Proxy/SessionHandlerProxy.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ public function destroy($sessionId)
7676
}
7777

7878
/**
79-
* {@inheritdoc}
79+
* @return bool
8080
*/
8181
public function gc($maxlifetime)
8282
{

StreamedResponse.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,8 +136,6 @@ public function setContent($content)
136136

137137
/**
138138
* {@inheritdoc}
139-
*
140-
* @return false
141139
*/
142140
public function getContent()
143141
{

Tests/BinaryFileResponseTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ public function testRequests($requestRange, $offset, $length, $responseRange)
107107

108108
$this->assertEquals(206, $response->getStatusCode());
109109
$this->assertEquals($responseRange, $response->headers->get('Content-Range'));
110-
$this->assertSame($length, $response->headers->get('Content-Length'));
110+
$this->assertSame((string) $length, $response->headers->get('Content-Length'));
111111
}
112112

113113
/**

Tests/Session/Storage/Proxy/SessionHandlerProxyTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,8 @@ public function testUpdateTimestamp()
144144
{
145145
$mock = $this->getMockBuilder(['SessionHandlerInterface', 'SessionUpdateTimestampHandlerInterface'])->getMock();
146146
$mock->expects($this->once())
147-
->method('updateTimestamp');
147+
->method('updateTimestamp')
148+
->willReturn(false);
148149

149150
$proxy = new SessionHandlerProxy($mock);
150151
$proxy->updateTimestamp('id', 'data');

0 commit comments

Comments
 (0)