Skip to content

Stdlib: strtok() — tokenize strings (ext/standard/string.c parity) #3201

Description

@PurHur

Category

stdlib

Problem

strtok() is missing from ext/standard. Zend uses it for simple parsers, config scanners, and legacy code paths. Calling it today fails at runtime (function_exists('strtok') → false).

php-src reference

Repro (failure today)

<?php
$s = "a,b,c";
echo strtok($s, ","); // a
echo strtok(",");     // b
echo strtok(",");     // c
echo strtok(",") === false ? "end" : "bad";
./script/docker-exec.sh -- bash -lc 'source script/php-env.sh && php bin/vm.php repro.php'

Zend PHP: abcend
This compiler: fatal / undefined function

Scope (this repo)

  • ext/standard/strtok.php — VM implementation with per-request static strtok state (Zend semantics)
  • ext/standard/Module.php — register builtin
  • lib/JIT/Builtin/ — optional JIT lowering after VM green
  • test/compliance/cases/stdlib/strtok.phpt

Done when

  • Repro prints abcend on VM (and JIT/AOT if lowered)
  • Two-argument form resets internal pointer; one-argument form continues same string
  • ./script/ci-fast.sh --filter strtok green
  • docs/capabilities.md row via php script/capability-matrix.php

Related

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:vmVirtual machineenhancementNew feature or requestimplementation-readySpec complete: repro, php-src ref, done-when — safe for workers to claimphase-4:stdlibPhase 4 – stdlib for web apps

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions