1--TEST-- 2finfo_open(): Testing magic_file names 3--EXTENSIONS-- 4fileinfo 5--FILE-- 6<?php 7try { 8 var_dump(finfo_open(FILEINFO_MIME, "\0")); 9} catch (ValueError $e) { 10 echo $e->getMessage(), "\n"; 11} 12 13var_dump(finfo_open(FILEINFO_MIME, NULL)); 14var_dump(finfo_open(FILEINFO_MIME, '')); 15var_dump(finfo_open(FILEINFO_MIME, 123)); 16var_dump(finfo_open(FILEINFO_MIME, 1.0)); 17var_dump(finfo_open(FILEINFO_MIME, '/foo/bar/inexistent')); 18 19var_dump($obj = new finfo(FILEINFO_MIME, NULL)); 20var_dump($obj = new finfo(FILEINFO_MIME, '')); 21 22try { 23 var_dump($obj = new finfo(FILEINFO_MIME, 123)); 24} catch (\Exception $e) { 25 echo $e->getMessage() . PHP_EOL; 26} 27 28try { 29 var_dump($obj = new finfo(FILEINFO_MIME, 1.0)); 30} catch (\Exception $e) { 31 echo $e->getMessage() . PHP_EOL; 32} 33 34try { 35 var_dump($obj = new finfo(FILEINFO_MIME, '/foo/bar/inexistent')); 36} catch (\Exception $e) { 37 echo $e->getMessage() . PHP_EOL; 38} 39?> 40--EXPECTF-- 41finfo_open(): Argument #2 ($magic_database) must not contain any null bytes 42object(finfo)#%d (0) { 43} 44object(finfo)#%d (0) { 45} 46 47Warning: finfo_open(%s123): Failed to open stream: No such file or directory in %s on line %d 48 49Warning: finfo_open(%s123): Failed to open stream: No such file or directory in %s on line %d 50 51Warning: finfo_open(): Failed to load magic database at "%s123" in %s on line %d 52bool(false) 53 54Warning: finfo_open(%s1): Failed to open stream: No such file or directory in %s on line %d 55 56Warning: finfo_open(%s1): Failed to open stream: No such file or directory in %s on line %d 57 58Warning: finfo_open(): Failed to load magic database at "%s1" in %s on line %d 59bool(false) 60 61Warning: finfo_open(%sinexistent): Failed to open stream: No such file or directory in %s on line %d 62 63Warning: finfo_open(%sinexistent): Failed to open stream: No such file or directory in %s on line %d 64 65Warning: finfo_open(): Failed to load magic database at "%sinexistent" in %s on line %d 66bool(false) 67object(finfo)#%d (%d) { 68} 69object(finfo)#%d (%d) { 70} 71finfo::__construct(%s123): Failed to open stream: No such file or directory 72finfo::__construct(%s1): Failed to open stream: No such file or directory 73finfo::__construct(%sinexistent): Failed to open stream: No such file or directory 74