php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #72553 SplQueue::valid() always return false.
Submitted: 2016-07-06 09:34 UTC Modified: 2016-07-06 09:46 UTC
From: hjkim at mkinternet dot com Assigned:
Status: Not a bug Package: SPL related
PHP Version: 7.0.8 OS: CentOS Release 6.4 (Final)
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
23 - 16 = ?
Subscribe to this entry?

 
 [2016-07-06 09:34 UTC] hjkim at mkinternet dot com
Description:
------------
---
From manual page: http://www.php.net/class.splqueue
---

valid() method in SqlQueue always return false.


$q = new \SplQueue();
var_dump($q->valid()); // false
$q->enqueue('a');
var_dump($q->valid()); // false
var_dump($q->count()); // 1


Test script:
---------------
<?php
$q = new \SplQueue();
var_dump($q->valid()); // false
$q->enqueue('a');
var_dump($q->valid()); // false
var_dump($q->count()); // 1

Expected result:
----------------
<?php
$q = new \SplQueue();
var_dump($q->valid()); // false
$q->enqueue('a');
var_dump($q->valid()); // true
var_dump($q->count()); // 1


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2016-07-06 09:46 UTC] requinix@php.net
-Status: Open +Status: Not a bug
 [2016-07-06 09:46 UTC] requinix@php.net
valid() is part of the Iterator interface.
http://php.net/manual/en/iterator.valid.php

To use the method properly you must first call rewind() or next(), as would happen if the object was being used in a foreach.
https://3v4l.org/MvGTV
 [2016-07-07 05:09 UTC] hjkim at mkinternet dot com
I realized it after reporting bug. Sorry and Thank to reply.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat May 04 16:01:31 2024 UTC