Bug #78361 [Opn->Ver]: parse_ini_file converts constants to strings, even with INI_SCANNER_TYPED

From: Date: Thu, 01 Aug 2019 09:55:31 +0000
Subject: Bug #78361 [Opn->Ver]: parse_ini_file converts constants to strings, even with INI_SCANNER_TYPED
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-222041@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=78361&edit=1 ID: 78361 Updated by: cmb@php.net Reported by: mfishe at gmail dot com Summary: parse_ini_file converts constants to strings, even with INI_SCANNER_TYPED -Status: Open +Status: Verified Type: Bug Package: Unknown/Other Function Operating System: Mac, Ubuntu PHP Version: Irrelevant Block user comment: N Private report: N New Comment: See also <https://3v4l.org/DbEYV>. Also DEFINED_BOOLEAN_CONSTANT should be TRUE, not "1". Previous Comments: ------------------------------------------------------------------------ [2019-08-01 09:37:16] mfishe at gmail dot com 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 this bug report at https://bugs.php.net/bug.php?id=78361&edit=1

« previous php.bugs (#222041) next »