@@ -73,27 +73,27 @@ final class MultipartParser
73
73
*/
74
74
public function __construct ($ uploadMaxFilesize = null , $ maxFileUploads = null )
75
75
{
76
- $ var = ini_get ('max_input_vars ' );
76
+ $ var = \ ini_get ('max_input_vars ' );
77
77
if ($ var !== false ) {
78
78
$ this ->maxInputVars = (int )$ var ;
79
79
}
80
- $ var = ini_get ('max_input_nesting_level ' );
80
+ $ var = \ ini_get ('max_input_nesting_level ' );
81
81
if ($ var !== false ) {
82
82
$ this ->maxInputNestingLevel = (int )$ var ;
83
83
}
84
84
85
85
if ($ uploadMaxFilesize === null ) {
86
- $ uploadMaxFilesize = ini_get ('upload_max_filesize ' );
86
+ $ uploadMaxFilesize = \ ini_get ('upload_max_filesize ' );
87
87
}
88
88
89
89
$ this ->uploadMaxFilesize = IniUtil::iniSizeToBytes ($ uploadMaxFilesize );
90
- $ this ->maxFileUploads = $ maxFileUploads === null ? (ini_get ('file_uploads ' ) === '' ? 0 : (int )ini_get ('max_file_uploads ' )) : (int )$ maxFileUploads ;
90
+ $ this ->maxFileUploads = $ maxFileUploads === null ? (\ ini_get ('file_uploads ' ) === '' ? 0 : (int )\ ini_get ('max_file_uploads ' )) : (int )$ maxFileUploads ;
91
91
}
92
92
93
93
public function parse (ServerRequestInterface $ request )
94
94
{
95
95
$ contentType = $ request ->getHeaderLine ('content-type ' );
96
- if (!preg_match ('/boundary="?(.*)"?$/ ' , $ contentType , $ matches )) {
96
+ if (!\ preg_match ('/boundary="?(.*)"?$/ ' , $ contentType , $ matches )) {
97
97
return $ request ;
98
98
}
99
99
@@ -112,35 +112,35 @@ public function parse(ServerRequestInterface $request)
112
112
113
113
private function parseBody ($ boundary , $ buffer )
114
114
{
115
- $ len = strlen ($ boundary );
115
+ $ len = \ strlen ($ boundary );
116
116
117
117
// ignore everything before initial boundary (SHOULD be empty)
118
- $ start = strpos ($ buffer , $ boundary . "\r\n" );
118
+ $ start = \ strpos ($ buffer , $ boundary . "\r\n" );
119
119
120
120
while ($ start !== false ) {
121
121
// search following boundary (preceded by newline)
122
122
// ignore last if not followed by boundary (SHOULD end with "--")
123
123
$ start += $ len + 2 ;
124
- $ end = strpos ($ buffer , "\r\n" . $ boundary , $ start );
124
+ $ end = \ strpos ($ buffer , "\r\n" . $ boundary , $ start );
125
125
if ($ end === false ) {
126
126
break ;
127
127
}
128
128
129
129
// parse one part and continue searching for next
130
- $ this ->parsePart (substr ($ buffer , $ start , $ end - $ start ));
130
+ $ this ->parsePart (\ substr ($ buffer , $ start , $ end - $ start ));
131
131
$ start = $ end ;
132
132
}
133
133
}
134
134
135
135
private function parsePart ($ chunk )
136
136
{
137
- $ pos = strpos ($ chunk , "\r\n\r\n" );
137
+ $ pos = \ strpos ($ chunk , "\r\n\r\n" );
138
138
if ($ pos === false ) {
139
139
return ;
140
140
}
141
141
142
142
$ headers = $ this ->parseHeaders ((string )substr ($ chunk , 0 , $ pos ));
143
- $ body = (string )substr ($ chunk , $ pos + 4 );
143
+ $ body = (string )\ substr ($ chunk , $ pos + 4 );
144
144
145
145
if (!isset ($ headers ['content-disposition ' ])) {
146
146
return ;
@@ -180,7 +180,7 @@ private function parseFile($name, $filename, $contentType, $contents)
180
180
181
181
private function parseUploadedFile ($ filename , $ contentType , $ contents )
182
182
{
183
- $ size = strlen ($ contents );
183
+ $ size = \ strlen ($ contents );
184
184
185
185
// no file selected (zero size and empty filename)
186
186
if ($ size === 0 && $ filename === '' ) {
@@ -192,7 +192,7 @@ private function parseUploadedFile($filename, $contentType, $contents)
192
192
return new UploadedFile (
193
193
Psr7 \stream_for (),
194
194
$ size ,
195
- UPLOAD_ERR_NO_FILE ,
195
+ \ UPLOAD_ERR_NO_FILE ,
196
196
$ filename ,
197
197
$ contentType
198
198
);
@@ -208,7 +208,7 @@ private function parseUploadedFile($filename, $contentType, $contents)
208
208
return new UploadedFile (
209
209
Psr7 \stream_for (),
210
210
$ size ,
211
- UPLOAD_ERR_INI_SIZE ,
211
+ \ UPLOAD_ERR_INI_SIZE ,
212
212
$ filename ,
213
213
$ contentType
214
214
);
@@ -219,7 +219,7 @@ private function parseUploadedFile($filename, $contentType, $contents)
219
219
return new UploadedFile (
220
220
Psr7 \stream_for (),
221
221
$ size ,
222
- UPLOAD_ERR_FORM_SIZE ,
222
+ \ UPLOAD_ERR_FORM_SIZE ,
223
223
$ filename ,
224
224
$ contentType
225
225
);
@@ -228,7 +228,7 @@ private function parseUploadedFile($filename, $contentType, $contents)
228
228
return new UploadedFile (
229
229
Psr7 \stream_for ($ contents ),
230
230
$ size ,
231
- UPLOAD_ERR_OK ,
231
+ \ UPLOAD_ERR_OK ,
232
232
$ filename ,
233
233
$ contentType
234
234
);
@@ -247,7 +247,7 @@ private function parsePost($name, $value)
247
247
$ value
248
248
));
249
249
250
- if (strtoupper ($ name ) === 'MAX_FILE_SIZE ' ) {
250
+ if (\ strtoupper ($ name ) === 'MAX_FILE_SIZE ' ) {
251
251
$ this ->maxFileSize = (int )$ value ;
252
252
253
253
if ($ this ->maxFileSize === 0 ) {
@@ -260,15 +260,15 @@ private function parseHeaders($header)
260
260
{
261
261
$ headers = array ();
262
262
263
- foreach (explode ("\r\n" , trim ($ header )) as $ line ) {
264
- $ parts = explode (': ' , $ line , 2 );
263
+ foreach (\ explode ("\r\n" , \ trim ($ header )) as $ line ) {
264
+ $ parts = \ explode (': ' , $ line , 2 );
265
265
if (!isset ($ parts [1 ])) {
266
266
continue ;
267
267
}
268
268
269
- $ key = strtolower (trim ($ parts [0 ]));
270
- $ values = explode ('; ' , $ parts [1 ]);
271
- $ values = array_map ('trim ' , $ values );
269
+ $ key = \ strtolower (trim ($ parts [0 ]));
270
+ $ values = \ explode ('; ' , $ parts [1 ]);
271
+ $ values = \ array_map ('trim ' , $ values );
272
272
$ headers [$ key ] = $ values ;
273
273
}
274
274
@@ -278,7 +278,7 @@ private function parseHeaders($header)
278
278
private function getParameterFromHeader (array $ header , $ parameter )
279
279
{
280
280
foreach ($ header as $ part ) {
281
- if (preg_match ('/ ' . $ parameter . '="?(.*)"$/ ' , $ part , $ matches )) {
281
+ if (\ preg_match ('/ ' . $ parameter . '="?(.*)"$/ ' , $ part , $ matches )) {
282
282
return $ matches [1 ];
283
283
}
284
284
}
@@ -288,8 +288,8 @@ private function getParameterFromHeader(array $header, $parameter)
288
288
289
289
private function extractPost ($ postFields , $ key , $ value )
290
290
{
291
- $ chunks = explode ('[ ' , $ key );
292
- if (count ($ chunks ) == 1 ) {
291
+ $ chunks = \ explode ('[ ' , $ key );
292
+ if (\ count ($ chunks ) == 1 ) {
293
293
$ postFields [$ key ] = $ value ;
294
294
return $ postFields ;
295
295
}
@@ -299,23 +299,23 @@ private function extractPost($postFields, $key, $value)
299
299
return $ postFields ;
300
300
}
301
301
302
- $ chunkKey = rtrim ($ chunks [0 ], '] ' );
302
+ $ chunkKey = \ rtrim ($ chunks [0 ], '] ' );
303
303
$ parent = &$ postFields ;
304
304
for ($ i = 1 ; isset ($ chunks [$ i ]); $ i ++) {
305
305
$ previousChunkKey = $ chunkKey ;
306
306
307
307
if ($ previousChunkKey === '' ) {
308
308
$ parent [] = array ();
309
- end ($ parent );
310
- $ parent = &$ parent [key ($ parent )];
309
+ \ end ($ parent );
310
+ $ parent = &$ parent [\ key ($ parent )];
311
311
} else {
312
- if (!isset ($ parent [$ previousChunkKey ]) || !is_array ($ parent [$ previousChunkKey ])) {
312
+ if (!isset ($ parent [$ previousChunkKey ]) || !\ is_array ($ parent [$ previousChunkKey ])) {
313
313
$ parent [$ previousChunkKey ] = array ();
314
314
}
315
315
$ parent = &$ parent [$ previousChunkKey ];
316
316
}
317
317
318
- $ chunkKey = rtrim ($ chunks [$ i ], '] ' );
318
+ $ chunkKey = \ rtrim ($ chunks [$ i ], '] ' );
319
319
}
320
320
321
321
if ($ chunkKey === '' ) {
0 commit comments