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
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: gmblar+php at gmail dot com
New email:
PHP Version: OS:

 

 [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-2024 The PHP Group
All rights reserved.
Last updated: Tue Mar 19 11:01:28 2024 UTC