Bug #80462 [NEW]: Nullsafe operator tokenize with TOKEN_PARSE flag fails
From: possumfromspace at gmail dot com
Operating system: ubuntu
PHP version: 8.0.0
Package: *General Issues
Bug Type: Bug
Bug description:Nullsafe operator tokenize with TOKEN_PARSE flag fails
Description:
------------
On:
PHP 8.0.0 (cli) (built: Dec 1 2020 04:01:52) ( NTS )
Copyright (c) The PHP Group
Zend Engine v4.0.0-dev, Copyright (c) Zend Technologies
When tokenizing as following:
```
<?php token_get_all('<?php $foo = $a?->b();', TOKEN_PARSE);
```
the T_NULLSAFE_OBJECT_OPERATOR is missing
https://3v4l.org/t5aAA
Test script:
---------------
```
<?php token_get_all('<?php $foo = $a?->b();', TOKEN_PARSE);
```
results in something like:
```
array(10) {
[0]=>
array(3) {
[0]=>
int(390)
[1]=>
string(6) "<?php "
[2]=>
int(1)
}
[1]=>
array(3) {
[0]=>
int(315)
[1]=>
string(4) "$foo"
[2]=>
int(1)
}
[2]=>
array(3) {
[0]=>
int(393)
[1]=>
string(1) " "
[2]=>
int(1)
}
[3]=>
string(1) "="
[4]=>
array(3) {
[0]=>
int(393)
[1]=>
string(1) " "
[2]=>
int(1)
}
[5]=>
array(3) {
[0]=>
int(315)
[1]=>
string(2) "$a"
[2]=>
int(1)
}
[6]=>
array(3) {
[0]=>
int(311)
[1]=>
string(1) "b"
[2]=>
int(1)
}
[7]=>
string(1) "("
[8]=>
string(1) ")"
[9]=>
string(1) ";"
}
```
expected same result as
```
<?php token_get_all('<?php $foo = $a?->b();');
```
```
array(11) {
[0]=>
array(3) {
[0]=>
int(390)
[1]=>
string(6) "<?php "
[2]=>
int(1)
}
[1]=>
array(3) {
[0]=>
int(315)
[1]=>
string(4) "$foo"
[2]=>
int(1)
}
[2]=>
array(3) {
[0]=>
int(393)
[1]=>
string(1) " "
[2]=>
int(1)
}
[3]=>
string(1) "="
[4]=>
array(3) {
[0]=>
int(393)
[1]=>
string(1) " "
[2]=>
int(1)
}
[5]=>
array(3) {
[0]=>
int(315)
[1]=>
string(2) "$a"
[2]=>
int(1)
}
[6]=>
array(3) {
[0]=>
int(387)
[1]=>
string(3) "?->"
[2]=>
int(1)
}
[7]=>
array(3) {
[0]=>
int(311)
[1]=>
string(1) "b"
[2]=>
int(1)
}
[8]=>
string(1) "("
[9]=>
string(1) ")"
[10]=>
string(1) ";"
}
```
note the T_NULLSAFE_OBJECT_OPERATOR token @ index 6
https://3v4l.org/t5aAA
--
Edit bug report at https://bugs.php.net/bug.php?id=80462&edit=1
--
Fix committed: https://bugs.php.net/fix.php?id=80462&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=80462&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=80462&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=80462&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=80462&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=80462&r=support
Expected behavior: https://bugs.php.net/fix.php?id=80462&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=80462&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=80462&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=80462&r=globals
PHP version support discontinued: https://bugs.php.net/fix.php?id=80462&r=phptooold
Daylight Savings: https://bugs.php.net/fix.php?id=80462&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=80462&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=80462&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=80462&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=80462&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=80462&r=mysqlcfg
Thread (2 messages)
- possumfromspace at gmail dot com