8000 minor #33410 [HttpFoundation] Add types to private/final/internal met… · symfony/symfony@26954bc · GitHub
[go: up one dir, main page]

Skip to content

Commit 26954bc

Browse files
minor #33410 [HttpFoundation] Add types to private/final/internal methods and constructors (derrabus)
This PR was merged into the 4.4 branch. Discussion ---------- [HttpFoundation] Add types to private/final/internal methods and constructors | Q | A | ------------- | --- | Branch? | 4.4 | Bug fix? | no | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #32179, #33228 | License | MIT | Doc PR | N/A Commits ------- 1978d88 [HttpFoundation] Add types to private/final/internal methods and constructors.
2 parents c79b45d + 1978d88 commit 26954bc

File tree

9 files changed

+19
-17
lines changed

9 files changed

+19
-17
lines changed

src/Symfony/Component/HttpFoundation/Request.php

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1817,12 +1817,12 @@ protected function prepareBaseUrl()
18171817
$requestUri = '/'.$requestUri;
18181818
}
18191819

1820-
if ($baseUrl && false !== $prefix = $this->getUrlencodedPrefix($requestUri, $baseUrl)) {
1820+
if ($baseUrl && null !== $prefix = $this->getUrlencodedPrefix($requestUri, $baseUrl)) {
18211821
// full $baseUrl matches
18221822
return $prefix;
18231823
}
18241824

1825-
if ($baseUrl && false !== $prefix = $this->getUrlencodedPrefix($requestUri, rtrim(\dirname($baseUrl), '/'.\DIRECTORY_SEPARATOR).'/')) {
1825+
if ($baseUrl && null !== $prefix = $this->getUrlencodedPrefix($requestUri, rtrim(\dirname($baseUrl), '/'.\DIRECTORY_SEPARATOR).'/')) {
18261826
// directory portion of $baseUrl matches
18271827
return rtrim($prefix, '/'.\DIRECTORY_SEPARATOR);
18281828
}
@@ -1941,14 +1941,12 @@ private function setPhpDefaultLocale(string $locale): void
19411941

19421942
/**
19431943
* Returns the prefix as encoded in the string when the string starts with
1944-
* the given prefix, false otherwise.
1945-
*
1946-
* @return string|false The prefix as it is encoded in $string, or false
1944+
* the given prefix, null otherwise.
19471945
*/
1948-
private function getUrlencodedPrefix(string $string, string $prefix)
1946+
private function getUrlencodedPrefix(string $string, string $prefix): ?string
19491947
{
19501948
if (0 !== strpos(rawurldecode($string), $prefix)) {
1951-
return false;
1949+
return null;
19521950
}
19531951

19541952
$len = \strlen($prefix);
@@ -1957,10 +1955,10 @@ private function getUrlencodedPrefix(string $string, string $prefix)
19571955
return $match[0];
19581956
}
19591957

1960-
return false;
1958+
return null;
19611959
}
19621960

1963-
private static function createRequestFromFactory(array $query = [], array $request = [], array $attributes = [], array $cookies = [], array $files = [], array $server = [], $content = null)
1961+
private static function createRequestFromFactory(array $query = [], array $request = [], array $attributes = [], array $cookies = [], array $files = [], array $server = [], $content = null): self
19641962
{
19651963
if (self::$requestFactory) {
19661964
$request = (self::$requestFactory)($query, $request, $attributes, $cookies, $files, $server, $content);

src/Symfony/Component/HttpFoundation/Session/SessionBagProxy.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ final class SessionBagProxy implements SessionBagInterface
2222
private $data;
2323
private $usageIndex;
2424

25-
public function __construct(SessionBagInterface $bag, array &$data, &$usageIndex)
25+
public function __construct(SessionBagInterface $bag, array &$data, ?int &$usageIndex)
2626
{
2727
$this->bag = $bag;
2828
$this->data = &$data;

src/Symfony/Component/HttpFoundation/Test/Constraint/RequestAttributeValueSame.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
namespace Symfony\Component\HttpFoundation\Test\Constraint;
1313

1414
use PHPUnit\Framework\Constraint\Constraint;
15+
use Symfony\Component\HttpFoundation\Request;
1516

1617
final class RequestAttributeValueSame extends Constraint
1718
{

src/Symfony/Component/HttpFoundation/Test/Constraint/ResponseHasCookie.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ protected function failureDescription($response): string
64< F438 code>64
return 'the Response '.$this->toString();
6565
}
6666

67-
protected function getCookie(Response $response): ?Cookie
67+
private function getCookie(Response $response): ?Cookie
6868
{
6969
$cookies = $response->headers->getCookies();
7070

src/Symfony/Component/HttpFoundation/Tests/RequestTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1803,7 +1803,7 @@ private function disableHttpMethodParameterOverride()
18031803
$property->setValue(false);
18041804
}
18051805

1806-
private function getRequestInstanceForClientIpTests($remoteAddr, $httpForwardedFor, $trustedProxies)
1806+
private function getRequestInstanceForClientIpTests(string $remoteAddr, ?string $httpForwardedFor, ?array $trustedProxies): Request
18071807
{
18081808
$request = new Request();
18091809

@@ -1821,7 +1821,7 @@ private function getRequestInstanceForClientIpTests($remoteAddr, $httpForwardedF
18211821
return $request;
18221822
}
18231823

1824-
private function getRequestInstanceForClientIpsForwardedTests($remoteAddr, $httpForwarded, $trustedProxies)
1824+
private function getRequestInstanceForClientIpsForwardedTests(string $remoteAddr, ?string $httpForwarded, ?array $trustedProxies): Request
18251825
{
18261826
$request = new Request();
18271827

src/Symfony/Component/HttpFoundation/Tests/ResponseHeaderBagTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,7 @@ public function testDateHeaderWillBeRecreatedWhenHeadersAreReplaced()
299299
$this->assertTrue($bag->has('Date'));
300300
}
301301

302-
private function assertSetCookieHeader($expected, ResponseHeaderBag $actual)
302+
private function assertSetCookieHeader(string $expected, ResponseHeaderBag $actual)
303303
{
304304
$this->assertRegExp('#^Set-Cookie:\s+'.preg_quote($expected, '#').'$#m', str_replace("\r\n", "\n", (string) $actual));
305305
}

src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/MongoDbSessionHandlerTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ public function testGetConnection()
197197
$this->assertInstanceOf(\MongoDB\Client::class, $method->invoke($this->storage));
198198
}
199199

200-
private function createMongoCollectionMock()
200+
private function createMongoCollectionMock(): \MongoDB\Collection
201201
{
202202
$collection = $this->getMockBuilder(\MongoDB\Collection::class)
203203
->disableOriginalConstructor()

src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/PdoSessionHandlerTest.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -346,6 +346,9 @@ public function provideUrlDsnPairs()
346346
yield ['mssql://localhost:56/test', 'sqlsrv:server=localhost,56;Database=test'];
347347
}
348348

349+
/**
350+
* @return resource
351+
*/
349352
private function createStream($content)
350353
{
351354
$stream = tmpfile();
@@ -362,7 +365,7 @@ class MockPdo extends \PDO
362365
private $driverName;
363366
private $errorMode;
364367

365-
public function __construct($driverName = null, $errorMode = null)
368+
public function __construct(string $driverName = null, int $errorMode = null)
366369
{
367370
$this->driverName = $driverName;
368371
$this->errorMode = null !== $errorMode ?: \PDO::ERRMODE_EXCEPTION;

src/Symfony/Component/HttpFoundation/Tests/Session/Storage/MockFileSessionStorageTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ public function testSaveWithoutStart()
114114
$storage1->save();
115115
}
116116

117-
private function getStorage()
117+
private function getStorage(): MockFileSessionStorage
118118
{
119119
$storage = new MockFileSessionStorage($this->sessionDir);
120120
$storage->registerBag(new FlashBag());

0 commit comments

Comments
 (0)
0