Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:79113 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 95556 invoked from network); 24 Nov 2014 00:20:43 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 24 Nov 2014 00:20:43 -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.44 as permitted sender) X-PHP-List-Original-Sender: tjerk.meesters@gmail.com X-Host-Fingerprint: 209.85.220.44 mail-pa0-f44.google.com Received: from [209.85.220.44] ([209.85.220.44:63899] helo=mail-pa0-f44.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 42/51-23429-AD972745 for ; Sun, 23 Nov 2014 19:20:43 -0500 Received: by mail-pa0-f44.google.com with SMTP id et14so8440463pad.17 for ; Sun, 23 Nov 2014 16:20:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=content-type:mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=k7zG/j5walEsradJLjT3qOmXVdp1dWMtx+QRbWO9Vys=; b=iNaGlQxgIzZcwf8NSOUV6KV4rDkpsmO+eoUR1r3cS8AQuYndgsm6h5ayDAjePPX9CQ t47YKKSRM2n/daVP/wk9gB2rwHSyp1pmQp368U14baPro1yp+lYqdeyK7RBWlz9/fwOR Y59Oftqg2fXq6//4CAXuEwPpTt2zYYUZOg7QvKTHcclV7GIleK1Y0zGeY2FVtApT+ba6 xt547onmHo69dB1ssP8wRBoCzbtRHowrgqAzZtGvjs7hC3VOdXv9EPLpppmW9jfIt6kg RWqqMDdasvSxLK0Hwx7CNpBa43T/LNm/rYEdQcJ3FkyIGdIhsfDaU01Tfsj8uwe66oHI 2DUA== X-Received: by 10.68.68.130 with SMTP id w2mr27408779pbt.167.1416788439627; Sun, 23 Nov 2014 16:20:39 -0800 (PST) Received: from tjerks-imac.gateway.2wire.net (bb121-7-198-24.singnet.com.sg. [121.7.198.24]) by mx.google.com with ESMTPSA id xd3sm10645078pbc.54.2014.11.23.16.20.37 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sun, 23 Nov 2014 16:20:38 -0800 (PST) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 8.1 \(1993\)) In-Reply-To: <012701d0074c$ccfe6f40$66fb4dc0$@devtemple.com> Date: Mon, 24 Nov 2014 08:20:35 +0800 Cc: PHP Internals Content-Transfer-Encoding: quoted-printable Message-ID: <65EFC50E-4D50-49ED-AE3B-8C12CB32DC50@gmail.com> References: <012701d0074c$ccfe6f40$66fb4dc0$@devtemple.com> To: Bill Salak X-Mailer: Apple Mail (2.1993) Subject: Re: [PHP-DEV] enhance fget to accept a callback From: tjerk.meesters@gmail.com (Tjerk Meesters) Hi! > On 24 Nov 2014, at 02:39, Bill Salak wrote: >=20 > Hi list, >=20 >=20 >=20 > I'm considering writing an RFC to add a 3rd parameter to fgets which = accepts > a user defined function. If we had this today we wouldn't need fgetcsv = with > the added benefit of fgetcsv style support for data packaging formats = we > would otherwise create more 1 off functions for. For example, if we = decided > to support reading json from files in the same manner as our current = fgetcsv > functionality today, we would create an fgetjson function.=20 >=20 >=20 >=20 > This change unifies the way in which we support native transliteration = of > data packaging formats from files into php data structures through a = single > interface. The other major design benefit, from my point of view, is = the > unification of userland transliteration functions/libraries with the = same > modality as our native support for these types of use cases. I believe = this > will ultimately result in more intuitive userland code around this = type of > functionality. The fgets() function has a few behavioural properties that are hard to = change: 1) it reads until it reaches a newline; 2) it=E2=80=99s expected to return a string. The above two properties prevent it from being a good candidate for = reading other formats, such as CSV or JSON which may: 1) span across multiple lines and 2) almost always return something other than a string. >=20 >=20 >=20 > Before I go any further in formalizing my proposal, I'd like to get = feedback > from list members. >=20 >=20 >=20 > Thanks for your time. >=20 > Bill Salak >=20 >=20 >=20 >=20 >=20