Skip to content

Commit fe529ed

Browse files
authored
Merge pull request #32 from GravityPDF/iterator-deprecation-notice
Resolve PHP8.1 Deprecation Notice
2 parents 663ee48 + be4055d commit fe529ed

File tree

3 files changed

+22
-0
lines changed

3 files changed

+22
-0
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
QueryPath Changelog
22
===========================
33

4+
# 3.2.1
5+
- Fix QueryPath\QueryPathIterator::current() deprecation notice in PHP8.1
6+
47
# 3.2.0
58

69
- Fixes a number of type-related errors on PHP 8.1

src/QueryPathIterator.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ class QueryPathIterator extends IteratorIterator
2626
public $options = [];
2727
private $qp;
2828

29+
#[\ReturnTypeWillChange]
2930
public function current()
3031
{
3132
if (! isset($this->qp)) {
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?php
2+
3+
namespace QueryPathTests;
4+
5+
class QueryPathIteratorTest extends TestCase
6+
{
7+
public function testCurrent()
8+
{
9+
$qp = qp('<ul><li>Item1</li><li>Item2</li></ul>', 'li');
10+
11+
$iterator = $qp->getIterator();
12+
$iterator->rewind();
13+
14+
$this->assertSame('Item1', $iterator->current()->text());
15+
$iterator->next();
16+
$this->assertSame('Item2', $iterator->current()->text());
17+
}
18+
}

0 commit comments

Comments
 (0)