[HttpFoundation] Add types to private/final/internal methods and constructors.
This commit is contained in:
parent
afad96285e
commit
1978d88f1b
@ -1817,12 +1817,12 @@ class Request
|
||||
$requestUri = '/'.$requestUri;
|
||||
}
|
||||
|
||||
if ($baseUrl && false !== $prefix = $this->getUrlencodedPrefix($requestUri, $baseUrl)) {
|
||||
if ($baseUrl && null !== $prefix = $this->getUrlencodedPrefix($requestUri, $baseUrl)) {
|
||||
// full $baseUrl matches
|
||||
return $prefix;
|
||||
}
|
||||
|
||||
if ($baseUrl && false !== $prefix = $this->getUrlencodedPrefix($requestUri, rtrim(\dirname($baseUrl), '/'.\DIRECTORY_SEPARATOR).'/')) {
|
||||
if ($baseUrl && null !== $prefix = $this->getUrlencodedPrefix($requestUri, rtrim(\dirname($baseUrl), '/'.\DIRECTORY_SEPARATOR).'/')) {
|
||||
// directory portion of $baseUrl matches
|
||||
return rtrim($prefix, '/'.\DIRECTORY_SEPARATOR);
|
||||
}
|
||||
@ -1941,14 +1941,12 @@ class Request
|
||||
|
||||
/**
|
||||
* Returns the prefix as encoded in the string when the string starts with
|
||||
* the given prefix, false otherwise.
|
||||
*
|
||||
* @return string|false The prefix as it is encoded in $string, or false
|
||||
* the given prefix, null otherwise.
|
||||
*/
|
||||
private function getUrlencodedPrefix(string $string, string $prefix)
|
||||
private function getUrlencodedPrefix(string $string, string $prefix): ?string
|
||||
{
|
||||
if (0 !== strpos(rawurldecode($string), $prefix)) {
|
||||
return false;
|
||||
return null;
|
||||
}
|
||||
|
||||
$len = \strlen($prefix);
|
||||
@ -1957,10 +1955,10 @@ class Request
|
||||
return $match[0];
|
||||
}
|
||||
|
||||
return false;
|
||||
return null;
|
||||
}
|
||||
|
||||
private static function createRequestFromFactory(array $query = [], array $request = [], array $attributes = [], array $cookies = [], array $files = [], array $server = [], $content = null)
|
||||
private static function createRequestFromFactory(array $query = [], array $request = [], array $attributes = [], array $cookies = [], array $files = [], array $server = [], $content = null): self
|
||||
{
|
||||
if (self::$requestFactory) {
|
||||
$request = (self::$requestFactory)($query, $request, $attributes, $cookies, $files, $server, $content);
|
||||
|
@ -22,7 +22,7 @@ final class SessionBagProxy implements SessionBagInterface
|
||||
private $data;
|
||||
private $usageIndex;
|
||||
|
||||
public function __construct(SessionBagInterface $bag, array &$data, &$usageIndex)
|
||||
public function __construct(SessionBagInterface $bag, array &$data, ?int &$usageIndex)
|
||||
{
|
||||
$this->bag = $bag;
|
||||
$this->data = &$data;
|
||||
|
@ -12,6 +12,7 @@
|
||||
namespace Symfony\Component\HttpFoundation\Test\Constraint;
|
||||
|
||||
use PHPUnit\Framework\Constraint\Constraint;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
|
||||
final class RequestAttributeValueSame extends Constraint
|
||||
{
|
||||
|
@ -64,7 +64,7 @@ final class ResponseHasCookie extends Constraint
|
||||
return 'the Response '.$this->toString();
|
||||
}
|
||||
|
||||
protected function getCookie(Response $response): ?Cookie
|
||||
private function getCookie(Response $response): ?Cookie
|
||||
{
|
||||
$cookies = $response->headers->getCookies();
|
||||
|
||||
|
@ -1803,7 +1803,7 @@ class RequestTest extends TestCase
|
||||
$property->setValue(false);
|
||||
}
|
||||
|
||||
private function getRequestInstanceForClientIpTests($remoteAddr, $httpForwardedFor, $trustedProxies)
|
||||
private function getRequestInstanceForClientIpTests(string $remoteAddr, ?string $httpForwardedFor, ?array $trustedProxies): Request
|
||||
{
|
||||
$request = new Request();
|
||||
|
||||
@ -1821,7 +1821,7 @@ class RequestTest extends TestCase
|
||||
return $request;
|
||||
}
|
||||
|
||||
private function getRequestInstanceForClientIpsForwardedTests($remoteAddr, $httpForwarded, $trustedProxies)
|
||||
private function getRequestInstanceForClientIpsForwardedTests(string $remoteAddr, ?string $httpForwarded, ?array $trustedProxies): Request
|
||||
{
|
||||
$request = new Request();
|
||||
|
||||
|
@ -299,7 +299,7 @@ class ResponseHeaderBagTest extends TestCase
|
||||
$this->assertTrue($bag->has('Date'));
|
||||
}
|
||||
|
||||
private function assertSetCookieHeader($expected, ResponseHeaderBag $actual)
|
||||
private function assertSetCookieHeader(string $expected, ResponseHeaderBag $actual)
|
||||
{
|
||||
$this->assertRegExp('#^Set-Cookie:\s+'.preg_quote($expected, '#').'$#m', str_replace("\r\n", "\n", (string) $actual));
|
||||
}
|
||||
|
@ -197,7 +197,7 @@ class MongoDbSessionHandlerTest extends TestCase
|
||||
$this->assertInstanceOf(\MongoDB\Client::class, $method->invoke($this->storage));
|
||||
}
|
||||
|
||||
private function createMongoCollectionMock()
|
||||
private function createMongoCollectionMock(): \MongoDB\Collection
|
||||
{
|
||||
$collection = $this->getMockBuilder(\MongoDB\Collection::class)
|
||||
->disableOriginalConstructor()
|
||||
|
@ -346,6 +346,9 @@ class PdoSessionHandlerTest extends TestCase
|
||||
yield ['mssql://localhost:56/test', 'sqlsrv:server=localhost,56;Database=test'];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return resource
|
||||
*/
|
||||
private function createStream($content)
|
||||
{
|
||||
$stream = tmpfile();
|
||||
@ -362,7 +365,7 @@ class MockPdo extends \PDO
|
||||
private $driverName;
|
||||
private $errorMode;
|
||||
|
||||
public function __construct($driverName = null, $errorMode = null)
|
||||
public function __construct(string $driverName = null, int $errorMode = null)
|
||||
{
|
||||
$this->driverName = $driverName;
|
||||
$this->errorMode = null !== $errorMode ?: \PDO::ERRMODE_EXCEPTION;
|
||||
|
@ -114,7 +114,7 @@ class MockFileSessionStorageTest extends TestCase
|
||||
$storage1->save();
|
||||
}
|
||||
|
||||
private function getStorage()
|
||||
private function getStorage(): MockFileSessionStorage
|
||||
{
|
||||
$storage = new MockFileSessionStorage($this->sessionDir);
|
||||
$storage->registerBag(new FlashBag());
|
||||
|
Reference in New Issue
Block a user