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

From: Date: Mon, 12 Mar 2007 06:15:54 +0000
Subject: #40782 [Com]: boolean argument type to function throws Catchable fatal error.
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-110212@lists.php.net to get a copy of this message
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 http://bugs.php.net/?id=40782&edit=1

« previous php.bugs (#110212) next »