Re: enhance fget to accept a callback

From: Date: Mon, 24 Nov 2014 00:20:35 +0000
Subject: Re: enhance fget to accept a callback
References: 1  Groups: php.internals 
Request: Send a blank email to internals+get-79113@lists.php.net to get a copy of this message
Hi! > On 24 Nov 2014, at 02:39, Bill Salak <bill@devtemple.com> wrote: > > Hi list, > > > > 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. > > > > 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’s 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. > > > > Before I go any further in formalizing my proposal, I'd like to get feedback > from list members. > > > > Thanks for your time. > > Bill Salak > > > > >

« previous php.internals (#79113) next »