Re: [PHP-DEV] [RFC][VOTE] Deprecate curly brace syntax for accessing array elements and string offsets
Den 2019-07-05 kl. 03:48, skrev Theodore Brown: On Thu, July 4, 2019 at 5:26 PM Björn Larsson wrote: Den 2019-07-03 kl. 17:25, skrev Peter Bowyer: Thanks for taking the time to push forward this RFC. I found the earlier discussion at https://externals.io/message/104744, which I hadn't seen. Like others, I would have chosen to keep {} for string offsets to make it clearer, though I have not used {} in my code for a decade. Was any consideration given to a split vote, voting on the array and string deprecations separately? For others interested, the history of this deprecation going back to 2005 is found at https://externals.io/message/38153 Hi, I have the same question regarding split vote. In my eyes the array case is a no-brainer, but for string access maybe not... Good question. I did consider whether it would make sense to only deprecate curly brace offset access for arrays and not strings. The problem with this is that it wouldn't solve the issue of confusion outlined in the RFC. Unless the bracket syntax for string offset access was also deprecated, users would still be left to question whether the curly brace syntax behaves differently in certain circumstances, if one alternative performs better than the other, if there is a scoping related difference, or when the curly brace syntax should be used instead of the normal bracket syntax for string offset access. Would it be possible to compare the string access only for both curly & straight braces and the same for array access? I updated my script to list all the unique variable names referenced in the output of Nikita's analysis of the top 2k Composer packages: https://gist.github.com/theodorejb/ba35fc8f72df8823e07c5f3b51870e00. The most frequent variable name is `$string`, and from numerous other variable names it does seem that the majority of curly brace usages are on strings (other frequent variable names include `$code`, `$Bytestring`, `$chrs`, `$text`, `$str`, `$numberstring`, and many similar examples). I also dug into the repositories for a bunch of the packages, and most of the curly braces uses appear to be in older code without any type declarations (which may explain why so many variable names include a type). Best regards, Theodore Hi, Thanks for the clarification. My concern regarding the vote is that string curly braces is swept along the vote for array curly braces, since the last one is so obvious to deprecate. So separate votes would make it clearer. One could add that keeping string curly braces could help removing confusion when reading code ;-) For instance is $var[7] an array or string access. Having string curly braces gives the programmer one more tool to improve readability. r//Björn L -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] [RFC][VOTE] Deprecate curly brace syntax for accessing array elements and string offsets
> > > Thanks for taking the time to push forward this RFC. > > > > > > I found the earlier discussion at https://externals.io/message/104744, > > > which I hadn't seen. Like others, I would have chosen to keep {} for > > > string offsets to make it clearer, though I have not used {} in my > > > code for a decade. Was any consideration given to a split vote, > > > voting on the array and string deprecations separately? > > > > > > For others interested, the history of this deprecation going back to > > > 2005 is found at https://externals.io/message/38153 > > > > I have the same question regarding split vote. In my eyes the > > array case is a no-brainer, but for string access maybe not... > > Good question. I did consider whether it would make sense to only > deprecate curly brace offset access for arrays and not strings. The > problem with this is that it wouldn't solve the issue of confusion > outlined in the RFC. Syntax (and depreciation) checks on compile time.It's make impossible to separate arrays and strings because of PHP nature. > > Would it be possible to compare the string access only for both > > curly & straight braces and the same for array access? > I updated my script to list all the unique variable names referenced > in the output of Nikita's analysis of the top 2k Composer packages:> https://gist.github.com/theodorejb/ba35fc8f72df8823e07c5f3b51870e00. > The most frequent variable name is `$string`, and from numerous other > variable names it does seem that the majority of curly brace usages > are on strings (other frequent variable names include `$code`, > `$Bytestring`, `$chrs`, `$text`, `$str`, `$numberstring`, and many > similar examples). I also dug into the repositories for a bunch of > the packages, and most of the curly braces uses appear to be in older > code without any type declarations (which may explain why so many > variable names include a type). Also:'phpoffice/phpexcel' => 219, abandoned 'tecnick.com/tcpdf' => 74, abandoned 'yiisoft/yii' => 64, deprecated, only security fixes'zendframework/zendframework1' => 37, abandoned'dflydev/markdown' => 22, abandoned 'picqer/php-barcode-generator' => 63, inherits code from 'tecnickcom/tcpdf' 'milon/barcode' => 89, inherits code from 'tecnickcom/tcpdf''lukasreschke/id3parser' => 78, inherits code from 'james-heinrich/getid3'etc. Inherited code in general means that it is not author decision but only copy paste.
Re: [PHP-DEV] [RFC][VOTE] Deprecate curly brace syntax for accessing array elements and string offsets
On Thu, July 4, 2019 at 5:26 PM Björn Larsson wrote: > Den 2019-07-03 kl. 17:25, skrev Peter Bowyer: > > > Thanks for taking the time to push forward this RFC. > > > > I found the earlier discussion at https://externals.io/message/104744, > > which I hadn't seen. Like others, I would have chosen to keep {} for > > string offsets to make it clearer, though I have not used {} in my > > code for a decade. Was any consideration given to a split vote, > > voting on the array and string deprecations separately? > > > > For others interested, the history of this deprecation going back to > > 2005 is found at https://externals.io/message/38153 > > Hi, > > I have the same question regarding split vote. In my eyes the > array case is a no-brainer, but for string access maybe not... Good question. I did consider whether it would make sense to only deprecate curly brace offset access for arrays and not strings. The problem with this is that it wouldn't solve the issue of confusion outlined in the RFC. Unless the bracket syntax for string offset access was also deprecated, users would still be left to question whether the curly brace syntax behaves differently in certain circumstances, if one alternative performs better than the other, if there is a scoping related difference, or when the curly brace syntax should be used instead of the normal bracket syntax for string offset access. > Would it be possible to compare the string access only for both > curly & straight braces and the same for array access? I updated my script to list all the unique variable names referenced in the output of Nikita's analysis of the top 2k Composer packages: https://gist.github.com/theodorejb/ba35fc8f72df8823e07c5f3b51870e00. The most frequent variable name is `$string`, and from numerous other variable names it does seem that the majority of curly brace usages are on strings (other frequent variable names include `$code`, `$Bytestring`, `$chrs`, `$text`, `$str`, `$numberstring`, and many similar examples). I also dug into the repositories for a bunch of the packages, and most of the curly braces uses appear to be in older code without any type declarations (which may explain why so many variable names include a type). Best regards, Theodore -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] [RFC][VOTE] Deprecate curly brace syntax for accessing array elements and string offsets
Den 2019-07-03 kl. 17:25, skrev Peter Bowyer: Hi Andrey, Thanks for taking the time to push forward this RFC. I found the earlier discussion at https://externals.io/message/104744, which I hadn't seen. Like others, I would have chosen to keep {} for string offsets to make it clearer, though I have not used {} in my code for a decade. Was any consideration given to a split vote, voting on the array and string deprecations separately? For others interested, the history of this deprecation going back to 2005 is found at https://externals.io/message/38153 Peter Hi, I have the same question regarding split vote. In my eyes the array case is a no-brainer, but for string access maybe not... r//Björn L -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] [RFC][VOTE] Deprecate curly brace syntax for accessing array elements and string offsets
Den 2019-07-03 kl. 19:22, skrev Claude Pache: Le 3 juil. 2019 à 17:59, Nikita Popov a écrit : On Wed, Jul 3, 2019 at 4:41 PM Levi Morrison wrote: Was any analysis of usage done for top open source projects? I support this direction, but would prefer to know its current impact before voting. I checked top 2k projects with a 2-3 months outdated data set. Here is the analysis log: https://gist.github.com/nikic/b5f811e0423bf051f4492cd6e0c0273e Overall there were ~2.2k individual uses of alternative array syntax. To put that into context, there 888.3k total array accesses in the data set, which puts usage at about 0.25%. Uses are usually clustered, i.e. if alternative array syntax is used in a file, it will be used many times. Nikita It ought to be noted that the alternative syntax is used essentially for strings, not for arrays proper. In fact, I expect that it is used almost exclusively for strings. That means, most probably: ~2.2k uses of alternative syntax for direct byte access in strings among 888.3k for byte access in strings AND direct element access in arrays. —Claude Hi, Would it be possible to compare the string access only for both curly & straight braces and the same for array access? r//Björn L -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] [RFC][VOTE] Deprecate curly brace syntax for accessing array elements and string offsets
On Wed, July 3, 2019 at 10:59 AM Nikita Popov wrote: > On Wed, Jul 3, 2019 at 4:41 PM Levi Morrison wrote: > > > Was any analysis of usage done for top open source projects? I support > > this direction, but would prefer to know its current impact before > > voting. > > > I checked top 2k projects with a 2-3 months outdated data set. Here is the > analysis log: > https://gist.github.com/nikic/b5f811e0423bf051f4492cd6e0c0273e > > Overall there were ~2.2k individual uses of alternative array syntax. To > put that into context, there 888.3k total array accesses in the data set, > which puts usage at about 0.25%. Uses are usually clustered, i.e. if > alternative array syntax is used in a file, it will be used many times. I did some additional analysis on the output of Nikita's script. The number of curly brace usages is inflated somewhat due to duplicate packages. For example, tecnick.com/tcpdf and tecnickcom/tcpdf both have 74 usages, and are the same project which was renamed. Likewise, johnpbloch/wordpress-core and roots/wordpress each have 182 usages, and they are both mirrors of the WordPress core codebase. Another example is magento/zendframework1 which was forked from zendframework/zendframework1 (almost half the curly brace usages have been removed in the magento fork). 53 out of 89 total packages using the curly brace syntax use it 4 or fewer times. 92% of the usages in are in just 25 unique projects. You can view my script and its output here: https://gist.github.com/theodorejb/ba35fc8f72df8823e07c5f3b51870e00 Best regards, Theodore -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] [RFC][VOTE] Deprecate curly brace syntax for accessing array elements and string offsets
> Le 3 juil. 2019 à 17:59, Nikita Popov a écrit : > > On Wed, Jul 3, 2019 at 4:41 PM Levi Morrison wrote: > >> Was any analysis of usage done for top open source projects? I support >> this direction, but would prefer to know its current impact before >> voting. >> > > I checked top 2k projects with a 2-3 months outdated data set. Here is the > analysis log: https://gist.github.com/nikic/b5f811e0423bf051f4492cd6e0c0273e > > Overall there were ~2.2k individual uses of alternative array syntax. To > put that into context, there 888.3k total array accesses in the data set, > which puts usage at about 0.25%. Uses are usually clustered, i.e. if > alternative array syntax is used in a file, it will be used many times. > > Nikita It ought to be noted that the alternative syntax is used essentially for strings, not for arrays proper. In fact, I expect that it is used almost exclusively for strings. That means, most probably: ~2.2k uses of alternative syntax for direct byte access in strings among 888.3k for byte access in strings AND direct element access in arrays. —Claude -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] [RFC][VOTE] Deprecate curly brace syntax for accessing array elements and string offsets
On 7/3/2019 7:41 AM, Levi Morrison wrote: Was any analysis of usage done for top open source projects? I support this direction, but would prefer to know its current impact before voting. Well, I currently use braces when I iterate over strings for reasons of readability. Example: https://github.com/cubiclesoft/ultimate-web-scraper/blob/master/support/tag_filter.php If deprecated, at least the linter will pick up the problem areas and flood log files. -- Thomas Hruska CubicleSoft President I've got great, time saving software that you will find useful. http://cubiclesoft.com/ And once you find my software useful: http://cubiclesoft.com/donate/ -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] [RFC][VOTE] Deprecate curly brace syntax for accessing array elements and string offsets
On Wed, Jul 3, 2019 at 4:41 PM Levi Morrison wrote: > Was any analysis of usage done for top open source projects? I support > this direction, but would prefer to know its current impact before > voting. > I checked top 2k projects with a 2-3 months outdated data set. Here is the analysis log: https://gist.github.com/nikic/b5f811e0423bf051f4492cd6e0c0273e Overall there were ~2.2k individual uses of alternative array syntax. To put that into context, there 888.3k total array accesses in the data set, which puts usage at about 0.25%. Uses are usually clustered, i.e. if alternative array syntax is used in a file, it will be used many times. Nikita
Re: [PHP-DEV] [RFC][VOTE] Deprecate curly brace syntax for accessing array elements and string offsets
Hi Andrey, Thanks for taking the time to push forward this RFC. I found the earlier discussion at https://externals.io/message/104744, which I hadn't seen. Like others, I would have chosen to keep {} for string offsets to make it clearer, though I have not used {} in my code for a decade. Was any consideration given to a split vote, voting on the array and string deprecations separately? For others interested, the history of this deprecation going back to 2005 is found at https://externals.io/message/38153 Peter
Re: [PHP-DEV] [RFC][VOTE] Deprecate curly brace syntax for accessing array elements and string offsets
Was any analysis of usage done for top open source projects? I support this direction, but would prefer to know its current impact before voting. -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] [RFC][VOTE] Deprecate curly brace syntax for accessing array elements and string offsets
On 7/3/2019 3:18 AM, Andrew Gromov wrote: Hello Internals, I just started the vote on https://wiki.php.net/rfc/deprecate_curly_braces_array_accessand I will close it in two weeks from now (10.06.2019). Thanks in advance to all who paid attention to the vote. Best regards, Andrey. The URL, as shown, doesn't go anywhere. Looks like it should be this: https://wiki.php.net/rfc/deprecate_curly_braces_array_access -- Thomas Hruska CubicleSoft President I've got great, time saving software that you will find useful. http://cubiclesoft.com/ And once you find my software useful: http://cubiclesoft.com/donate/ -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] [RFC][VOTE] Deprecate curly brace syntax for accessing array elements and string offsets
On Wed, 3 Jul 2019 at 12:18, Andrew Gromov wrote: > Hello Internals, > > > I just started the vote on > https://wiki.php.net/rfc/deprecate_curly_braces_array_accessand I will > close it in two weeks from now (10.06.2019). > > Thanks in advance to all who paid attention to the vote. > > Best regards, Andrey. > Two weeks from now would be 17/07/2019. Also the voting period on the RFC lists June (06) as the start and end month for voting instead of July (07) George P. Banyard