@@ -64,10 +64,10 @@ public function __construct(string $path, string $originalName, string $mimeType
6464 {
6565 $ this ->originalName = $ this ->getName ($ originalName );
6666 $ this ->mimeType = $ mimeType ?: 'application/octet-stream ' ;
67- $ this ->error = $ error ?: UPLOAD_ERR_OK ;
67+ $ this ->error = $ error ?: \ UPLOAD_ERR_OK ;
6868 $ this ->test = $ test ;
6969
70- parent ::__construct ($ path , UPLOAD_ERR_OK === $ this ->error );
70+ parent ::__construct ($ path , \ UPLOAD_ERR_OK === $ this ->error );
7171 }
7272
7373 /**
@@ -93,7 +93,7 @@ public function getClientOriginalName()
9393 */
9494 public function getClientOriginalExtension ()
9595 {
96- return pathinfo ($ this ->originalName , PATHINFO_EXTENSION );
96+ return pathinfo ($ this ->originalName , \ PATHINFO_EXTENSION );
9797 }
9898
9999 /**
@@ -160,7 +160,7 @@ public function getError()
160160 */
161161 public function isValid ()
162162 {
163- $ isOk = UPLOAD_ERR_OK === $ this ->error ;
163+ $ isOk = \ UPLOAD_ERR_OK === $ this ->error ;
164164
165165 return $ this ->test ? $ isOk : $ isOk && is_uploaded_file ($ this ->getPathname ());
166166 }
@@ -194,19 +194,19 @@ public function move(string $directory, string $name = null)
194194 }
195195
196196 switch ($ this ->error ) {
197- case UPLOAD_ERR_INI_SIZE :
197+ case \ UPLOAD_ERR_INI_SIZE :
198198 throw new IniSizeFileException ($ this ->getErrorMessage ());
199- case UPLOAD_ERR_FORM_SIZE :
199+ case \ UPLOAD_ERR_FORM_SIZE :
200200 throw new FormSizeFileException ($ this ->getErrorMessage ());
201- case UPLOAD_ERR_PARTIAL :
201+ case \ UPLOAD_ERR_PARTIAL :
202202 throw new PartialFileException ($ this ->getErrorMessage ());
203- case UPLOAD_ERR_NO_FILE :
203+ case \ UPLOAD_ERR_NO_FILE :
204204 throw new NoFileException ($ this ->getErrorMessage ());
205- case UPLOAD_ERR_CANT_WRITE :
205+ case \ UPLOAD_ERR_CANT_WRITE :
206206 throw new CannotWriteFileException ($ this ->getErrorMessage ());
207- case UPLOAD_ERR_NO_TMP_DIR :
207+ case \ UPLOAD_ERR_NO_TMP_DIR :
208208 throw new NoTmpDirFileException ($ this ->getErrorMessage ());
209- case UPLOAD_ERR_EXTENSION :
209+ case \ UPLOAD_ERR_EXTENSION :
210210 throw new ExtensionFileException ($ this ->getErrorMessage ());
211211 }
212212
@@ -223,7 +223,7 @@ public static function getMaxFilesize()
223223 $ sizePostMax = self ::parseFilesize (ini_get ('post_max_size ' ));
224224 $ sizeUploadMax = self ::parseFilesize (ini_get ('upload_max_filesize ' ));
225225
226- return min ($ sizePostMax ?: PHP_INT_MAX , $ sizeUploadMax ?: PHP_INT_MAX );
226+ return min ($ sizePostMax ?: \ PHP_INT_MAX , $ sizeUploadMax ?: \ PHP_INT_MAX );
227227 }
228228
229229 /**
@@ -267,17 +267,17 @@ private static function parseFilesize($size): int
267267 public function getErrorMessage ()
268268 {
269269 static $ errors = [
270- UPLOAD_ERR_INI_SIZE => 'The file "%s" exceeds your upload_max_filesize ini directive (limit is %d KiB). ' ,
271- UPLOAD_ERR_FORM_SIZE => 'The file "%s" exceeds the upload limit defined in your form. ' ,
272- UPLOAD_ERR_PARTIAL => 'The file "%s" was only partially uploaded. ' ,
273- UPLOAD_ERR_NO_FILE => 'No file was uploaded. ' ,
274- UPLOAD_ERR_CANT_WRITE => 'The file "%s" could not be written on disk. ' ,
275- UPLOAD_ERR_NO_TMP_DIR => 'File could not be uploaded: missing temporary directory. ' ,
276- UPLOAD_ERR_EXTENSION => 'File upload was stopped by a PHP extension. ' ,
270+ \ UPLOAD_ERR_INI_SIZE => 'The file "%s" exceeds your upload_max_filesize ini directive (limit is %d KiB). ' ,
271+ \ UPLOAD_ERR_FORM_SIZE => 'The file "%s" exceeds the upload limit defined in your form. ' ,
272+ \ UPLOAD_ERR_PARTIAL => 'The file "%s" was only partially uploaded. ' ,
273+ \ UPLOAD_ERR_NO_FILE => 'No file was uploaded. ' ,
274+ \ UPLOAD_ERR_CANT_WRITE => 'The file "%s" could not be written on disk. ' ,
275+ \ UPLOAD_ERR_NO_TMP_DIR => 'File could not be uploaded: missing temporary directory. ' ,
276+ \ UPLOAD_ERR_EXTENSION => 'File upload was stopped by a PHP extension. ' ,
277277 ];
278278
279279 $ errorCode = $ this ->error ;
280- $ maxFilesize = UPLOAD_ERR_INI_SIZE === $ errorCode ? self ::getMaxFilesize () / 1024 : 0 ;
280+ $ maxFilesize = \ UPLOAD_ERR_INI_SIZE === $ errorCode ? self ::getMaxFilesize () / 1024 : 0 ;
281281 $ message = isset ($ errors [$ errorCode ]) ? $ errors [$ errorCode ] : 'The file "%s" was not uploaded due to an unknown error. ' ;
282282
283283 return sprintf ($ message , $ this ->getClientOriginalName (), $ maxFilesize );
0 commit comments