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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: hjkim at mkinternet dot com
New email:
PHP Version: OS:

 

 [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

Pull Requests

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-2025 The PHP Group
All rights reserved.
Last updated: Wed Jul 02 07:01:33 2025 UTC