Skip to content

Commit 17f15b3

Browse files
minor #33112 [HttpFoundation] some cleanups (azjezz)
This PR was merged into the 4.4 branch. Discussion ---------- [HttpFoundation] some cleanups | Q | A | ------------- | --- | Branch? | 4.4 | Bug fix? | no | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | - | License | MIT | Doc PR | - As found by @azjezz in #33088 Commits ------- f62a3c0 [HttpFoundation] some cleanups
2 parents e37f672 + f62a3c0 commit 17f15b3

23 files changed

+40
-70
lines changed

src/Symfony/Component/HttpFoundation/AcceptHeader.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ public function first()
153153
/**
154154
* Sorts items by descending quality.
155155
*/
156-
private function sort()
156+
private function sort(): void
157157
{
158158
if (!$this->sorted) {
159159
uasort($this->items, function (AcceptHeaderItem $a, AcceptHeaderItem $b) {

src/Symfony/Component/HttpFoundation/BinaryFileResponse.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ public function prepare(Request $request)
269269
return $this;
270270
}
271271

272-
private function hasValidIfRangeHeader(?string $header)
272+
private function hasValidIfRangeHeader(?string $header): bool
273273
{
274274
if ($this->getEtag() === $header) {
275275
return true;

src/Symfony/Component/HttpFoundation/File/Exception/AccessDeniedException.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,6 @@
1818
*/
1919
class AccessDeniedException extends FileException
2020
{
21-
/**
22-
* @param string $path The path to the accessed file
23-
*/
2421
public function __construct(string $path)
2522
{
2623
parent::__construct(sprintf('The file %s could not be accessed', $path));

src/Symfony/Component/HttpFoundation/File/Exception/FileNotFoundException.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,6 @@
1818
*/
1919
class FileNotFoundException extends FileException
2020
{
21-
/**
22-
* @param string $path The path to the file that was not found
23-
*/
2421
public function __construct(string $path)
2522
{
2623
parent::__construct(sprintf('The file "%s" does not exist', $path));

src/Symfony/Component/HttpFoundation/File/File.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,9 @@ public function move($directory, $name = null)
9999
return $target;
100100
}
101101

102+
/**
103+
* @return self
104+
*/
102105
protected function getTargetFile($directory, $name = null)
103106
{
104107
if (!is_dir($directory)) {
@@ -119,7 +122,7 @@ protected function getTargetFile($directory, $name = null)
119122
*
120123
* @param string $name The new file name
121124
*
122-
* @return string containing
125+
* @return string
123126
*/
124127
protected function getName($name)
125128
{

src/Symfony/Component/HttpFoundation/FileBag.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class FileBag extends ParameterBag
2424
private static $fileKeys = ['error', 'name', 'size', 'tmp_name', 'type'];
2525

2626
/**
27-
* @param array $parameters An array of HTTP files
27+
* @param array|UploadedFile[] $parameters An array of HTTP files
2828
*/
2929
public function __construct(array $parameters = [])
3030
{

src/Symfony/Component/HttpFoundation/HeaderBag.php

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,6 @@ class HeaderBag implements \IteratorAggregate, \Countable
2121
protected $headers = [];
2222
protected $cacheControl = [];
2323

24-
/**
25-
* @param array $headers An array of HTTP headers
26-
*/
2724
public function __construct(array $headers = [])
2825
{
2926
foreach ($headers as $key => $values) {
@@ -85,8 +82,6 @@ public function keys()
8582

8683
/**
8784
* Replaces the current HTTP headers by a new set.
88-
*
89-
* @param array $headers An array of HTTP headers
9085
*/
9186
public function replace(array $headers = [])
9287
{
@@ -96,8 +91,6 @@ public function replace(array $headers = [])
9691

9792
/**
9893
* Adds new headers the current HTTP headers set.
99-
*
100-
* @param array $headers An array of HTTP headers
10194
*/
10295
public function add(array $headers)
10396
{
@@ -204,10 +197,9 @@ public function remove($key)
204197
/**
205198
* Returns the HTTP header value converted to a date.
206199
*
207-
* @param string $key The parameter key
208-
* @param \DateTime $default The default value
200+
* @param string $key The parameter key
209201
*
210-
* @return \DateTime|null The parsed DateTime or the default value if the header does not exist
202+
* @return \DateTimeInterface|null The parsed DateTime or the default value if the header does not exist
211203
*
212204
* @throws \RuntimeException When the HTTP header is not parseable
213205
*/

src/Symfony/Component/HttpFoundation/ParameterBag.php

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,6 @@ class ParameterBag implements \IteratorAggregate, \Countable
2323
*/
2424
protected $parameters;
2525

26-
/**
27-
* @param array $parameters An array of parameters
28-
*/
2926
public function __construct(array $parameters = [])
3027
{
3128
$this->parameters = $parameters;
@@ -53,8 +50,6 @@ public function keys()
5350

5451
/**
5552
* Replaces the current parameters by a new set.
56-
*
57-
* @param array $parameters An array of parameters
5853
*/
5954
public function replace(array $parameters = [])
6055
{
@@ -63,8 +58,6 @@ public function replace(array $parameters = [])
6358

6459
/**
6560
* Adds parameters.
66-
*
67-
* @param array $parameters An array of parameters
6861
*/
6962
public function add(array $parameters = [])
7063
{

src/Symfony/Component/HttpFoundation/Request.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -632,7 +632,7 @@ public static function getTrustedHosts()
632632
*/
633633
public static function normalizeQueryString($qs)
634634
{
635-
if ('' == $qs) {
635+
if ('' === ($qs ?? '')) {
636636
return '';
637637
}
638638

@@ -702,7 +702,7 @@ public function get($key, $default = null)
702702
/**
703703
* Gets the Session.
704704
*
705-
* @return SessionInterface|null The session
705+
* @return SessionInterface The session
706706
*/
707707
public function getSession()
708708
{
@@ -1591,7 +1591,7 @@ public function getPreferredFormat(?string $default = 'html'): ?string
15911591
/**
15921592
* Returns the preferred language.
15931593
*
1594-
* @param array $locales An array of ordered available locales
1594+
* @param string[] $locales An array of ordered available locales
15951595
*
15961596
* @return string|null The preferred locale
15971597
*/
@@ -1920,7 +1920,7 @@ protected static function initializeFormats()
19201920
];
19211921
}
19221922

1923-
private function setPhpDefaultLocale(string $locale)
1923+
private function setPhpDefaultLocale(string $locale): void
19241924
{
19251925
// if either the class Locale doesn't exist, or an exception is thrown when
19261926
// setting the default locale, the intl module is not installed, and
@@ -1982,7 +1982,7 @@ public function isFromTrustedProxy()
19821982
return self::$trustedProxies && IpUtils::checkIp($this->server->get('REMOTE_ADDR'), self::$trustedProxies);
19831983
}
19841984

1985-
private function getTrustedValues(int $type, string $ip = null)
1985+
private function getTrustedValues(int $type, string $ip = null): array
19861986
{
19871987
$clientValues = [];
19881988
$forwardedValues = [];
@@ -2033,7 +2033,7 @@ private function getTrustedValues(int $type, string $ip = null)
20332033
throw new ConflictingHeadersException(sprintf('The request has both a trusted "%s" header and a trusted "%s" header, conflicting with each other. You should either configure your proxy to remove one of them, or configure your project to distrust the offending one.', self::$trustedHeaders[self::HEADER_FORWARDED], self::$trustedHeaders[$type]));
20342034
}
20352035

2036-
private function normalizeAndFilterClientIps(array $clientIps, string $ip)
2036+
private function normalizeAndFilterClientIps(array $clientIps, string $ip): array
20372037
{
20382038
if (!$clientIps) {
20392039
return [];

src/Symfony/Component/HttpFoundation/RequestMatcher.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,8 @@ class RequestMatcher implements RequestMatcherInterface
5454
private $schemes = [];
5555

5656
/**
57-
* @param string|null $path
58-
* @param string|null $host
5957
* @param string|string[]|null $methods
6058
* @param string|string[]|null $ips
61-
* @param array $attributes
6259
* @param string|string[]|null $schemes
6360
*/
6461
public function __construct(string $path = null, string $host = null, $methods = null, $ips = null, array $attributes = [], $schemes = null, int $port = null)

0 commit comments

Comments
 (0)