Skip to content

Language: String offset access and assignment ($str[$i]) #198

@PurHur

Description

@PurHur

Problem

Byte-level string manipulation ($slug[0], mutating chars) is common in routers and sanitizers. Compiler may not lower string dim-fetch/write uniformly across VM/JIT.

Goal

Read/write single-byte offsets on PHP strings (Zend-compatible for ASCII subset).

Tasks

  • Audit TYPE_ARRAY_DIM_FETCH for string operands in lib/Compiler.php
  • VM: bounds checks, copy-on-write for string updates
  • JIT: native byte load/store on JitNativeString / string type
  • PHPT: read, assign, out-of-range behavior
  • Document UTF-8 limitation (multibyte = Stdlib: mb_strlen and UTF-8 byte-safe string metrics #158)

Acceptance criteria

$s = 'abc';
$s[1] = 'z';
echo $s; // azc

Files

  • lib/Compiler.php, lib/VM.php, lib/JIT.php, lib/JIT/JitNativeString.php

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions