Skip to content

Commit fa79c8c

Browse files
Fixed bug that uploadedFile was incompatibility with php 8.1 (#4655)
Co-authored-by: 李铭昕 <[email protected]>
1 parent ea9f858 commit fa79c8c

File tree

2 files changed

+37
-2
lines changed

2 files changed

+37
-2
lines changed

src/Upload/UploadedFile.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -175,9 +175,9 @@ public function moveTo($targetPath)
175175
* the file in the $_FILES array if available, as PHP calculates this based
176176
* on the actual size transmitted.
177177
*
178-
* @return null|int the file size in bytes or null if unknown
178+
* @return false|int the file size in bytes or null if unknown
179179
*/
180-
public function getSize()
180+
public function getSize(): int|false
181181
{
182182
return $this->size;
183183
}

tests/Upload/UploadedFileTest.php

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
/**
5+
* This file is part of Hyperf.
6+
*
7+
* @link https://www.hyperf.io
8+
* @document https://hyperf.wiki
9+
* @contact [email protected]
10+
* @license https://github.com/hyperf/hyperf/blob/master/LICENSE
11+
*/
12+
namespace HyperfTest\HttpMessage\Upload;
13+
14+
use Hyperf\HttpMessage\Upload\UploadedFile;
15+
use Mockery;
16+
use PHPUnit\Framework\TestCase;
17+
18+
/**
19+
* @internal
20+
* @coversNothing
21+
*/
22+
class UploadedFileTest extends TestCase
23+
{
24+
protected function tearDown(): void
25+
{
26+
Mockery::close();
27+
}
28+
29+
public function testGetSize()
30+
{
31+
$file = new UploadedFile('', 10, 0);
32+
33+
$this->assertSame(10, $file->getSize());
34+
}
35+
}

0 commit comments

Comments
 (0)