Bug #75668 [Fbk->Opn]: count function accuses that could not count an ArrayObject

From: Date: Tue, 12 Dec 2017 03:46:15 +0000
Subject: Bug #75668 [Fbk->Opn]: count function accuses that could not count an ArrayObject
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-213060@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=75668&edit=1 ID: 75668 User updated by: carusogabriel34 at gmail dot com Reported by: carusogabriel34 at gmail dot com Summary: count function accuses that could not count an ArrayObject -Status: Feedback +Status: Open Type: Bug Package: SPL related Operating System: Ubuntu 14.04.5 LTS PHP Version: 7.2.0 Block user comment: N Private report: N New Comment: Sorry requinix@php.net, this was my first bug report. Here's the code; <?php class Foo { protected $emailLog; public function initialize() { $this->emailLog = new ArrayObject; } public function summary() { return count($this->emailLog) === 0 ? '' : count($this->emailLog); } } $log = new Foo; $log->initialize(); $log->summary(); ?> Previous Comments: ------------------------------------------------------------------------ [2017-12-12 03:27:22] requinix@php.net Thank you for this bug report. To properly diagnose the problem, we need a short but complete example script to be able to reproduce this bug ourselves. A proper reproducing script starts with <?php and ends with ?>, is max. 10-20 lines long and does not require any external resources such as databases, etc. If the script requires a database to demonstrate the issue, please make sure it creates all necessary tables, stored procedures etc. Please avoid embedding huge scripts into the report. Works for me. https://3v4l.org/lKNqU ------------------------------------------------------------------------ [2017-12-12 03:20:15] carusogabriel34 at gmail dot com Description: ------------ Discovered while trying to test cakephp/debug_kit against PHP 7.2 (https://travis-ci.org/cakephp/debug_kit/jobs/314694265#L553). Test script: --------------- $log = new ArrayObject; count($log); Expected result: ---------------- The count method should count and ArrayObject, as it implements Countable. ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=75668&edit=1

« previous php.bugs (#213060) next »