Re: [RFC][DISCUSSION] Change var_export() array syntax to use short hand arrays

From: Date: Mon, 30 Mar 2020 17:37:51 +0000
Subject: Re: [RFC][DISCUSSION] Change var_export() array syntax to use short hand arrays
References: 1 2 3 4 5 6 7  Groups: php.internals 
Request: Send a blank email to internals+get-109466@lists.php.net to get a copy of this message
On Mon, Mar 30, 2020 at 1:32 PM Sara Golemon <pollita@php.net> wrote: > On Mon, Mar 30, 2020 at 11:39 AM Benjamin Morel <benjamin.morel@gmail.com> > wrote: > > > If "they" don't care about syntax, then why do you? > > > > > > Sorry I was unclear. I was reacting to the argument about broken tests in > > php-src. > > I meant: they don't have *expectations* about the syntax, but they'll > most > > likely want to be able to read it. > > > > And we circle back to the current syntax being perfectly readable. We > could keep this up all quarantine... > > In a more practical example, > https://github.com/php/web-php/blob/master/include/releases.inc > is an > example of a var_export() generated file that lives in the wild and is > regularly updated. > > I would say it's fairly readable, HOWEVER I WOULD AGREE WITH YOU that it > would be MORE readable using short array syntax and skipping the index > numbers. In fact, I had exactly this thought nearly 3 years ago when I > started touching this file regularly. (plus the fact that the structure of > this array is kinda gross). > > You'll note though, that I'm not championing making this file more > reasonable. Because it doesn't matter. Because accidental damage to > existing code isn't worth a minor bit of aesthetics by a file which is > primarily read by machines. If it really mattered to me in any meaningful > way, I'd write the dozen or so lines of script needed to output in a > "pretty" way. Or I'd go google and find brick/varexporter. > > Lastly, there are at least six RMs at any given moment working on PHP's > release. Can you imagine if we were updating this file using different > versions? The git churn would be horrific. Do not want. If we really > wanted "pretty var_export", then there'd be no real choice BUT to use a > library script to do the serializing. > > -Sara > I'm with Sara on this, which shouldn't be a big surprise. Just out of curiosity, is there any reason we couldn't add an optional parameter called "$short_array" or whatever that defaults to false? Then there shouldn't be any backwards compatibility issues. -- Chase Peeler chasepeeler@gmail.com

« previous php.internals (#109466) next »