Skip to content

Stdlib: number_format() dec_point: named parameter — unknown name must Error not silently use defaults (ext/standard/number_format.c) #10132

Closed

Description

@PurHur

Category

stdlib · php-src-strict

Problem

number_format() accepts the wrong named parameter dec_point: (php-src stub uses decimal_separator:). Zend throws Error: Unknown named parameter $dec_point. This compiler binds by position/slot and formats with default separators, masking caller bugs.

php-src reference

Repro (failure today)

test/repro/issue_number_format_dec_point_named.php:

<?php
echo number_format(1234.5, 2, dec_point: ',', thousands_sep: '.'), "\n";
./script/docker-exec.sh -- bash -lc 'source script/php-env.sh
php8.2 test/repro/issue_number_format_dec_point_named.php
php bin/vm.php test/repro/issue_number_format_dec_point_named.php
'
Runtime Result
Zend PHP 8.0+ Fatal Error: Unknown named parameter $dec_point
VM today 1.234,50 (wrong — dec_point ignored, defaults used)

Positive control (after fix):

echo number_format(1234.5, 2, decimal_separator: ',', thousands_separator: '.'), "\n";
// both engines: 1.234,50

Scope (PHP-in-PHP)

Path Work
ext/standard/number_format.php register stub parameter names for named-arg validation
lib/Compiler.php / call lowering reject unknown named parameters at compile (preferred) or runtime
Tests test/compliance/cases/stdlib/number_format_named_params.phpt

Done when (php-src-strict)

  • Repro fatals with Unknown named parameter $dec_point on VM
  • decimal_separator: / thousands_separator: named calls match Zend output
  • Positional 4-arg form unchanged
  • ./script/ci-fast.sh --filter number_format_named green

Related

Activity

  1. added
    enhancementNew feature or request
    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 Jun 19, 2026
  2. PurHur commented on Jun 19, 2026

    @PurHur
    OwnerAuthor

    claim: PHP Compiler STD Lib — starting this run

  3. PurHur commented on Jun 19, 2026

    @PurHur
    OwnerAuthor

    Merged via #10138.

    Fix: Removed incorrect dec_point / thousands_sep named-parameter aliases from BuiltinParamNames::aliasesForFunction(). Wrong names now throw Error: Unknown named parameter $dec_point matching Zend; canonical decimal_separator: / thousands_separator: unchanged.

    Verification:

    • VM repro: php bin/vm.php test/repro/issue_number_format_dec_point_named.php → Fatal Error (matches php8.2)
    • Positive: php bin/vm.php test/repro/issue_number_format_named.php → '1.23' / '1 235'
    • vendor/bin/phpunit --filter number_format_dec_point_named → OK (4)
    • php bin/compile.php -l on both repros → exit 0
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:compilerCompiler / CFG / JITarea: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