Req #51922 [NEW]: Controlled typecasting for objects that implement the "Countable" interface

From: Date: Wed, 26 May 2010 13:06:27 +0000
Subject: Req #51922 [NEW]: Controlled typecasting for objects that implement the "Countable" interface
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-150846@lists.php.net to get a copy of this message
From:             
Operating system: Any
PHP version:      5.3.2
Package:          SPL related
Bug Type:         Feature/Change Request
Bug description:Controlled typecasting for objects that implement the "Countable"
interface

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 bug report at http://bugs.php.net/bug.php?id=51922&edit=1
-- 
Try a snapshot (PHP 5.2):            http://bugs.php.net/fix.php?id=51922&r=trysnapshot52
Try a snapshot (PHP 5.3):            http://bugs.php.net/fix.php?id=51922&r=trysnapshot53
Try a snapshot (trunk):              http://bugs.php.net/fix.php?id=51922&r=trysnapshottrunk
Fixed in SVN:                        http://bugs.php.net/fix.php?id=51922&r=fixed
Fixed in SVN and need be documented: http://bugs.php.net/fix.php?id=51922&r=needdocs
Fixed in release:                    http://bugs.php.net/fix.php?id=51922&r=alreadyfixed
Need backtrace:                      http://bugs.php.net/fix.php?id=51922&r=needtrace
Need Reproduce Script:               http://bugs.php.net/fix.php?id=51922&r=needscript
Try newer version:                   http://bugs.php.net/fix.php?id=51922&r=oldversion
Not developer issue:                 http://bugs.php.net/fix.php?id=51922&r=support
Expected behavior:                   http://bugs.php.net/fix.php?id=51922&r=notwrong
Not enough info:                     http://bugs.php.net/fix.php?id=51922&r=notenoughinfo
Submitted twice:                     http://bugs.php.net/fix.php?id=51922&r=submittedtwice
register_globals:                    http://bugs.php.net/fix.php?id=51922&r=globals
PHP 4 support discontinued:          http://bugs.php.net/fix.php?id=51922&r=php4
Daylight Savings:                    http://bugs.php.net/fix.php?id=51922&r=dst
IIS Stability:                       http://bugs.php.net/fix.php?id=51922&r=isapi
Install GNU Sed:                     http://bugs.php.net/fix.php?id=51922&r=gnused
Floating point limitations:          http://bugs.php.net/fix.php?id=51922&r=float
No Zend Extensions:                  http://bugs.php.net/fix.php?id=51922&r=nozend
MySQL Configuration Error:           http://bugs.php.net/fix.php?id=51922&r=mysqlcfg



Thread (2 messages)

« previous php.bugs (#150846) next »