|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2013-10-09 04:46 UTC] kakserpompoyaitsam at gmail dot com
-Summary: strace php -r 'class A implements Countable {function
count() {return count($th
+Summary: Countable interface infinite recursion.
[2013-10-09 04:46 UTC] kakserpompoyaitsam at gmail dot com
[2013-10-09 13:14 UTC] johannes@php.net
-Status: Open
+Status: Wont fix
[2013-10-09 13:14 UTC] johannes@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Mon Oct 27 12:00:02 2025 UTC |
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.