Edit report at http://bugs.php.net/bug.php?id=51922&edit=1
ID: 51922 Updated by: johan...@php.net Reported by: korchasa at gmail dot com Summary: Controlled typecasting for objects that implement the "Countable" interface -Status: Open +Status: Bogus Type: Feature/Change Request Package: SPL related Operating System: Any PHP Version: 5.3.2 Block user comment: N New Comment: Even with count() returning null an object often is a "true" value and we decided not to add other casting functions (other than __toString()) Previous Comments: ------------------------------------------------------------------------ [2010-05-26 15:06:27] korchasa at gmail dot com Description: ------------ Now we have no ways to controll type casting of Countable-objects to boolean type. We would like to work with the SPL-derivatives, as well as with the built- in types. Test script: --------------- <?php class myCountable implements Countable { function count() { return 0; } } var_dump((boolean) array()); var_dump((boolean) new myCountable()); Expected result: ---------------- bool(false) bool(false) Actual result: -------------- bool(false) bool(true) ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/bug.php?id=51922&edit=1