Re: [PHP-DEV] Making parse_ini_*() aware of types

[email protected] (Paul Dragoonis)
Newsgroups php.internals
Message-ID <CAKxcST-A34_aNS_AOEGXp_Vp=jJmtNf+R2S5=uSZnOQYbpumLA@mail.gmail.com>
Seems like a no brainer and since its gone through voting then you could go
ahead with it.
On 30 Aug 2014 15:37, "Tjerk Meesters" <[email protected]> wrote:

> Hi internals,
>
> I was going through the bug list and found this report:
>
> https://bugs.php.net/bug.php?id=38409
>
> It discusses the fact that `parse_ini_file()` and `parse_ini_string()`
> throw away type information; for instance, the flag “on” doesn’t translate
> into a bool(true) but string(“1”).
>
> The report has had 21 votes and an average score of 4.3 +- 0.7, so it
> seems to have some traction with users.
>
>
> Simply changing this behaviour would cause BC, so I’ve found a way in
> which this can be solved with a separate scanner mode; e.g.:
>
> $data = parse_ini_file(‘/path/to/file’, true, INI_SCANNER_TYPED);
>
> A patch for the lexer can be found here, together with a simple test case:
>
>
> https://github.com/datibbaw/php-src/compare/php:master...datibbaw:ini-scanner-plus
>
> It currently distinguishes between booleans, numbers and NULL (it was
> mentioned in the ticket by someone else, not entirely sure of its
> usefulness, though). I haven’t benchmarked it, but the impact on
> performance should be quite minimal.
>
> Thoughts?
> --
> PHP Internals - PHP Runtime Development Mailing List
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.