Skip to content
This repository was archived by the owner on Aug 24, 2021. It is now read-only.
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 55 additions & 0 deletions ext/spl/tests/bug49369.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
--TEST--
Bug #49369 (Change current(), key(), next(), etc. to check for Iterator)
--CREDITS--
KCPHPUG TestFest 2017 - Eric Poe
--FILE--
<?php

class iterator_array implements Iterator
{
protected $arr;

public function __construct(array $array = [])
{
$this->arr = $array;
}

public function key()
{
return key($this->arr);
}

public function current()
{
return current($this->arr);
}

public function valid()
{
return current($this->arr) !== FALSE;
}

public function next()
{
next($this->arr);
}

public function rewind()
{
reset($this->arr);
}
}

$i = new iterator_array([1,2]);
var_dump(current($i));
var_dump(key($i));
next($i);
var_dump(current($i));
var_dump(key($i));
--XFAIL--
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We won't merge XFAIL tests 😕

Bug #49369 - This will fail until current(), key(), next() & other \Iterator methods-as-functions are able to take advantage, properly, of the \Iterator methods.
--EXPECT--
int(1)
int(0)
int(2)
int(1)