strtok is not comptime()

Fixes GH-13145
Closes GH-13148
This commit is contained in:
Ilija Tovilo 2024-01-14 18:10:05 +01:00
parent 00ea756c93
commit ed64949d12
No known key found for this signature in database
GPG key ID: A4F5D403F118200A
4 changed files with 21 additions and 3 deletions

3
NEWS
View file

@ -10,6 +10,9 @@ PHP NEWS
. Fixed bug GH-12996 (Incorrect SCRIPT_NAME with Apache ProxyPassMatch when
plus in path). (Jakub Zelenka)
- Opcache:
. Fixed bug GH-13145 (strtok() is not comptime). (ilutov)
- Phar:
. Fixed bug #71465 (PHAR doesn't know about litespeed). (nielsdos)

16
Zend/tests/gh13145.phpt Normal file
View file

@ -0,0 +1,16 @@
--TEST--
GH-13145: strtok() misoptimization
--FILE--
<?php
$tok = strtok("This is\tan example\nstring", " \n\t");
while ($tok !== false) {
var_dump($tok);
$tok = strtok(" \n\t");
}
?>
--EXPECT--
string(4) "This"
string(2) "is"
string(2) "an"
string(7) "example"
string(6) "string"

View file

@ -2337,7 +2337,6 @@ function implode(string|array $separator, ?array $array = null): string {}
function join(string|array $separator, ?array $array = null): string {}
/**
* @compile-time-eval
* @refcount 1
*/
function strtok(string $string, ?string $token = null): string|false {}

View file

@ -1,5 +1,5 @@
/* This is a generated file, edit the .stub.php file instead.
* Stub hash: 487cee0751d47b18bf0a8fbdb050313783f1b369 */
* Stub hash: 7389d094a842a2289cd32cb37386e5e40ea7e031 */
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_set_time_limit, 0, 1, _IS_BOOL, 0)
ZEND_ARG_TYPE_INFO(0, seconds, IS_LONG, 0)
@ -3087,7 +3087,7 @@ static const zend_function_entry ext_functions[] = {
ZEND_SUPPORTS_COMPILE_TIME_EVAL_FE(explode, arginfo_explode)
ZEND_SUPPORTS_COMPILE_TIME_EVAL_FE(implode, arginfo_implode)
ZEND_FALIAS(join, implode, arginfo_join)
ZEND_SUPPORTS_COMPILE_TIME_EVAL_FE(strtok, arginfo_strtok)
ZEND_FE(strtok, arginfo_strtok)
ZEND_SUPPORTS_COMPILE_TIME_EVAL_FE(strtoupper, arginfo_strtoupper)
ZEND_SUPPORTS_COMPILE_TIME_EVAL_FE(strtolower, arginfo_strtolower)
ZEND_FE(str_increment, arginfo_str_increment)