From bfe7a22944fe876ba3bc7648301c3c184f5be229 Mon Sep 17 00:00:00 2001 From: "Matthew J. Sahagian" Date: Fri, 8 Nov 2019 11:36:38 -0800 Subject: [PATCH] Making UploadedFile extend SplFileInfo --- src/UploadedFile.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/UploadedFile.php b/src/UploadedFile.php index 2f4d87f1..a28b7af5 100644 --- a/src/UploadedFile.php +++ b/src/UploadedFile.php @@ -9,6 +9,7 @@ namespace Zend\Diactoros; +use SplFileInfo; use Psr\Http\Message\StreamInterface; use Psr\Http\Message\UploadedFileInterface; @@ -35,7 +36,7 @@ use const UPLOAD_ERR_OK; use const UPLOAD_ERR_PARTIAL; -class UploadedFile implements UploadedFileInterface +class UploadedFile extends SplFileInfo implements UploadedFileInterface { const ERROR_MESSAGES = [ UPLOAD_ERR_OK => 'There is no error, the file uploaded with success', @@ -102,9 +103,13 @@ public function __construct( if ($errorStatus === UPLOAD_ERR_OK) { if (is_string($streamOrFile)) { $this->file = $streamOrFile; + + parent::__construct($this->file); } if (is_resource($streamOrFile)) { $this->stream = new Stream($streamOrFile); + + parent::__construct($this->stream->getMetaData('uri')); } if (! $this->file && ! $this->stream) {