Skip to content

Commit a630617

Browse files
authored
Make File compatible with SplFileInfo (#5040)
1 parent 3a040f8 commit a630617

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

system/Files/File.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
use CodeIgniter\Files\Exceptions\FileException;
1515
use CodeIgniter\Files\Exceptions\FileNotFoundException;
1616
use Config\Mimes;
17+
use ReturnTypeWillChange;
1718
use SplFileInfo;
1819

1920
/**
@@ -29,15 +30,15 @@ class File extends SplFileInfo
2930
protected $size;
3031

3132
/**
32-
* Original MimeType
33-
*
3433
* @var string|null
3534
*/
3635
protected $originalMimeType;
3736

3837
/**
3938
* Run our SplFileInfo constructor with an optional verification
4039
* that the path is really a file.
40+
*
41+
* @throws FileNotFoundException
4142
*/
4243
public function __construct(string $path, bool $checkFile = false)
4344
{
@@ -55,8 +56,9 @@ public function __construct(string $path, bool $checkFile = false)
5556
* the file in the $_FILES array if available, as PHP calculates this based
5657
* on the actual size transmitted.
5758
*
58-
* @return int The file size in bytes
59+
* @return false|int The file size in bytes, or false on failure
5960
*/
61+
#[ReturnTypeWillChange]
6062
public function getSize()
6163
{
6264
return $this->size ?? ($this->size = parent::getSize());
@@ -65,7 +67,7 @@ public function getSize()
6567
/**
6668
* Retrieve the file size by unit.
6769
*
68-
* @return int|string
70+
* @return false|int|string
6971
*/
7072
public function getSizeByUnit(string $unit = 'b')
7173
{

0 commit comments

Comments
 (0)