[RFC] Improve array to string conversion

php.internals

F & N Laupretre

11 years ago
Hi, A new RFC for PHP7 : https://wiki.php.net/rfc/array-to-string Not implemented yet, but the PR is available for comments : https://github.com/php/php-src/pull/991 Regards François

Stelian Mocanita

11 years ago
I would vote for the first option and entirely deprecate the array to string conversion. As far as I can see there is no real world use-case for it and most of the time it does more harm than good. Stelian On Sun, Jan 11, 2015 at 2:29 PM, F & N Laupretre <nf.laupretre@yahoo.fr> wrote:

Derick Rethans

11 years ago
On Sun, 11 Jan 2015, F & N Laupretre wrote:
> Hi, > > A new RFC for PHP7 : https://wiki.php.net/rfc/array-to-string
The voting options are missing in there. They should (probably) be: - don't change - 1st alternative - 2nd alternative cheers, Derick

F & N Laupretre

11 years ago
Fixed. Thanks

Patrick ALLAERT

11 years ago
Le Sun Jan 11 2015 at 14:30:42, F & N Laupretre <nf.laupretre@yahoo.fr> a écrit :
> Hi, > > A new RFC for PHP7 : https://wiki.php.net/rfc/array-to-string > > Not implemented yet, but the PR is available for comments : > https://github.com/php/php-src/pull/991 > > Regards > > François >
Just for the record, when I implemented the E_NOTICE on that conversion I received lot of complaints of users using (incorrectly) the array_diff() family which internally compare all sub-elements given their "string" representation. It means that if you present something for "option 3" you also have to think about the way those functions will behave (and the possible BC introduced. Note the exact same behavior with multi dimensional arrays containing same / different content: // Same sub-array php > var_dump( array_diff( [['a']], [['a']] ) ); PHP Notice: Array to string conversion in php shell code on line 1 array(0) { } // Different sub-array php > var_dump( array_diff( [['a']], [['42']] ) ); PHP Notice: Array to string conversion in php shell code on line 1 array(0) { } My 0.02€. Patrick