FileTypeCheck final class
Minn\Runtime\FileTypeCheck · public/minn/src/Minn/Runtime/FileTypeCheck.php · 77 lines
A file's type from its content as much as its name, as the reference's wp_check_filetype_and_ext decides it (probe upload-filters): an image the server can measure is what its bytes say, and a name with the wrong image extension is corrected (a.png holding a JPEG becomes a.jpg); anything claiming to be such an image and not being one has no type; any other type must match what the content is, plain text standing for a few text types and an office or archive container for the document types; and the type must be one the site allows.
Constants and properties
| const | IMAGES = array ( 'image/jpeg' => 'jpg', 'image/png' => 'png', 'image/gif' => 'gif', 'image/bmp' => 'bmp', 'image/tiff' => 'tif', 'image/webp' => 'webp', 'image/avif' => 'avif', 'image/heic' => 'heic', ) | The image types measured by their bytes, and the extension each takes. |
| private | TEXT_TYPES = array ( 0 => 'text/plain', 1 => 'text/csv', 2 => 'application/csv', 3 => 'text/richtext', 4 => 'text/tsv', 5 => 'text/vtt', ) | |
| private | CONTAINERS = array ( 0 => 'application/octet-stream', 1 => 'application/encrypted', 2 => 'application/CDFV2-encrypted', 3 => 'application/zip', ) |
Public
| static | check(string $file, string $filename, ?array $mimes, array $images): array# | ext, type, proper_filename, and the content's own type (real_mime).
@return array{ext: string|false, type: string|false, proper_filename: string|false, real_mime: string|false} |
Internals 2
Private and protected methods: how the class does its work. Not a contract; they change whenever the code is tidied.
Nothing matches.