Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 17f15b3

Browse filesBrowse 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
Copy full SHA for 17f15b3

23 files changed

+40
-70
lines changed

‎src/Symfony/Component/HttpFoundation/AcceptHeader.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/HttpFoundation/AcceptHeader.php
+1-1Lines 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

Copy file name to clipboardExpand all lines: src/Symfony/Component/HttpFoundation/BinaryFileResponse.php
+1-1Lines 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

Copy file name to clipboardExpand all lines: src/Symfony/Component/HttpFoundation/File/Exception/AccessDeniedException.php
-3Lines 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

Copy file name to clipboardExpand all lines: src/Symfony/Component/HttpFoundation/File/Exception/FileNotFoundException.php
-3Lines 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

Copy file name to clipboardExpand all lines: src/Symfony/Component/HttpFoundation/File/File.php
+4-1Lines 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

Copy file name to clipboardExpand all lines: src/Symfony/Component/HttpFoundation/FileBag.php
+1-1Lines 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

Copy file name to clipboardExpand all lines: src/Symfony/Component/HttpFoundation/HeaderBag.php
+2-10Lines 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

Copy file name to clipboardExpand all lines: src/Symfony/Component/HttpFoundation/ParameterBag.php
-7Lines 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

Copy file name to clipboardExpand all lines: src/Symfony/Component/HttpFoundation/Request.php
+6-6Lines 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

Copy file name to clipboardExpand all lines: src/Symfony/Component/HttpFoundation/RequestMatcher.php
-3Lines 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)

