#40782 [NEW]: boolean argument type to function throws Catchable fatal error.

Ask a Question related to PHP Bugs, Design and Development.

  1. #1

    Default #40782 [NEW]: boolean argument type to function throws Catchable fatal error.

    From: tims at arizona dot edu
    Operating system: Debian Linux
    PHP version: 5.2.1
    PHP Bug Type: Scripting Engine problem
    Bug description: boolean argument type to function throws Catchable fatal error.

    Description:
    ------------
    I have found a minimal reproducible test case that consistently fails. I
    believe this should work as a typed parameter but php5 dies with the
    result below.


    Reproduce code:
    ---------------
    $b = true;
    function f( boolean $a ) { return $a; }
    f( $b );

    Expected result:
    ----------------
    The above code does not do much except return the boolean that was passed
    in. My larger block of code uses typed arguments to ensure the type of
    data being passed in. The bool type does not work and I can not find a
    suitable workaround.



    Actual result:
    --------------
    Catchable fatal error: Argument 1 passed to f() must be an instance of
    boolean, boolean given, called in
    /home/bink/Projects/opticsnow/web_software/dev_space/a.php on line 5 and
    defined in /home/bink/Projects/opticsnow/web_software/dev_space/a.php on
    line 4


    --
    Edit bug report at [url]http://bugs.php.net/?id=40782&edit=1[/url]
    --
    Try a CVS snapshot (PHP 4.4): [url]http://bugs.php.net/fix.php?id=40782&r=trysnapshot44[/url]
    Try a CVS snapshot (PHP 5.2): [url]http://bugs.php.net/fix.php?id=40782&r=trysnapshot52[/url]
    Try a CVS snapshot (PHP 6.0): [url]http://bugs.php.net/fix.php?id=40782&r=trysnapshot60[/url]
    Fixed in CVS: [url]http://bugs.php.net/fix.php?id=40782&r=fixedcvs[/url]
    Fixed in release: [url]http://bugs.php.net/fix.php?id=40782&r=alreadyfixed[/url]
    Need backtrace: [url]http://bugs.php.net/fix.php?id=40782&r=needtrace[/url]
    Need Reproduce Script: [url]http://bugs.php.net/fix.php?id=40782&r=needscript[/url]
    Try newer version: [url]http://bugs.php.net/fix.php?id=40782&r=oldversion[/url]
    Not developer issue: [url]http://bugs.php.net/fix.php?id=40782&r=support[/url]
    Expected behavior: [url]http://bugs.php.net/fix.php?id=40782&r=notwrong[/url]
    Not enough info: [url]http://bugs.php.net/fix.php?id=40782&r=notenoughinfo[/url]
    Submitted twice: [url]http://bugs.php.net/fix.php?id=40782&r=submittedtwice[/url]
    register_globals: [url]http://bugs.php.net/fix.php?id=40782&r=globals[/url]
    PHP 3 support discontinued: [url]http://bugs.php.net/fix.php?id=40782&r=php3[/url]
    Daylight Savings: [url]http://bugs.php.net/fix.php?id=40782&r=dst[/url]
    IIS Stability: [url]http://bugs.php.net/fix.php?id=40782&r=isapi[/url]
    Install GNU Sed: [url]http://bugs.php.net/fix.php?id=40782&r=gnused[/url]
    Floating point limitations: [url]http://bugs.php.net/fix.php?id=40782&r=float[/url]
    No Zend Extensions: [url]http://bugs.php.net/fix.php?id=40782&r=nozend[/url]
    MySQL Configuration Error: [url]http://bugs.php.net/fix.php?id=40782&r=mysqlcfg[/url]
    tims at arizona dot edu Guest

  2. Similar Questions and Discussions

    1. Fatal error: Call to undefined function
      I'm a PHP and MySQL newbie. I have a feeling a lot of you may have seen this before. I'm teaching myself PHP/MySQL and trying to setup a guestbook....
    2. GetOpts: boolean and argument value combos
      Hey Perl Peps, I am stuck in the mudd and hoping someone can give me a few clues that will help get me back on track. I want to submit some...
    3. Fatal error: Call to undefined function: imagecreatefromjpeg() in...
      I am getting a "Fatal error: Call to undefined function: imagecreatefromjpeg() in..." error in one of my scripts, and after doing a bit of...
    4. Fatal error: Call to undefined function: imagecreatefromjpeg()
      Folks, I feel like pulling my hair out - I tried unsuccessfully over the past few days to install ImagMagick but because of version conflicts and...
    5. Fatal error: Call to undefined function: mysql_connect()
      I get this error "Fatal error: Call to undefined function: mysql_connect() " in one script. whereas phpMyAdmin is installed in another directory and...
  3. #2

    Default #40782 [Com]: boolean argument type to function throws Catchable fatal error.

    ID: 40782
    Comment by: judas dot iscariote at gmail dot com
    Reported By: tims at arizona dot edu
    Status: Open
    Bug Type: Scripting Engine problem
    Operating System: Debian Linux
    PHP Version: 5.2.1
    New Comment:

    I indeed think that booleans should be accepted, but this is not a bug,
    but a feature request :) actually type hinting works for Objects and
    arrays **only**.

    There is a patch to allow this IIRC but has not been merged into,and
    probably will only be included with PHP6.


    Previous Comments:
    ------------------------------------------------------------------------

    [2007-03-12 06:04:45] tims at arizona dot edu

    Description:
    ------------
    I have found a minimal reproducible test case that consistently fails.
    I believe this should work as a typed parameter but php5 dies with the
    result below.


    Reproduce code:
    ---------------
    $b = true;
    function f( boolean $a ) { return $a; }
    f( $b );

    Expected result:
    ----------------
    The above code does not do much except return the boolean that was
    passed in. My larger block of code uses typed arguments to ensure the
    type of data being passed in. The bool type does not work and I can not
    find a suitable workaround.



    Actual result:
    --------------
    Catchable fatal error: Argument 1 passed to f() must be an instance of
    boolean, boolean given, called in
    /home/bink/Projects/opticsnow/web_software/dev_space/a.php on line 5
    and defined in
    /home/bink/Projects/opticsnow/web_software/dev_space/a.php on line 4



    ------------------------------------------------------------------------


    --
    Edit this bug report at [url]http://bugs.php.net/?id=40782&edit=1[/url]
    judas dot iscariote at gmail dot com Guest

  4. #3

    Default #40782 [Opn->Bgs]: boolean argument type to function throws Catchable fatal error.

    ID: 40782
    Updated by: [email]bjori@php.net[/email]
    Reported By: tims at arizona dot edu
    -Status: Open
    +Status: Bogus
    Bug Type: Scripting Engine problem
    Operating System: Debian Linux
    PHP Version: 5.2.1
    New Comment:

    Thank you for taking the time to write to us, but this is not
    a bug. Please double-check the documentation available at
    [url]http://www.php.net/manual/[/url] and the instructions on how to report
    a bug at [url]http://bugs.php.net/how-to-report.php[/url]

    [url]http://devzone.zend.com/node/view/id/1518#Heading8[/url]


    Previous Comments:
    ------------------------------------------------------------------------

    [2007-03-12 06:15:53] judas dot iscariote at gmail dot com

    I indeed think that booleans should be accepted, but this is not a bug,
    but a feature request :) actually type hinting works for Objects and
    arrays **only**.

    There is a patch to allow this IIRC but has not been merged into,and
    probably will only be included with PHP6.

    ------------------------------------------------------------------------

    [2007-03-12 06:04:45] tims at arizona dot edu

    Description:
    ------------
    I have found a minimal reproducible test case that consistently fails.
    I believe this should work as a typed parameter but php5 dies with the
    result below.


    Reproduce code:
    ---------------
    $b = true;
    function f( boolean $a ) { return $a; }
    f( $b );

    Expected result:
    ----------------
    The above code does not do much except return the boolean that was
    passed in. My larger block of code uses typed arguments to ensure the
    type of data being passed in. The bool type does not work and I can not
    find a suitable workaround.



    Actual result:
    --------------
    Catchable fatal error: Argument 1 passed to f() must be an instance of
    boolean, boolean given, called in
    /home/bink/Projects/opticsnow/web_software/dev_space/a.php on line 5
    and defined in
    /home/bink/Projects/opticsnow/web_software/dev_space/a.php on line 4



    ------------------------------------------------------------------------


    --
    Edit this bug report at [url]http://bugs.php.net/?id=40782&edit=1[/url]
    bjori@php.net Guest

  5. #4

    Default #40782 [Bgs->Csd]: only arrays and objects can be passed as typed args.

    ID: 40782
    User updated by: tims at arizona dot edu
    -Summary: boolean argument type to function throws Catchable
    fatal error.
    Reported By: tims at arizona dot edu
    -Status: Bogus
    +Status: Closed
    Bug Type: Scripting Engine problem
    Operating System: Debian Linux
    PHP Version: 5.2.1
    New Comment:

    For anyone that google's the thread, and wants a work-around you might
    try something like:

    function f( $bool_arg ) {
    if( ! is_bool( $bool_arg ) )
    throw new Exception("Argument is not boolean.");

    .. rest of function declaration ..

    }

    at least until php6.


    Previous Comments:
    ------------------------------------------------------------------------

    [2007-03-12 08:49:40] [email]bjori@php.net[/email]

    Thank you for taking the time to write to us, but this is not
    a bug. Please double-check the documentation available at
    [url]http://www.php.net/manual/[/url] and the instructions on how to report
    a bug at [url]http://bugs.php.net/how-to-report.php[/url]

    [url]http://devzone.zend.com/node/view/id/1518#Heading8[/url]

    ------------------------------------------------------------------------

    [2007-03-12 06:15:53] judas dot iscariote at gmail dot com

    I indeed think that booleans should be accepted, but this is not a bug,
    but a feature request :) actually type hinting works for Objects and
    arrays **only**.

    There is a patch to allow this IIRC but has not been merged into,and
    probably will only be included with PHP6.

    ------------------------------------------------------------------------

    [2007-03-12 06:04:45] tims at arizona dot edu

    Description:
    ------------
    I have found a minimal reproducible test case that consistently fails.
    I believe this should work as a typed parameter but php5 dies with the
    result below.


    Reproduce code:
    ---------------
    $b = true;
    function f( boolean $a ) { return $a; }
    f( $b );

    Expected result:
    ----------------
    The above code does not do much except return the boolean that was
    passed in. My larger block of code uses typed arguments to ensure the
    type of data being passed in. The bool type does not work and I can not
    find a suitable workaround.



    Actual result:
    --------------
    Catchable fatal error: Argument 1 passed to f() must be an instance of
    boolean, boolean given, called in
    /home/bink/Projects/opticsnow/web_software/dev_space/a.php on line 5
    and defined in
    /home/bink/Projects/opticsnow/web_software/dev_space/a.php on line 4



    ------------------------------------------------------------------------


    --
    Edit this bug report at [url]http://bugs.php.net/?id=40782&edit=1[/url]
    tims at arizona dot edu Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139