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
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
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

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: Wed Apr 24 22:01:30 2024 UTC