Skip to content

Stdlib: parse_ini_string()/parse_ini_file() — INI_SCANNER_RAW and INI_SCANNER_TYPED parity (ext/standard/ini.c) #9153

Closed

Description

@PurHur

Summary

parse_ini_string($ini, false, INI_SCANNER_TYPED) silently returns string values ('42', '3.14', '1') instead of typed int/float/bool. INI_SCANNER_RAW is also accepted but behaves like INI_SCANNER_NORMAL.

ParseIniEngine documents RAW/TYPED as deferred (#3263 closed with NORMAL-only v1); callers get wrong types without error — php-src-strict mismatch.

Repro

./script/docker-exec.sh -- bash -lc 'source script/php-env.sh && php bin/vm.php test/repro/maintainer_probe_parse_ini_typed.php'

Zend:

array (
  'n' => 42,
  'f' => 3.14,
  'b' => true,
)

This compiler (bin/vm.php):

array (
  'n' => '42',
  'f' => '3.14',
  'b' => '1',
)

php-src reference

  • ext/standard/basic_functions.c — PHP_FUNCTION(parse_ini_string)
  • ext/standard/ini.c — zend_ini_scanner() modes INI_SCANNER_NORMAL, INI_SCANNER_RAW, INI_SCANNER_TYPED

Implementation (PHP-in-PHP)

  • ext/standard/ParseIniEngine.php — implement RAW (no quote stripping) and TYPED (bool/int/float/null coercion per php-src ini_scanner).
  • ext/standard/VmParseIni.php — pass scanner mode through; surface ValueError/Warning for invalid mode like Zend.
  • Share logic with parse_ini_file() path.

Done when (php-src-strict)

  • php bin/vm.php test/repro/maintainer_probe_parse_ini_typed.php matches Zend typed output.
  • RAW mode repro: quoted values preserved without normalization.
  • Compliance guards under test/compliance/.
  • No new C in runtime/ — keep parser in ext/standard/.

Related

Closed #3263 (NORMAL v1); this issue tracks RAW/TYPED phase 2.

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 17, 2026
  2. PurHur commented on Jul 4, 2026

    @PurHur
    OwnerAuthor

    claim: worker-lane-a — starting this run

  3. PurHur commented on Jul 4, 2026

    @PurHur
    OwnerAuthor

    Merged via #15880.

    Fix: ParseIniEngine now applies scanner-mode post-processing — RAW keeps unquoted RHS literal, TYPED coerces int/float/bool/null; invalid mode warns and returns false.

    Verification:

    ./script/docker-exec.sh -- bash -lc 'source script/php-env.sh
    php bin/vm.php test/repro/maintainer_probe_parse_ini_typed.php
    vendor/bin/phpunit test/compliance/ParseIniBoolKeywordVMTest.php'

    Repro prints ok; PHPUnit OK (2 tests).

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