8000 Backport type fixes · symfony/http-foundation@605a05b · GitHub
[go: up one dir, main page]

Skip to content

Commit 605a05b

Browse files
Backport type fixes
1 parent 108541d commit 605a05b

File tree

5 files changed

+23
-25
lines changed

5 files changed

+23
-25
lines changed

File/UploadedFile.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ public static function getMaxFilesize()
254254
*
255255
* @return int|float Returns float if size > PHP_INT_MAX
256256
*/
257-
private static function parseFilesize($size)
257+
private static function parseFilesize(string $size)
258258
{
259259
if ('' === $size) {
260260
return 0;

FileBag.php

Lines changed: 13 additions & 15 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

HeaderBag.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -133,9 +133,9 @@ public function get($key, $default = null)
133133
/**
134134
* Sets a header by name.
135135
*
136-
* @param string $key The key
137-
* @param string|string[] $values The value or an array of values
138-
* @param bool $replace Whether to replace the actual value or not (true by default)
136+
* @param string $key The key
137+
* @param string|string[]|null $values The value or an array of values
138+
* @param bool $replace Whether to replace the actual value or not (true by default)
139139
*/
140140
public function set($key, $values, $replace = true)
141141
{
@@ -228,8 +228,8 @@ public function getDate($key, \DateTime $default = null)
228228
/**
229229
* Adds a custom Cache-Control directive.
230230
*
231-
* @param string $key The Cache-Control directive name
232-
* @param mixed $value The Cache-Control directive value
231+
* @param string $key The Cache-Control directive name
232+
* @param bool|string $value The Cache-Control directive value
233233
*/
234234
public function addCacheControlDirective($key, $value = true)
235235
{
@@ -255,11 +255,11 @@ public function hasCacheControlDirective($key)
255255
*
256256
* @param string $key The directive name
257257
*
258-
* @return mixed The directive value if defined, null otherwise
258+
* @return bool|string|null The directive value if defined, null otherwise
259259
*/
260260
public function getCacheControlDirective($key)
261261
{
262-
return \array_key_exists($key, $this->cacheControl) ? $this->cacheControl[$key] : null;
262+
return $this->cacheControl[$key] ?? null;
263263
}
264264

265265
/**

Tests/JsonResponseTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ public function testfromJsonStringConstructorWithNullAsDataThrowsAnUnexpectedVal
257257
public function testConstructorWithObjectWithToStringMethod()
258258
{
259259
$class = new class() {
260-
public function __toString()
260+
public function __toString(): string
261261
{
262262
return '{}';
263263
}

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)
0