Skip to content

Regression: trim/ltrim/rtrim 3rd arg TypeError under PROFILE≥8.4 — Zend ArgumentCountError (re-#23224, ext/standard/string.c) #28230

Description

@PurHur

Category

bug · php-src-strict · phantom $mode · pillar 4 (sibling #28202 StringTrimMode enum; re-#23224)

Problem

Under PHP_COMPILER_PROFILE=8.4, trim(" x ", " ", true) throws TypeError: trim(): Argument #3 ($mode) must be of type StringTrimMode, bool given — proving a phantom 3rd $mode parameter wired to the non-existent StringTrimMode enum (#28202).

Zend/php-src arity is 2 (string $string, string $characters = " \n\r\t\v\0"); excess args are ArgumentCountError: trim() expects at most 2 arguments, 3 given. Same for ltrim / rtrim.

Verified 2026-08-06 vs php:8.4-cli (8.4.24).

Repro Zend 8.4 VM PROFILE=8.4
trim(" x ", " ", true) ArgumentCountError: … at most 2 arguments, 3 given TypeError: … Argument #3 ($mode) must be of type StringTrimMode, bool given
enum_exists('StringTrimMode') false true (#28202)

Removing the phantom enum (#28202) should naturally restore arity-2 ArgumentCountError; this ticket tracks the call-site observable until that lands (or an explicit arity guard).

php-src reference

PHP implementation target

Repro

./script/docker-exec.sh -- bash -lc 'export PHP_COMPILER_PROFILE=8.4
php -r '"'"'file_put_contents("/tmp/t.php", "<?php\ntry { trim(\" x \", \" \", true); } catch (Throwable \$e) { echo get_class(\$e), \":\", \$e->getMessage(), PHP_EOL; }\necho \"enum=\", enum_exists(\"StringTrimMode\") ? \"1\" : \"0\", PHP_EOL;\n");'"'"'
php bin/vm.php /tmp/t.php'

Done when

Activity

  1. added
    bugSomething isn't working
    phase-4:stdlibPhase 4 – stdlib for web apps
    area:vmVirtual machine
    implementation-readySpec complete: repro, php-src ref, done-when — safe for workers to claim
    on Aug 6, 2026
  2. PurHur commented on Aug 6, 2026

    @PurHur
    OwnerAuthor

    claim: PHP Compiler STD Lib — starting this run

    Bundled with #28202: dropping phantom $mode / StringTrimMode restores Zend ArgumentCountError on 3-arg trim/ltrim/rtrim.

  3. PurHur commented on Aug 8, 2026

    @PurHur
    OwnerAuthor

    unclaim: stale claim (~33h, no open PR, no branch). Returning to implementation-ready for a fresh worker.

    Cleanup bot: claimed together with #28202; neither issue has a PR or leftover head branch. Queue is free again.

  4. PurHur commented on Aug 8, 2026

    @PurHur
    OwnerAuthor

    claim: PHP Compiler STD Lib Advanced — paired with #28202 (same PR)

    Dropping phantom $mode / StringTrimMode restores Zend ArgumentCountError on 3-arg trim family.

  5. PurHur commented on Aug 8, 2026

    @PurHur
    OwnerAuthor

    Merged #28959 (paired with #28202)

    3-arg trim/ltrim/rtrim now raise Zend ArgumentCountError after StringTrimMode retirement.

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 machinebugSomething isn't workingimplementation-readySpec complete: repro, php-src ref, done-when — safe for workers to claimphase-4:stdlibPhase 4 – stdlib for web appsstdlib

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions