Skip to content

Commit 80d9b78

Browse files
committed
Fix PHP 8.1 compatibility
1 parent c9f6d5b commit 80d9b78

File tree

2 files changed

+12
-8
lines changed

2 files changed

+12
-8
lines changed

ChangeLog.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,12 @@ Tokenize log
33

44
## ?.?.? / ????-??-??
55

6+
## 9.0.2 / 2021-08-16
7+
8+
* Fixed PHP 8.1 compatibility by declaring `getIterator()` with correct
9+
return type. See https://wiki.php.net/rfc/internal_method_return_types
10+
(@thekid)
11+
612
## 9.0.1 / 2020-10-09
713

814
* Fixed reading past end to consistently return `NULL` - @thekid

src/main/php/text/Tokenizer.class.php

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
11
<?php namespace text;
2+
3+
use Traversable, IteratorAggregate;
4+
25
/**
36
* A tokenizer splits input strings into tokens.
47
*
58
* @see xp://text.StringTokenizer
69
* @see xp://text.StreamTokenizer
710
* @see php://strtok
811
*/
9-
abstract class Tokenizer implements \IteratorAggregate {
12+
abstract class Tokenizer implements IteratorAggregate {
1013
public $delimiters;
1114
public $returnDelims;
1215
protected $source;
@@ -25,13 +28,8 @@ public function __construct($source, $delimiters= ' ', $returnDelims= false) {
2528
$this->reset();
2629
}
2730

28-
/**
29-
* Returns an iterator for use in foreach()
30-
*
31-
* @see php://language.oop5.iterations
32-
* @return php.Iterator
33-
*/
34-
public function getIterator() {
31+
/** Returns an iterator for use in foreach() */
32+
public function getIterator(): Traversable {
3533
while ($this->hasMoreTokens()) {
3634
yield $this->nextToken();
3735
}

0 commit comments

Comments
 (0)