Improve phpdoc types, type-safety
This commit is contained in:
@ -134,9 +134,9 @@ final class MD_STD_IN {
|
||||
* Retrieves HTTP input texts from GET or POST variables, whatever is provided.
|
||||
* If neither is given, returns a provided default.
|
||||
*
|
||||
* @param string $var_name Variable name.
|
||||
* @param string $default Default value for the output.
|
||||
* @param array<string> $allowed List of allowed values. Defaults to empty (all values allowed).
|
||||
* @param non-empty-string $var_name Variable name.
|
||||
* @param string $default Default value for the output.
|
||||
* @param array<string> $allowed List of allowed values. Defaults to empty (all values allowed).
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
@ -164,9 +164,9 @@ final class MD_STD_IN {
|
||||
* Retrieves HTTP input texts from POST variables.
|
||||
* If none is given, returns a provided default.
|
||||
*
|
||||
* @param string $var_name Variable name.
|
||||
* @param string $default Default value for the output.
|
||||
* @param array<string> $allowed List of allowed values. Defaults to empty (all values allowed).
|
||||
* @param non-empty-string $var_name Variable name.
|
||||
* @param string $default Default value for the output.
|
||||
* @param array<string> $allowed List of allowed values. Defaults to empty (all values allowed).
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
@ -362,19 +362,22 @@ final class MD_STD_IN {
|
||||
* Wrapper around move_uploaded_file that throws errors in case the upload failed
|
||||
* for an identifiable reason.
|
||||
*
|
||||
* @param string $filename Name of the file to upload.
|
||||
* @param string $destination Destination to move the file to.
|
||||
* @param array<string> $mime_types Optional array of acceptable mime types. If this is
|
||||
* not empty, the file will be checked for having one
|
||||
* of the given mime types. If it does not, an error
|
||||
* will be thrown.
|
||||
* @param non-empty-string $filename Name of the file to upload.
|
||||
* @param non-empty-string $destination Destination to move the file to.
|
||||
* @param array<string> $mime_types Optional array of acceptable mime types. If this is
|
||||
* not empty, the file will be checked for having one
|
||||
* of the given mime types. If it does not, an error
|
||||
* will be thrown.
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public static function move_uploaded_file(string $filename, string $destination, array $mime_types = []):bool {
|
||||
|
||||
MD_STD::ensure_file($filename, $mime_types);
|
||||
MD_STD::check_is_writable(dirname($destination));
|
||||
if (empty($destDir = dirname($destination))) {
|
||||
return false;
|
||||
}
|
||||
MD_STD::check_is_writable($destDir);
|
||||
|
||||
if (!(\move_uploaded_file($filename, $destination))) {
|
||||
return false;
|
||||
|
Reference in New Issue
Block a user