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
Have you experienced this issue?
Rate the importance of this bug to you:

 [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

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2010-12-01 16:25 UTC] jani@php.net
-Package: Feature/Change Request +Package: Filter related
 
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Fri Jul 19 23:01:25 2019 UTC