Skip to content

Commit e79eb86

Browse files
authored
Change array_key_exists with null coalescing assignment operator to simplify the assignment of Content-Type and Content-Length headers (#48943)
1 parent aacd066 commit e79eb86

File tree

1 file changed

+2
-7
lines changed

1 file changed

+2
-7
lines changed

src/Illuminate/Filesystem/FilesystemAdapter.php

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -289,13 +289,8 @@ public function response($path, $name = null, array $headers = [], $disposition
289289
{
290290
$response = new StreamedResponse;
291291

292-
if (! array_key_exists('Content-Type', $headers)) {
293-
$headers['Content-Type'] = $this->mimeType($path);
294-
}
295-
296-
if (! array_key_exists('Content-Length', $headers)) {
297-
$headers['Content-Length'] = $this->size($path);
298-
}
292+
$headers['Content-Type'] ??= $this->mimeType($path);
293+
$headers['Content-Length'] ??= $this->size($path);
299294

300295
if (! array_key_exists('Content-Disposition', $headers)) {
301296
$filename = $name ?? basename($path);

0 commit comments

Comments
 (0)