Ask a Question related to PHP Bugs, Design and Development.
-
tims at arizona dot edu #1
#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
-
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.... -
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... -
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... -
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... -
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... -
judas dot iscariote at gmail dot com #2
#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
-
bjori@php.net #3
#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
-
tims at arizona dot edu #4
#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



Reply With Quote

