Skip to content

Commit 77846ae

Browse files
Merge branch '5.2' into 5.3
* 5.2: Backport type fixes Fix CS Avoid triggering the autoloader in Deprecation::isLegacy() fix markdown markup Backport type fixes uzb translation [DependencyInjection] Fix doc blocks [DependencyInjection] Turn $defaultDeprecationTemplate into a constant [Form] better form doc types to support static analysis
2 parents 8c1e8fe + 4cb86d0 commit 77846ae

File tree

7 files changed

+24
-28
lines changed

7 files changed

+24
-28
lines changed

File/UploadedFile.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ public static function getMaxFilesize()
231231
*
232232
* @return int|float Returns float if size > PHP_INT_MAX
233233
*/
234-
private static function parseFilesize($size)
234+
private static function parseFilesize(string $size)
235235
{
236236
if ('' === $size) {
237237
return 0;

FileBag.php

Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -75,22 +75,20 @@ protected function convertFileInformation($file)
7575
return $file;
7676
}
7777

78-
if (\is_array($file)) {
79-
$file = $this->fixPhpFilesArray($file);
80-
$keys = array_keys($file);
81-
sort($keys);
82-
83-
if (self::FILE_KEYS == $keys) {
84-
if (\UPLOAD_ERR_NO_FILE == $file['error']) {
85-
$file = null;
86-
} else {
87-
$file = new UploadedFile($file['tmp_name'], $file['name'], $file['type'], $file['error'], false);
88-
}
78+
$file = $this->fixPhpFilesArray($file);
79+
$keys = array_keys($file);
80+
sort($keys);
81+
82+
if (self::FILE_KEYS == $keys) {
83+
if (\UPLOAD_ERR_NO_FILE == $file['error']) {
84+
$file = null;
8985
} else {
90-
$file = array_map([$this, 'convertFileInformation'], $file);
91-
if (array_keys($keys) === $keys) {
92-
$file = array_filter($file);
93-
}
86+
$file = new UploadedFile($file['tmp_name'], $file['name'], $file['type'], $file['error'], false);
87+
}
88+
} else {
89+
$file = array_map(function ($v) { return $v instanceof UploadedFile || \is_array($v) ? $this->convertFileInformation($v) : $v; }, $file);
90+
if (array_keys($keys) === $keys) {
91+
$file = array_filter($file);
9492
}
9593
}
9694

@@ -109,11 +107,9 @@ protected function convertFileInformation($file)
109107
* It's safe to pass an already converted array, in which case this method
110108
* just returns the original array unmodified.
111109
*
112-
* @param array $data
113-
*
114110
* @return array
115111
*/
116-
protected function fixPhpFilesArray($data)
112+
protected function fixPhpFilesArray(array $data)
117113
{
118114
$keys = array_keys($data);
119115
sort($keys);

HeaderBag.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -123,8 +123,8 @@ public function get(string $key, string $default = null)
123123
/**
124124
* Sets a header by name.
125125
*
126-
* @param string|string[] $values The value or an array of values
127-
* @param bool $replace Whether to replace the actual value or not (true by default)
126+
* @param string|string[]|null $values The value or an array of values
127+
* @param bool $replace Whether to replace the actual value or not (true by default)
128128
*/
129129
public function set(string $key, $values, bool $replace = true)
130130
{
@@ -208,7 +208,7 @@ public function getDate(string $key, \DateTime $default = null)
208208
/**
209209
* Adds a custom Cache-Control directive.
210210
*
211-
* @param mixed $value The Cache-Control directive value
211+
* @param bool|string $value The Cache-Control directive value
212212
*/
213213
public function addCacheControlDirective(string $key, $value = true)
214214
{
@@ -230,11 +230,11 @@ public function hasCacheControlDirective(string $key)
230230
/**
231231
* Returns a Cache-Control directive value by name.
232232
*
233-
* @return mixed The directive value if defined, null otherwise
233+
* @return bool|string|null The directive value if defined, null otherwise
234234
*/
235235
public function getCacheControlDirective(string $key)
236236
{
237-
return \array_key_exists($key, $this->cacheControl) ? $this->cacheControl[$key] : null;
237+
return $this->cacheControl[$key] ?? null;
238238
}
239239

240240
/**

InputBag.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
/**
1717
* InputBag is a container for user input values such as $_GET, $_POST, $_REQUEST, and $_COOKIE.
1818
*
19-
* @author Saif Eddin Gmati <saif.gmati@symfony.com>
19+
* @author Saif Eddin Gmati <azjezz@protonmail.com>
2020
*/
2121
final class InputBag extends ParameterBag
2222
{

Response.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -462,7 +462,7 @@ public function getProtocolVersion(): string
462462
*
463463
* @final
464464
*/
465-
public function setStatusCode(int $code, $text = null): object
465+
public function setStatusCode(int $code, string $text = null): object
466466
{
467467
$this->statusCode = $code;
468468
if ($this->isInvalid()) {

Tests/JsonResponseTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@ public function testConstructorWithNullAsDataThrowsAnUnexpectedValueException()
276276
public function testConstructorWithObjectWithToStringMethod()
277277
{
278278
$class = new class() {
279-
public function __toString()
279+
public function __toString(): string
280280
{
281281
return '{}';
282282
}

Tests/Session/Storage/Handler/AbstractRedisSessionHandlerTestCase.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ public function testUpdateTimestamp()
122122
$lowTtl = 10;
123123

124124
$this->redisClient->setex(self::PREFIX.'id', $lowTtl, 'foo');
125-
$this->storage->updateTimestamp('id', []);
125+
$this->storage->updateTimestamp('id', 'data');
126126

127127
$this->assertGreaterThan($lowTtl, $this->redisClient->ttl(self::PREFIX.'id'));
128128
}

0 commit comments

Comments
 (0)