php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #50633 Add constant FILTER_EXCEPTION_ON_FAILURE to throw exceptions
Submitted: 2010-01-02 09:47 UTC Modified: 2010-12-01 16:25 UTC
Votes:8
Avg. Score:3.9 ± 1.7
Reproduced:5 of 5 (100.0%)
Same Version:4 (80.0%)
Same OS:5 (100.0%)
From: gmblar+php at gmail dot com Assigned:
Status: Open Package: Filter related
PHP Version: 5.3.1 OS: *
Private report: No CVE-ID: None
 [2010-01-02 09:47 UTC] gmblar+php at gmail dot com
Description:
------------
Add constant FILTER_EXCEPTION_ON_FAILURE to throw meaningful exceptions 
why filter fails

Reproduce code:
---------------
<?php

$foo = filter_input(INPUT_GET, 'foo', FILTER_VALIDATE_INT, array(
    'flags' => FILTER_REQUIRE_SCALAR + FILTER_EXCEPTION_ON_FAILURE,
    'options' => array(
        'min_range' => 5,
        'max_range' => 42
    )
));

var_dump($foo);

?>

Expected result:
----------------
Fatal error: Uncaught exception 'OutOfBoundsException' with message 'foo 
must an integer in range between 5 and 42' in input.php:3 Stack trace: 
#0 {main} thrown in input.php on line 3

Actual result:
--------------
bool(false)

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2010-12-01 16:25 UTC] jani@php.net
-Package: Feature/Change Request +Package: Filter related
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed Dec 04 08:01:29 2024 UTC