Edit report at https://bugs.php.net/bug.php?id=65867&edit=1

 ID:                 65867
 User updated by:    kakserpompoyaitsam at gmail dot com
 Reported by:        kakserpompoyaitsam at gmail dot com
-Summary:            strace php -r 'class A implements Countable
                     {function count() {return count($th
+Summary:            Countable interface infinite recursion.
 Status:             Open
 Type:               Bug
 Package:            SPL related
 Operating System:   Irrelevant
 PHP Version:        5.5.4
 Block user comment: N
 Private report:     N

 New Comment:

Changed title.


Previous Comments:
------------------------------------------------------------------------
[2013-10-09 04:44:30] kakserpompoyaitsam at gmail dot com

Description:
------------
Easy reproducible segmentation fault.
It seems that count($this) doesn't check recursion. I think that count($this) 
should check if it is called inside of $this->count(), and if so, should ignore 
the Countable interface and just count the properties. Use case: if your object 
got special properties that you do not want to count, you can use something 
liek that: "function count() {return count($this) - 
numberOfSpecialProperties;}" 

Test script:
---------------
class A implements Countable {function count() {return count($this);}} 
count(new A);

Expected result:
----------------
0

Actual result:
--------------
Segmentation fault.


------------------------------------------------------------------------



-- 
Edit this bug report at https://bugs.php.net/bug.php?id=65867&edit=1

Reply via email to