Skip to content

Stdlib: http_build_query() — enum case values must encode like Zend objects not backing scalars (ext/standard/http.c) #8733

Description

@PurHur

Category

stdlib · php-src-strict

Problem

When http_build_query() encounters an enum case value, Zend encodes it using object/enum rules (for backed enums: name + value keys in nested form). This compiler coerces to the backing scalar (x=1 vs Zend x%5Bname%5D=A&x%5Bvalue%5D=1).

php-src reference

Repro

<?php
enum E: int { case A = 1; }
var_export(http_build_query(['x' => E::A]));
echo "\n";
./script/docker-exec.sh -- bash -lc 'source script/php-env.sh
php -r "enum E: int { case A=1; } var_export(http_build_query([\"x\"=>E::A])); echo \"\\n\";"
php bin/vm.php -r "enum E: int { case A=1; } var_export(http_build_query([\"x\"=>E::A])); echo \"\\n\";"'
Engine Output
Zend PHP 8.3+ 'x%5Bname%5D=A&x%5Bvalue%5D=1' (exact encoding may vary by arg separator)
This compiler VM (today) 'x=1'

Scope (this repo)

  • ext/standard/VmHttpBuildQuery.php — enum case branch in query builder
  • lib/JIT/Builtin/*HttpBuildQuery* if JIT lowered
  • test/compliance/cases/stdlib/http_build_query_enum.phpt

Done when

  • Repro output matches Zend byte-for-byte (or documented equivalent with default args)
  • ./script/ci-fast.sh --filter http_build_query_enum green

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