php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #75668 count function accuses that could not count an ArrayObject
Submitted: 2017-12-12 03:20 UTC Modified: 2017-12-12 04:03 UTC
From: carusogabriel34 at gmail dot com Assigned:
Status: Not a bug Package: SPL related
PHP Version: 7.2.0 OS: Ubuntu 14.04.5 LTS
Private report: No CVE-ID: None
 [2017-12-12 03:20 UTC] 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.


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2017-12-12 03:27 UTC] requinix@php.net
-Status: Open +Status: Feedback
 [2017-12-12 03:27 UTC] 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:46 UTC] carusogabriel34 at gmail dot com
-Status: Feedback +Status: Open
 [2017-12-12 03:46 UTC] carusogabriel34 at gmail dot com
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();
?>
 [2017-12-12 03:49 UTC] requinix@php.net
-Status: Open +Status: Feedback
 [2017-12-12 03:49 UTC] requinix@php.net
That works too. https://3v4l.org/OZQGr
 [2017-12-12 03:54 UTC] carusogabriel34 at gmail dot com
-Status: Feedback +Status: Open
 [2017-12-12 03:54 UTC] carusogabriel34 at gmail dot com
Strange. I've use empty instead and works. Gonna close it, and if it show up again, I report it. Thanks!
 [2017-12-12 03:55 UTC] carusogabriel34 at gmail dot com
-Status: Open +Status: Closed
 [2017-12-12 03:55 UTC] carusogabriel34 at gmail dot com
Close due impracticable.
 [2017-12-12 04:03 UTC] requinix@php.net
-Status: Closed +Status: Not a bug
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed Apr 24 21:01:29 2024 UTC