Skip to content

Stdlib: str_pad() / count_chars() — TypeError for non-string operands (ext/standard/string.c parity) #4581

Description

@PurHur

Category

stdlib

Problem

str_pad() and count_chars() in Zend throw TypeError when the primary string operand is not a string. This compiler raises LogicException with build-specific messages (str_pad() input must be a string…, count_chars() argument #1 must be a string…).

Pad-length numeric-string coercion is tracked in #4170; count_chars mode/return flags in #4204. This ticket is string operand type validation only.

php-src reference

Repro (failure today)

./script/docker-exec.sh -- bash -lc 'source script/php-env.sh
php test/repro-maintainer/parity_str_pad_count_chars_type.php
php bin/vm.php test/repro-maintainer/parity_str_pad_count_chars_type.php
'
Call Zend PHP 8.x This compiler VM
str_pad([], 5) TypeError LogicException
count_chars([]) TypeError LogicException

Repro script: test/repro-maintainer/parity_str_pad_count_chars_type.php

Scope (this repo)

Module Path
VM ext/standard/str_pad.php, ext/standard/count_chars.php
JIT corresponding JIT builtins in lib/JIT/Builtin/
php-in-php no new runtime/*.c

Done when

  • VM/JIT/AOT throw TypeError with Zend messages for non-string primary operands (str_pad, count_chars).
  • Repro script: Zend and VM both throw TypeError (not LogicException); exit non-zero with catchable error.
  • Happy-path behavior unchanged; add or extend compliance under test/compliance/cases/stdlib/ if missing.

Labels

stdlib, implementation-ready

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 machineimplementation-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