Skip to content

Commit 61e07ca

Browse files
committed
Add PHP 7.4 compatibility
1 parent 28e35e4 commit 61e07ca

File tree

5 files changed

+18
-11
lines changed

5 files changed

+18
-11
lines changed

.travis.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,15 @@ php:
1010
- 7.1
1111
- 7.2
1212
- 7.3
13-
- hhvm
13+
- 7.4snapshot
1414
- nightly
1515

1616
matrix:
1717
allow_failures:
1818
- php: nightly
1919

2020
before_script:
21-
- curl -sSL https://dl.bintray.com/xp-runners/generic/xp-run-master.sh > xp-run
21+
- curl -sSL https://dl.bintray.com/xp-runners/generic/xp-run-8.1.7.sh > xp-run
2222
- composer install --prefer-dist
2323
- echo "vendor/autoload.php" > composer.pth
2424

ChangeLog.md

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

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

6+
## 8.1.0 / 2018-08-10
7+
8+
* Made compatible with PHP 7.4 - refrain using `{}` for string offsets
9+
(@thekid)
10+
611
## 8.0.0 / 2017-06-03
712

813
* **Heads up:** Dropped PHP 5.5 support - @thekid

src/main/php/text/StreamTokenizer.class.php

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
<?php namespace text;
2-
2+
3+
use io\streams\Seekable;
4+
use lang\IllegalStateException;
5+
use util\Objects;
6+
37
/**
48
* A stream tokenizer is a tokenizer that works on streams.
59
*
@@ -28,12 +32,10 @@ public function reset() {
2832
$this->_stack= [];
2933

3034
if ($this->_src) {
31-
if ($this->_src instanceof \io\streams\Seekable) {
35+
if ($this->_src instanceof Seekable) {
3236
$this->_src->seek(0, SEEK_SET);
3337
} else {
34-
throw new \lang\IllegalStateException(
35-
'Cannot reset, Source '.\xp::stringOf($this->_src).' is not seekable'
36-
);
38+
throw new IllegalStateException('Cannot reset, Source '.Objects::stringOf($this->_src).' is not seekable');
3739
}
3840
}
3941
$this->_src= $this->source;
@@ -79,7 +81,7 @@ public function nextToken($delimiters= null) {
7981
if (!$this->returnDelims || $offset > 0) $this->_stack[]= substr($this->_buf, 0, $offset);
8082
$l= strlen($this->_buf);
8183
if ($this->returnDelims && $offset < $l) {
82-
$this->_stack[]= $this->_buf{$offset};
84+
$this->_stack[]= $this->_buf[$offset];
8385
}
8486
$offset++;
8587
$this->_buf= $offset < $l ? substr($this->_buf, $offset) : false;

src/main/php/text/StringTokenizer.class.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ public function nextToken($delimiters= null) {
7777
$offset= strcspn($this->source, $delimiters ? $delimiters : $this->delimiters, $this->_ofs);
7878
if (!$this->returnDelims || $offset > 0) $this->_stack[]= substr($this->source, $this->_ofs, $offset);
7979
if ($this->returnDelims && $this->_ofs + $offset < $this->_len) {
80-
$this->_stack[]= $this->source{$this->_ofs + $offset};
80+
$this->_stack[]= $this->source[$this->_ofs + $offset];
8181
}
8282
$this->_ofs+= $offset+ 1;
8383
}

src/main/php/text/TextTokenizer.class.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php namespace text;
22

3-
use io\streams\Reader;
43
use io\IOException;
4+
use io\streams\Reader;
55
use lang\IllegalStateException;
66

77
/**
@@ -82,7 +82,7 @@ public function nextToken($delimiters= null) {
8282
if (!$this->returnDelims || $offset > 0) $this->_stack[]= substr($this->_buf, 0, $offset);
8383
$l= strlen($this->_buf);
8484
if ($this->returnDelims && $offset < $l) {
85-
$this->_stack[]= $this->_buf{$offset};
85+
$this->_stack[]= $this->_buf[$offset];
8686
}
8787
$offset++;
8888
$this->_buf= $offset < $l ? substr($this->_buf, $offset) : false;

0 commit comments

Comments
 (0)