Bug #78361 [NEW]: parse_ini_file converts constants to strings, even with INI_SCANNER_TYPED

From: Date: Thu, 01 Aug 2019 09:37:16 +0000
Subject: Bug #78361 [NEW]: parse_ini_file converts constants to strings, even with INI_SCANNER_TYPED
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-222040@lists.php.net to get a copy of this message
From: mfishe at gmail dot com Operating system: Mac, Ubuntu PHP version: Irrelevant Package: Unknown/Other Function Bug Type: Bug Bug description:parse_ini_file converts constants to strings, even with INI_SCANNER_TYPED Description: ------------ With the following .ini file ... ---------- NUMBER = 1 TEXT = "1" DEFINED_INTEGER_CONSTANT = FOO DEFINED_BOOLEAN_CONSTANT = BAR UNDEFINED_CONSTANT = BAZ ---------- I have tested this behaviour in 7.1.26, 7.3.1 and 7.3.7. Test script: --------------- <?php declare(strict_types=1); define("FOO", 123); define("BAR", true); $ini_file = parse_ini_file(__DIR__ . '/test.ini', false, INI_SCANNER_TYPED); foreach($ini_file as $key => $value) { define($key, $value); } var_dump(NUMBER); // => int(1) var_dump(TEXT); // => string(1) "1" var_dump(DEFINED_INTEGER_CONSTANT); // => string(3) "123" var_dump(DEFINED_BOOLEAN_CONSTANT); // => "1" var_dump(UNDEFINED_CONSTANT); // => "BAZ" Expected result: ---------------- I expect the third var_dump to output an integer (123) due to the use of INI_SCANNER_TYPED. Actual result: -------------- The third var_dump outputs a string ("123"). -- Edit bug report at https://bugs.php.net/bug.php?id=78361&edit=1 -- Fix committed: https://bugs.php.net/fix.php?id=78361&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=78361&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=78361&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=78361&r=needscript Try newer version: https://bugs.php.net/fix.php?id=78361&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=78361&r=support Expected behavior: https://bugs.php.net/fix.php?id=78361&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=78361&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=78361&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=78361&r=globals PHP version support discontinued: https://bugs.php.net/fix.php?id=78361&r=phptooold Daylight Savings: https://bugs.php.net/fix.php?id=78361&r=dst IIS Stability: https://bugs.php.net/fix.php?id=78361&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=78361&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=78361&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=78361&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=78361&r=mysqlcfg

« previous php.bugs (#222040) next »