[HttpFoundation] fix return type declarations

This commit is contained in:
Nicolas Grekas 2019-08-21 18:20:57 +02:00
parent 1f7250139f
commit ef5ead0005
20 changed files with 31 additions and 29 deletions

View File

@ -327,12 +327,12 @@ class BinaryFileResponse extends Response
if (null !== $content) { if (null !== $content) {
throw new \LogicException('The content cannot be set on a BinaryFileResponse instance.'); throw new \LogicException('The content cannot be set on a BinaryFileResponse instance.');
} }
return $this;
} }
/** /**
* {@inheritdoc} * {@inheritdoc}
*
* @return false
*/ */
public function getContent() public function getContent()
{ {

View File

@ -75,8 +75,8 @@ class FileBag extends ParameterBag
return $file; return $file;
} }
$file = $this->fixPhpFilesArray($file);
if (\is_array($file)) { if (\is_array($file)) {
$file = $this->fixPhpFilesArray($file);
$keys = array_keys($file); $keys = array_keys($file);
sort($keys); sort($keys);
@ -109,14 +109,12 @@ class FileBag extends ParameterBag
* It's safe to pass an already converted array, in which case this method * It's safe to pass an already converted array, in which case this method
* just returns the original array unmodified. * just returns the original array unmodified.
* *
* @param array $data
*
* @return array * @return array
*/ */
protected function fixPhpFilesArray($data) protected function fixPhpFilesArray($data)
{ {
if (!\is_array($data)) {
return $data;
}
$keys = array_keys($data); $keys = array_keys($data);
sort($keys); sort($keys);

View File

@ -121,7 +121,7 @@ class HeaderBag implements \IteratorAggregate, \Countable
} }
if ($first) { if ($first) {
return \count($headers[$key]) ? $headers[$key][0] : $default; return \count($headers[$key]) ? (string) $headers[$key][0] : $default;
} }
return $headers[$key]; return $headers[$key];

View File

@ -528,6 +528,10 @@ class Request
try { try {
$content = $this->getContent(); $content = $this->getContent();
} catch (\LogicException $e) { } catch (\LogicException $e) {
if (\PHP_VERSION_ID >= 70400) {
throw $e;
}
return trigger_error($e, E_USER_ERROR); return trigger_error($e, E_USER_ERROR);
} }
@ -912,7 +916,7 @@ class Request
* ("Client-Ip" for instance), configure it via the $trustedHeaderSet * ("Client-Ip" for instance), configure it via the $trustedHeaderSet
* argument of the Request::setTrustedProxies() method instead. * argument of the Request::setTrustedProxies() method instead.
* *
* @return string The client IP address * @return string|null The client IP address
* *
* @see getClientIps() * @see getClientIps()
* @see https://wikipedia.org/wiki/X-Forwarded-For * @see https://wikipedia.org/wiki/X-Forwarded-For

View File

@ -407,7 +407,7 @@ class Response
/** /**
* Gets the current response content. * Gets the current response content.
* *
* @return string Content * @return string|false
*/ */
public function getContent() public function getContent()
{ {

View File

@ -97,7 +97,7 @@ class NamespacedAttributeBag extends AttributeBag
* @param string $name Key name * @param string $name Key name
* @param bool $writeContext Write context, default false * @param bool $writeContext Write context, default false
* *
* @return array * @return array|null
*/ */
protected function &resolveAttributePath($name, $writeContext = false) protected function &resolveAttributePath($name, $writeContext = false)
{ {

View File

@ -40,9 +40,6 @@ class MemcachedSessionHandler extends AbstractSessionHandler
* * prefix: The prefix to use for the memcached keys in order to avoid collision * * prefix: The prefix to use for the memcached keys in order to avoid collision
* * expiretime: The time to live in seconds. * * 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 * @throws \InvalidArgumentException When unsupported options are passed
*/ */
public function __construct(\Memcached $memcached, array $options = []) public function __construct(\Memcached $memcached, array $options = [])
@ -58,7 +55,7 @@ class MemcachedSessionHandler extends AbstractSessionHandler
} }
/** /**
* {@inheritdoc} * @return bool
*/ */
public function close() public function close()
{ {
@ -74,7 +71,7 @@ class MemcachedSessionHandler extends AbstractSessionHandler
} }
/** /**
* {@inheritdoc} * @return bool
*/ */
public function updateTimestamp($sessionId, $data) public function updateTimestamp($sessionId, $data)
{ {
@ -102,7 +99,7 @@ class MemcachedSessionHandler extends AbstractSessionHandler
} }
/** /**
* {@inheritdoc} * @return bool
*/ */
public function gc($maxlifetime) public function gc($maxlifetime)
{ {

View File

@ -67,7 +67,7 @@ class NullSessionHandler extends AbstractSessionHandler
} }
/** /**
* {@inheritdoc} * @return bool
*/ */
public function gc($maxlifetime) public function gc($maxlifetime)
{ {

View File

@ -286,7 +286,7 @@ class PdoSessionHandler extends AbstractSessionHandler
} }
/** /**
* {@inheritdoc} * @return bool
*/ */
public function gc($maxlifetime) public function gc($maxlifetime)
{ {

View File

@ -94,7 +94,7 @@ class StrictSessionHandler extends AbstractSessionHandler
} }
/** /**
* {@inheritdoc} * @return bool
*/ */
public function gc($maxlifetime) public function gc($maxlifetime)
{ {

View File

@ -31,7 +31,7 @@ abstract class AbstractProxy
/** /**
* Gets the session.save_handler name. * Gets the session.save_handler name.
* *
* @return string * @return string|null
*/ */
public function getSaveHandlerName() public function getSaveHandlerName()
{ {

View File

@ -76,7 +76,7 @@ class SessionHandlerProxy extends AbstractProxy implements \SessionHandlerInterf
} }
/** /**
* {@inheritdoc} * @return bool
*/ */
public function gc($maxlifetime) public function gc($maxlifetime)
{ {

View File

@ -136,8 +136,6 @@ class StreamedResponse extends Response
/** /**
* {@inheritdoc} * {@inheritdoc}
*
* @return false
*/ */
public function getContent() public function getContent()
{ {

View File

@ -107,7 +107,7 @@ class BinaryFileResponseTest extends ResponseTestCase
$this->assertEquals(206, $response->getStatusCode()); $this->assertEquals(206, $response->getStatusCode());
$this->assertEquals($responseRange, $response->headers->get('Content-Range')); $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'));
} }
/** /**

View File

@ -144,7 +144,8 @@ class SessionHandlerProxyTest extends TestCase
{ {
$mock = $this->getMockBuilder(['SessionHandlerInterface', 'SessionUpdateTimestampHandlerInterface'])->getMock(); $mock = $this->getMockBuilder(['SessionHandlerInterface', 'SessionUpdateTimestampHandlerInterface'])->getMock();
$mock->expects($this->once()) $mock->expects($this->once())
->method('updateTimestamp'); ->method('updateTimestamp')
->willReturn(false);
$proxy = new SessionHandlerProxy($mock); $proxy = new SessionHandlerProxy($mock);
$proxy->updateTimestamp('id', 'data'); $proxy->updateTimestamp('id', 'data');

View File

@ -22,6 +22,7 @@ use Symfony\Component\HttpKernel\Bundle\BundleInterface;
use Symfony\Component\HttpKernel\Config\EnvParametersResource; use Symfony\Component\HttpKernel\Config\EnvParametersResource;
use Symfony\Component\HttpKernel\DependencyInjection\ResettableServicePass; use Symfony\Component\HttpKernel\DependencyInjection\ResettableServicePass;
use Symfony\Component\HttpKernel\DependencyInjection\ServicesResetter; use Symfony\Component\HttpKernel\DependencyInjection\ServicesResetter;
use Symfony\Component\HttpKernel\HttpKernel;
use Symfony\Component\HttpKernel\HttpKernelInterface; use Symfony\Component\HttpKernel\HttpKernelInterface;
use Symfony\Component\HttpKernel\Kernel; use Symfony\Component\HttpKernel\Kernel;
use Symfony\Component\HttpKernel\Tests\Fixtures\KernelForOverrideName; use Symfony\Component\HttpKernel\Tests\Fixtures\KernelForOverrideName;

View File

@ -22,6 +22,9 @@ class Logger implements LoggerInterface
$this->clear(); $this->clear();
} }
/**
* @return array
*/
public function getLogs($level = false) public function getLogs($level = false)
{ {
return false === $level ? $this->logs : $this->logs[$level]; return false === $level ? $this->logs : $this->logs[$level];

View File

@ -71,7 +71,7 @@ class Process implements \IteratorAggregate
private $status = self::STATUS_READY; private $status = self::STATUS_READY;
private $incrementalOutputOffset = 0; private $incrementalOutputOffset = 0;
private $incrementalErrorOutputOffset = 0; private $incrementalErrorOutputOffset = 0;
private $tty; private $tty = false;
private $pty; private $pty;
private $inheritEnv = false; private $inheritEnv = false;

View File

@ -46,7 +46,7 @@ interface RememberMeServicesInterface
* make sure to throw an AuthenticationException as this will consequentially * make sure to throw an AuthenticationException as this will consequentially
* result in a call to loginFail() and therefore an invalidation of the cookie. * result in a call to loginFail() and therefore an invalidation of the cookie.
* *
* @return TokenInterface * @return TokenInterface|null
*/ */
public function autoLogin(Request $request); public function autoLogin(Request $request);

View File

@ -35,7 +35,7 @@ abstract class AbstractDumper implements DataDumperInterface, DumperInterface
protected $indentPad = ' '; protected $indentPad = ' ';
protected $flags; protected $flags;
private $charset; private $charset = '';
/** /**
* @param callable|resource|string|null $output A line dumper callable, an opened stream or an output path, defaults to static::$defaultOutput * @param callable|resource|string|null $output A line dumper callable, an opened stream or an output path, defaults to static::$defaultOutput