Skip to content
This repository was archived by the owner on Jan 29, 2020. It is now read-only.

Commit 46da102

Browse files
pine3reemichalbundyra
authored andcommitted
use shorter expressions in functions
1 parent c155144 commit 46da102

File tree

4 files changed

+13
-13
lines changed

4 files changed

+13
-13
lines changed

src/functions/create_uploaded_file.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ function createUploadedFile(array $spec) : UploadedFile
3333
$spec['tmp_name'],
3434
$spec['size'],
3535
$spec['error'],
36-
isset($spec['name']) ? $spec['name'] : null,
37-
isset($spec['type']) ? $spec['type'] : null
36+
$spec['name'] ?? null,
37+
$spec['type'] ?? null
3838
);
3939
}

src/functions/marshal_method_from_sapi.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,5 @@
1414
*/
1515
function marshalMethodFromSapi(array $server) : string
1616
{
17-
return isset($server['REQUEST_METHOD']) ? $server['REQUEST_METHOD'] : 'GET';
17+
return $server['REQUEST_METHOD'] ?? 'GET';
1818
}

src/functions/marshal_uri_from_sapi.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -132,19 +132,19 @@ function marshalUriFromSapi(array $server, array $headers) : Uri
132132
$marshalRequestPath = function (array $server) : string {
133133
// IIS7 with URL Rewrite: make sure we get the unencoded url
134134
// (double slash problem).
135-
$iisUrlRewritten = array_key_exists('IIS_WasUrlRewritten', $server) ? $server['IIS_WasUrlRewritten'] : null;
136-
$unencodedUrl = array_key_exists('UNENCODED_URL', $server) ? $server['UNENCODED_URL'] : '';
135+
$iisUrlRewritten = $server['IIS_WasUrlRewritten'] ?? null;
136+
$unencodedUrl = $server['UNENCODED_URL'] ?? '';
137137
if ('1' === $iisUrlRewritten && ! empty($unencodedUrl)) {
138138
return $unencodedUrl;
139139
}
140140

141-
$requestUri = array_key_exists('REQUEST_URI', $server) ? $server['REQUEST_URI'] : null;
141+
$requestUri = $server['REQUEST_URI'] ?? null;
142142

143143
if ($requestUri !== null) {
144144
return preg_replace('#^[^/:]+://[^/]+#', '', $requestUri);
145145
}
146146

147-
$origPathInfo = array_key_exists('ORIG_PATH_INFO', $server) ? $server['ORIG_PATH_INFO'] : null;
147+
$origPathInfo = $server['ORIG_PATH_INFO'] ?? null;
148148
if (empty($origPathInfo)) {
149149
return '/';
150150
}

src/functions/normalize_uploaded_files.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,17 +49,17 @@ function normalizeUploadedFiles(array $files) : array
4949
$tmpNameTree[$key],
5050
$sizeTree[$key],
5151
$errorTree[$key],
52-
isset($nameTree[$key]) ? $nameTree[$key] : null,
53-
isset($typeTree[$key]) ? $typeTree[$key] : null
52+
$nameTree[$key] ?? null,
53+
$typeTree[$key] ?? null
5454
);
5555
continue;
5656
}
5757
$normalized[$key] = createUploadedFile([
5858
'tmp_name' => $tmpNameTree[$key],
5959
'size' => $sizeTree[$key],
6060
'error' => $errorTree[$key],
61-
'name' => isset($nameTree[$key]) ? $nameTree[$key] : null,
62-
'type' => isset($typeTree[$key]) ? $typeTree[$key] : null
61+
'name' => $nameTree[$key] ?? null,
62+
'type' => $typeTree[$key] ?? null,
6363
]);
6464
}
6565
return $normalized;
@@ -96,8 +96,8 @@ function normalizeUploadedFiles(array $files) : array
9696
$files['tmp_name'],
9797
$files['size'],
9898
$files['error'],
99-
isset($files['name']) ? $files['name'] : null,
100-
isset($files['type']) ? $files['type'] : null
99+
$files['name'] ?? null,
100+
$files['type'] ?? null
101101
);
102102
};
103103

0 commit comments

Comments
 (0)