Skip to content

Stdlib: json_encode() flags: named parameter rejected — compile error not JSON output (ext/json/php_json.c) #9646

Description

@PurHur

Category

stdlib · php-src-strict

Problem

json_encode($value, flags: JSON_FORCE_OBJECT) fails at compile/runtime with Too many arguments to function call. Positional json_encode($value, JSON_FORCE_OBJECT) works. Zend accepts the named flags: parameter.

php-src reference

Repro

test/repro/maintainer_gap_json_encode_flags_named.php:

<?php
var_export(json_encode(['a' => 1], flags: JSON_FORCE_OBJECT));
./script/docker-exec.sh -- bash -lc 'source script/php-env.sh
php test/repro/maintainer_gap_json_encode_flags_named.php
php bin/vm.php test/repro/maintainer_gap_json_encode_flags_named.php'

Zend: '{"a":1}'
VM: Too many arguments to function call

Implementation hints (PHP-in-PHP)

Done when (php-src-strict)

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 appsstdlib

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions