Skip to content

Commit

Permalink
[HttpFoundation] fix return type declarations
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolas-grekas committed Aug 26, 2019
1 parent 9781d8d commit b3d57a1
Show file tree
Hide file tree
Showing 15 changed files with 24 additions and 26 deletions.
4 changes: 2 additions & 2 deletions BinaryFileResponse.php
Expand Up @@ -327,12 +327,12 @@ public function setContent($content)
if (null !== $content) {
throw new \LogicException('The content cannot be set on a BinaryFileResponse instance.');
}

return $this;
}

/**
* {@inheritdoc}
*
* @return false
*/
public function getContent()
{
Expand Down
8 changes: 3 additions & 5 deletions FileBag.php
Expand Up @@ -75,8 +75,8 @@ protected function convertFileInformation($file)
return $file;
}

$file = $this->fixPhpFilesArray($file);
if (\is_array($file)) {
$file = $this->fixPhpFilesArray($file);
$keys = array_keys($file);
sort($keys);

Expand Down Expand Up @@ -109,14 +109,12 @@ protected function convertFileInformation($file)
* It's safe to pass an already converted array, in which case this method
* just returns the original array unmodified.
*
* @param array $data
*
* @return array
*/
protected function fixPhpFilesArray($data)
{
if (!\is_array($data)) {
return $data;
}

$keys = array_keys($data);
sort($keys);

Expand Down
2 changes: 1 addition & 1 deletion HeaderBag.php
Expand Up @@ -121,7 +121,7 @@ public function get($key, $default = null, $first = true)
}

if ($first) {
return \count($headers[$key]) ? $headers[$key][0] : $default;
return \count($headers[$key]) ? (string) $headers[$key][0] : $default;
}

return $headers[$key];
Expand Down
6 changes: 5 additions & 1 deletion Request.php
Expand Up @@ -528,6 +528,10 @@ public function __toString()
try {
$content = $this->getContent();
} catch (\LogicException $e) {
if (\PHP_VERSION_ID >= 70400) {
throw $e;
}

return trigger_error($e, E_USER_ERROR);
}

Expand Down Expand Up @@ -912,7 +916,7 @@ public function getClientIps()
* ("Client-Ip" for instance), configure it via the $trustedHeaderSet
* argument of the Request::setTrustedProxies() method instead.
*
* @return string The client IP address
* @return string|null The client IP address
*
* @see getClientIps()
* @see https://wikipedia.org/wiki/X-Forwarded-For
Expand Down
2 changes: 1 addition & 1 deletion Response.php
Expand Up @@ -407,7 +407,7 @@ public function setContent($content)
/**
* Gets the current response content.
*
* @return string Content
* @return string|false
*/
public function getContent()
{
Expand Down
2 changes: 1 addition & 1 deletion Session/Attribute/NamespacedAttributeBag.php
Expand Up @@ -97,7 +97,7 @@ public function remove($name)
* @param string $name Key name
* @param bool $writeContext Write context, default false
*
* @return array
* @return array|null
*/
protected function &resolveAttributePath($name, $writeContext = false)
{
Expand Down
9 changes: 3 additions & 6 deletions Session/Storage/Handler/MemcachedSessionHandler.php
Expand Up @@ -40,9 +40,6 @@ class MemcachedSessionHandler extends AbstractSessionHandler
* * prefix: The prefix to use for the memcached keys in order to avoid collision
* * expiretime: The time to live in seconds.
*
* @param \Memcached $memcached A \Memcached instance
* @param array $options An associative array of Memcached options
*
* @throws \InvalidArgumentException When unsupported options are passed
*/
public function __construct(\Memcached $memcached, array $options = [])
Expand All @@ -58,7 +55,7 @@ public function __construct(\Memcached $memcached, array $options = [])
}

/**
* {@inheritdoc}
* @return bool
*/
public function close()
{
Expand All @@ -74,7 +71,7 @@ protected function doRead($sessionId)
}

/**
* {@inheritdoc}
* @return bool
*/
public function updateTimestamp($sessionId, $data)
{
Expand Down Expand Up @@ -102,7 +99,7 @@ protected function doDestroy($sessionId)
}

/**
* {@inheritdoc}
* @return bool
*/
public function gc($maxlifetime)
{
Expand Down
2 changes: 1 addition & 1 deletion Session/Storage/Handler/NullSessionHandler.php
Expand Up @@ -67,7 +67,7 @@ protected function doDestroy($sessionId)
}

/**
* {@inheritdoc}
* @return bool
*/
public function gc($maxlifetime)
{
Expand Down
2 changes: 1 addition & 1 deletion Session/Storage/Handler/PdoSessionHandler.php
Expand Up @@ -286,7 +286,7 @@ public function read($sessionId)
}

/**
* {@inheritdoc}
* @return bool
*/
public function gc($maxlifetime)
{
Expand Down
2 changes: 1 addition & 1 deletion Session/Storage/Handler/StrictSessionHandler.php
Expand Up @@ -94,7 +94,7 @@ public function close()
}

/**
* {@inheritdoc}
* @return bool
*/
public function gc($maxlifetime)
{
Expand Down
2 changes: 1 addition & 1 deletion Session/Storage/Proxy/AbstractProxy.php
Expand Up @@ -31,7 +31,7 @@ abstract class AbstractProxy
/**
* Gets the session.save_handler name.
*
* @return string
* @return string|null
*/
public function getSaveHandlerName()
{
Expand Down
2 changes: 1 addition & 1 deletion Session/Storage/Proxy/SessionHandlerProxy.php
Expand Up @@ -76,7 +76,7 @@ public function destroy($sessionId)
}

/**
* {@inheritdoc}
* @return bool
*/
public function gc($maxlifetime)
{
Expand Down
2 changes: 0 additions & 2 deletions StreamedResponse.php
Expand Up @@ -136,8 +136,6 @@ public function setContent($content)

/**
* {@inheritdoc}
*
* @return false
*/
public function getContent()
{
Expand Down
2 changes: 1 addition & 1 deletion Tests/BinaryFileResponseTest.php
Expand Up @@ -107,7 +107,7 @@ public function testRequests($requestRange, $offset, $length, $responseRange)

$this->assertEquals(206, $response->getStatusCode());
$this->assertEquals($responseRange, $response->headers->get('Content-Range'));
$this->assertSame($length, $response->headers->get('Content-Length'));
$this->assertSame((string) $length, $response->headers->get('Content-Length'));
}

/**
Expand Down
3 changes: 2 additions & 1 deletion Tests/Session/Storage/Proxy/SessionHandlerProxyTest.php
Expand Up @@ -144,7 +144,8 @@ public function testUpdateTimestamp()
{
$mock = $this->getMockBuilder(['SessionHandlerInterface', 'SessionUpdateTimestampHandlerInterface'])->getMock();
$mock->expects($this->once())
->method('updateTimestamp');
->method('updateTimestamp')
->willReturn(false);

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

0 comments on commit b3d57a1

Please sign in to comment.