Edit report at https://bugs.php.net/bug.php?id=61173&edit=1
ID: 61173 Updated by: cataphr...@php.net Reported by: vr...@php.net Summary: Unable to detect error from finfo constructor -Status: Open +Status: Feedback Type: Bug Package: Filesystem function related Operating System: Irrelevant PHP Version: 5.4.0RC8 Block user comment: N Private report: N New Comment: The manual suggests new should give NULL in case of error: http://php.net/finfo_open . Why do you expect the exception? In any case, there's of course a bug because new is giving an object. Previous Comments: ------------------------------------------------------------------------ [2012-02-23 20:45:57] vr...@php.net Description: ------------ There is currently no way to detect error in finfo::__construct() other than defining own set_error_handler(). It should throw an exception in case of an error. new finfo() always creates the object but this object is unusable if constructor doesn't succeed. Test script: --------------- $finfo = null; try { $finfo = new finfo(1, '', false); } catch (Exception $e) { echo "Error creating finfo.\n"; } var_dump($finfo); Expected result: ---------------- Error creating finfo. NULL Actual result: -------------- object(finfo)#1 (0) { } ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=61173&edit=1