‎src/Symfony/Component/HttpFoundation/Response.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/HttpFoundation/Response.php
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1208,7 +1208,7 @@ public function isEmpty(): bool
12081208
*
12091209
* @final
12101210
*/
1211-
public static function closeOutputBuffers(int $targetLevel, bool $flush)
1211+
public static function closeOutputBuffers(int $targetLevel, bool $flush): void
12121212
{
12131213
$status = ob_get_status(true);
12141214
$level = \count($status);
@@ -1230,7 +1230,7 @@ public static function closeOutputBuffers(int $targetLevel, bool $flush)
12301230
*
12311231
* @final
12321232
*/
1233-
protected function ensureIEOverSSLCompatibility(Request $request)
1233+
protected function ensureIEOverSSLCompatibility(Request $request): void
12341234
{
12351235
if (false !== stripos($this->headers->get('Content-Disposition'), 'attachment') && 1 == preg_match('/MSIE (.*?);/i', $request->server->get('HTTP_USER_AGENT'), $match) && true === $request->isSecure()) {
12361236
if ((int) preg_replace('/(MSIE )(.*?);/', '$2', $match[0]) < 9) {

‎src/Symfony/Component/HttpFoundation/ResponseHeaderBag.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/HttpFoundation/ResponseHeaderBag.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,7 @@ protected function computeCacheControlValue()
298298
return $header;
299299
}
300300

301-
private function initDate()
301+
private function initDate(): void
302302
{
303303
$now = \DateTime::createFromFormat('U', time());
304304
$now->setTimezone(new \DateTimeZone('UTC'));

‎src/Symfony/Component/HttpFoundation/Session/Attribute/AttributeBagInterface.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/HttpFoundation/Session/Attribute/AttributeBagInterface.php
+1-6Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,15 +50,10 @@ public function set($name, $value);
5050
/**
5151
* Returns attributes.
5252
*
53-
* @return array Attributes
53+
* @return array
5454
*/
5555
public function all();
5656

57-
/**
58-
* Sets attributes.
59-
*
60-
* @param array $attributes Attributes
61-
*/
6257
public function replace(array $attributes);
6358

6459
/**

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

Copy file name to clipboardExpand all lines: src/Symfony/Component/HttpFoundation/Session/Session.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ public function getIterator()
129129
/**
130130
* Returns the number of attributes.
131131
*
132-
* @return int The number of attributes
132+
* @return int
133133
*/
134134
public function count()
135135
{

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

Copy file name to clipboardExpand all lines: src/Symfony/Component/HttpFoundation/Session/SessionBagProxy.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ public function getName()
6363
/**
6464
* {@inheritdoc}
6565
*/
66-
public function initialize(array &$array)
66+
public function initialize(array &$array): void
6767
{
6868
++$this->usageIndex;
6969
$this->data[$this->bag->getStorageKey()] = &$array;

‎src/Symfony/Component/HttpFoundation/Session/SessionInterface.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/HttpFoundation/Session/SessionInterface.php
+7-9Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ interface SessionInterface
2323
/**
2424
* Starts the session storage.
2525
*
26-
* @return bool True if session started
26+
* @return bool
2727
*
2828
* @throws \RuntimeException if session fails to start
2929
*/
@@ -32,7 +32,7 @@ public function start();
3232
/**
3333
* Returns the session ID.
3434
*
35-
* @return string The session ID
35+
* @return string
3636
*/
3737
public function getId();
3838

@@ -46,7 +46,7 @@ public function setId($id);
4646
/**
4747
* Returns the session name.
4848
*
49-
* @return mixed The session name
49+
* @return string
5050
*/
5151
public function getName();
5252

@@ -68,7 +68,7 @@ public function setName($name);
6868
* to expire with browser session. Time is in seconds, and is
6969
* not a Unix timestamp.
7070
*
71-
* @return bool True if session invalidated, false if error
71+
* @return bool
7272
*/
7373
public function invalidate($lifetime = null);
7474

@@ -82,7 +82,7 @@ public function invalidate($lifetime = null);
8282
* to expire with browser session. Time is in seconds, and is
8383
* not a Unix timestamp.
8484
*
85-
* @return bool True if session migrated, false if error
85+
* @return bool
8686
*/
8787
public function migrate($destroy = false, $lifetime = null);
8888

@@ -100,7 +100,7 @@ public function save();
100100
*
101101
* @param string $name The attribute name
102102
*
103-
* @return bool true if the attribute is defined, false otherwise
103+
* @return bool
104104
*/
105105
public function has($name);
106106

@@ -125,14 +125,12 @@ public function set($name, $value);
125125
/**
126126
* Returns attributes.
127127
*
128-
* @return array Attributes
128+
* @return array
129129
*/
130130
public function all();
131131

132132
/**
133133
* Sets attributes.
134-
*
135-
* @param array $attributes Attributes
136134
*/
137135
public function replace(array $attributes);
138136

‎src/Symfony/Component/HttpFoundation/Session/Storage/Handler/MemcachedSessionHandler.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/HttpFoundation/Session/Storage/Handler/MemcachedSessionHandler.php
-2Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,6 @@ class MemcachedSessionHandler extends AbstractSessionHandler
4040
* * prefix: The prefix to use for the memcached keys in order to avoid collision
4141
* * expiretime: The time to live in seconds.
4242
*
43-
* @param \Memcached $memcached A \Memcached instance
44-
*
4543
* @throws \InvalidArgumentException When unsupported options are passed
4644
*/
4745
public function __construct(\Memcached $memcached, array $options = [])

‎src/Symfony/Component/HttpFoundation/Session/Storage/Handler/PdoSessionHandler.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/HttpFoundation/Session/Storage/Handler/PdoSessionHandler.php
+4-4Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -423,7 +423,7 @@ public function close()
423423
/**
424424
* Lazy-connects to the database.
425425
*/
426-
private function connect(string $dsn)
426+
private function connect(string $dsn): void
427427
{
428428
$this->pdo = new \PDO($dsn, $this->username, $this->password, $this->connectionOptions);
429429
$this->pdo->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION);
@@ -534,7 +534,7 @@ private function buildDsnFromUrl(string $dsnOrUrl): string
534534
* due to https://percona.com/blog/2013/12/12/one-more-innodb-gap-lock-to-avoid/ .
535535
* So we change it to READ COMMITTED.
536536
*/
537-
private function beginTransaction()
537+
private function beginTransaction(): void
538538
{
539539
if (!$this->inTransaction) {
540540
if ('sqlite' === $this->driver) {
@@ -552,7 +552,7 @@ private function beginTransaction()
552552
/**
553553
* Helper method to commit a transaction.
554554
*/
555-
private function commit()
555+
private function commit(): void
556556
{
557557
if ($this->inTransaction) {
558558
try {
@@ -574,7 +574,7 @@ private function commit()
574574
/**
575575
* Helper method to rollback a transaction.
576576
*/
577-
private function rollback()
577+
private function rollback(): void
578578
{
579579
// We only need to rollback if we are in a transaction. Otherwise the resulting
580580
// error would hide the real problem why rollback was called. We might not be

‎src/Symfony/Component/HttpFoundation/Session/Storage/MetadataBag.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/HttpFoundation/Session/Storage/MetadataBag.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ public function setName($name)
159159
$this->name = $name;
160160
}
161161

162-
private function stampCreated(int $lifetime = null)
162+
private function stampCreated(int $lifetime = null): void
163163
{
164164
$timeStamp = time();
165165
$this->meta[self::CREATED] = $this->meta[self::UPDATED] = $this->lastUsed = $timeStamp;

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.