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

From: Date: Mon, 12 Mar 2007 08:49:41 +0000
Subject: #40782 [Opn->Bgs]: boolean argument type to function throws Catchable fatal error.
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-110215@lists.php.net to get a copy of this message
ID: 40782 Updated by: bjori@php.net 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 http://www.php.net/manual/ and the instructions on how to report a bug at http://bugs.php.net/how-to-report.php http://devzone.zend.com/node/view/id/1518#Heading8 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 http://bugs.php.net/?id=40782&edit=1

« previous php.bugs (#110215) next »