-
Notifications
You must be signed in to change notification settings - Fork 11.5k
[12.x] Improve docblocks for file related methods of InteractsWithInput #55156
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -175,7 +175,7 @@ public function cookie($key = null, $default = null) | |
/** | ||
* Get an array of all of the files on the request. | ||
* | ||
* @return array | ||
* @return array<int, \Illuminate\Http\UploadedFile|\Illuminate\Http\UploadedFile[]> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The key here appears to be wrong, on FormRequest the key will be the name of the file input. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Addressed here: #55287 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I was actually looking in to adding types to this a few weeks ago, but backed off when I saw some of the nested logic so I'm glad you handled most of it :) |
||
*/ | ||
public function allFiles() | ||
{ | ||
|
@@ -187,8 +187,8 @@ public function allFiles() | |
/** | ||
* Convert the given array of Symfony UploadedFiles to custom Laravel UploadedFiles. | ||
* | ||
* @param array $files | ||
* @return array | ||
* @param array<int, \Symfony\Component\HttpFoundation\File\UploadedFile|\Symfony\Component\HttpFoundation\File\UploadedFile[]> $files | ||
* @return array<int, \Illuminate\Http\UploadedFile|\Illuminate\Http\UploadedFile[]> | ||
*/ | ||
protected function convertUploadedFiles(array $files) | ||
{ | ||
|
@@ -240,7 +240,7 @@ protected function isValidFile($file) | |
* | ||
* @param string|null $key | ||
* @param mixed $default | ||
* @return \Illuminate\Http\UploadedFile|\Illuminate\Http\UploadedFile[]|array|null | ||
* @return ($key is null ? array<int, \Illuminate\Http\UploadedFile|\Illuminate\Http\UploadedFile[]> : \Illuminate\Http\UploadedFile|\Illuminate\Http\UploadedFile[]|null) | ||
*/ | ||
public function file($key = null, $default = null) | ||
{ | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think most codebases don't take an array containing another array of files into consideration, but it is possible according tot he code.
convertUploadedFiles
recursively maps the array to files or if the array contains an array, to an array of files (inside the array of files) resulting in nested arrays of files.I guess not flat mapping this is on purpose (would be a breaking change now anyway), so the docblocks reflect the possibility of an array of items of which each item is either a file or an array of files.