Req #51922 [Opn->Bgs]: Controlled typecasting for objects that implement the "Countable" interface
| From: | johannes@php.net | Date: | Fri, 06 Aug 2010 23:55:32 +0000 |
| Subject: | Req #51922 [Opn->Bgs]: Controlled typecasting for objects that implement the "Countable" interface | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-153195@lists.php.net to get a copy of this message | ||
Edit report at http://bugs.php.net/bug.php?id=51922&edit=1
ID: 51922
Updated by: johannes@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