Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:76970 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 35368 invoked from network); 30 Aug 2014 14:36:33 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 30 Aug 2014 14:36:33 -0000 Authentication-Results: pb1.pair.com header.from=tjerk.meesters@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=tjerk.meesters@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.220.51 as permitted sender) X-PHP-List-Original-Sender: tjerk.meesters@gmail.com X-Host-Fingerprint: 209.85.220.51 mail-pa0-f51.google.com Received: from [209.85.220.51] ([209.85.220.51:50713] helo=mail-pa0-f51.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id C4/01-28092-071E1045 for ; Sat, 30 Aug 2014 10:36:32 -0400 Received: by mail-pa0-f51.google.com with SMTP id rd3so8646304pab.38 for ; Sat, 30 Aug 2014 07:36:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:content-type:content-transfer-encoding:subject:message-id:date :to:mime-version; bh=cC8L83yj1KlXO8pmzi2VdXWhqz7ToC6faVAPAWFKyhM=; b=ygdlA+GpWPdtZ0P2npM5YbZp/iJdhvCwCO8Szl0+WvRFJB+OA76YZXQpvIQq3EnmTL 8r0Zk8UGhwvNU9dGrZ8DOoFMLs8MsT8y0JUwr/ssFpp4BaBp2VjuKr5PryaPNCcYQLSI iMEuEtmDNW0mbH9HzrnUlKs2Y1RHiRFimCBNF5+XzwO//QATmwSpzm6e3iuH7Vg65PgJ 3roN3i3OuTmov386vt/EZQAJEjo4W3ZWwmh63RLlTRDFeZk0mAeTJAnFs91tD5qkJKBG m/82SDKx0X6HxWEESm/iKVmH9HnjfBgRa+MEJJ8+oHwho7U+bkOcdFU6ZAdbLnl+nJl3 B2hg== X-Received: by 10.70.103.79 with SMTP id fu15mr21911079pdb.126.1409409389426; Sat, 30 Aug 2014 07:36:29 -0700 (PDT) Received: from [172.18.12.226] (li747-134.members.linode.com. [106.185.38.134]) by mx.google.com with ESMTPSA id dn5sm3039598pbb.2.2014.08.30.07.36.27 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sat, 30 Aug 2014 07:36:28 -0700 (PDT) Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: quoted-printable Message-ID: <2BBB5D80-5594-4F53-B507-4AD3BB03AE0A@gmail.com> Date: Sat, 30 Aug 2014 22:36:23 +0800 To: PHP Internals Mime-Version: 1.0 (Mac OS X Mail 7.3 \(1878.6\)) X-Mailer: Apple Mail (2.1878.6) Subject: Making parse_ini_*() aware of types From: tjerk.meesters@gmail.com (Tjerk Meesters) Hi internals, I was going through the bug list and found this report: https://bugs.php.net/bug.php?id=3D38409 It discusses the fact that `parse_ini_file()` and `parse_ini_string()` = throw away type information; for instance, the flag =93on=94 doesn=92t = translate into a bool(true) but string(=931=94). 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=92ve found a way in = which this can be solved with a separate scanner mode; e.g.: $data =3D parse_ini_file(=91/path/to/file=92, 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-scan= ner-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=92t benchmarked it, but the impact on = performance should be quite minimal. Thoughts?=