diff --git a/src/Http/Request.php b/src/Http/Request.php index 99cd0960..84e425b1 100644 --- a/src/Http/Request.php +++ b/src/Http/Request.php @@ -131,11 +131,15 @@ public function getPost(string $key = null) /** * Returns uploaded file. - * @return FileUpload|array|null + * @param string|string[] $key + * @return ?FileUpload */ - public function getFile(string $key) + public function getFile($key) { - return $this->files[$key] ?? null; + $res = Nette\Utils\Arrays::get($this->files, $key, null); + return $res instanceof FileUpload + ? $res + : null; } diff --git a/tests/Http/Request.files.phpt b/tests/Http/Request.files.phpt index 5212508f..c9b1ee94 100644 --- a/tests/Http/Request.files.phpt +++ b/tests/Http/Request.files.phpt @@ -111,4 +111,4 @@ Assert::false(isset($request->files['file0'])); Assert::true(isset($request->files['file1'])); Assert::null($request->getFile('empty1')); -Assert::same([null], $request->getFile('empty2')); +Assert::null($request->getFile('empty2'));