Re: [PHP-DEV] [RFC] token_get_all() TOKEN_AS_OBJECT mode

2020-02-25 Thread Michał Brzuchalski
czw., 13 lut 2020 o 10:48 Nikita Popov napisał(a): > Hi internals, > > This has been discussed a while ago already, now as a proper proposal: > https://wiki.php.net/rfc/token_as_object > > tl;dr is that it allows you to get token_get_all() output as an array of > PhpToken objects. This reduces me

Re: [PHP-DEV] Re: [RFC] token_get_all() TOKEN_AS_OBJECT mode

2020-02-25 Thread Nikita Popov
On Tue, Feb 25, 2020 at 5:59 PM Larry Garfield wrote: > On Tue, Feb 25, 2020, at 9:59 AM, Nikita Popov wrote: > > On Thu, Feb 13, 2020 at 10:47 AM Nikita Popov > wrote: > > > > > Hi internals, > > > > > > This has been discussed a while ago already, now as a proper proposal: > > > https://wiki.p

Re: [PHP-DEV] Re: [RFC] token_get_all() TOKEN_AS_OBJECT mode

2020-02-25 Thread Nikita Popov
On Tue, Feb 25, 2020 at 7:16 PM Theodore Brown wrote: > On Tue, Feb 25, 2020 at 9:59 AM Nikita Popov wrote: > > > On Thu, Feb 13, 2020 at 10:47 AM Nikita Popov > wrote: > > > > > This has been discussed a while ago already, now as a proper proposal: > > > https://wiki.php.net/rfc/token_as_objec

Re: [PHP-DEV] Thoughts on adopting Python's for/foreach else construct.

2020-02-25 Thread Nikita Popov
On Tue, Feb 25, 2020 at 8:19 PM Michael Morris wrote: > I don't remember if this has been discussed before, but I've been working > with some listing code and wishing for a cleaner way to do this > >if (count($a) === 0) { > // code for no results > } > else { > foreach( $a as $key

Re: [PHP-DEV] Deprecate ReflectionParameter::isArray() and friends

2020-02-25 Thread Nikita Popov
On Tue, Feb 25, 2020 at 8:12 PM Bishop Bettini wrote: > On Tue, Feb 25, 2020 at 10:33 AM Nikita Popov > wrote: > >> I've put up https://github.com/php/php-src/pull/5209 to deprecate the >> following reflection methods: >> >> * ReflectionParameter::isArray() >> * ReflectionParameter::isCallable

Re: [PHP-DEV] Thoughts on adopting Python's for/foreach else construct.

2020-02-25 Thread Christian Schneider
Am 25.02.2020 um 20:18 schrieb Michael Morris : > How difficult would it be to make the following work in the interpreter? > > foreach($a as $key => $value) { >// code for iteration > } > else { >// code for no results > } > ?> > > The code of the else clause executes if the foreach

[PHP-DEV] Thoughts on adopting Python's for/foreach else construct.

2020-02-25 Thread Michael Morris
I don't remember if this has been discussed before, but I've been working with some listing code and wishing for a cleaner way to do this $value) { // code for iteration } } ?> How difficult would it be to make the following work in the interpreter? $value) { // code for iterat

Re: [PHP-DEV] Deprecate ReflectionParameter::isArray() and friends

2020-02-25 Thread Bishop Bettini
On Tue, Feb 25, 2020 at 10:33 AM Nikita Popov wrote: > I've put up https://github.com/php/php-src/pull/5209 to deprecate the > following reflection methods: > > * ReflectionParameter::isArray() > * ReflectionParameter::isCallable() > * ReflectionParameter::getClass() > > These APIs have been s

Re: [PHP-DEV] Re: [RFC] token_get_all() TOKEN_AS_OBJECT mode

2020-02-25 Thread Theodore Brown
On Tue, Feb 25, 2020 at 9:59 AM Nikita Popov wrote: > On Thu, Feb 13, 2020 at 10:47 AM Nikita Popov wrote: > > > This has been discussed a while ago already, now as a proper proposal: > > https://wiki.php.net/rfc/token_as_object > > > > An open question is whether (at least to start with) PhpTok

Re: [PHP-DEV] Re: [RFC] token_get_all() TOKEN_AS_OBJECT mode

2020-02-25 Thread Larry Garfield
On Tue, Feb 25, 2020, at 9:59 AM, Nikita Popov wrote: > On Thu, Feb 13, 2020 at 10:47 AM Nikita Popov wrote: > > > Hi internals, > > > > This has been discussed a while ago already, now as a proper proposal: > > https://wiki.php.net/rfc/token_as_object > > > > tl;dr is that it allows you to get t

[PHP-DEV] Re: [RFC] token_get_all() TOKEN_AS_OBJECT mode

2020-02-25 Thread Nikita Popov
On Thu, Feb 13, 2020 at 10:47 AM Nikita Popov wrote: > Hi internals, > > This has been discussed a while ago already, now as a proper proposal: > https://wiki.php.net/rfc/token_as_object > > tl;dr is that it allows you to get token_get_all() output as an array of > PhpToken objects. This reduces

[PHP-DEV] Deprecate ReflectionParameter::isArray() and friends

2020-02-25 Thread Nikita Popov
Hi internals, I've put up https://github.com/php/php-src/pull/5209 to deprecate the following reflection methods: * ReflectionParameter::isArray() * ReflectionParameter::isCallable() * ReflectionParameter::getClass() These APIs have been superseded by ReflectionParameter::getType() since PHP

Re: [PHP-DEV] [RFC] [DISCUSSION] Immutable/final/readonly properties

2020-02-25 Thread Nicolas Grekas
Le lun. 24 févr. 2020 à 21:35, Larry Garfield a écrit : > On Mon, Feb 24, 2020, at 7:55 AM, Rowan Tommins wrote: > > On Fri, 21 Feb 2020 at 23:18, Larry Garfield > wrote: > > > > > The with*() method style requires cloning the object. What happens to > the > > > locked status of a set property

Re: [PHP-DEV] [RFC] [DISCUSSION] Immutable/final/readonly properties

2020-02-25 Thread Máté Kocsis
Sorry, but I'd like to add a correction to my previous email. After thinking about it, I realized that cloning is not that serious of a problem in case of immutable objects, since it's also possible to create a new instance instead of cloning. So it seems to be only a Developer Experience concern

Re: [PHP-DEV] [RFC] [DISCUSSION] Immutable/final/readonly properties

2020-02-25 Thread Máté Kocsis
My original idea was to discuss cloning in connection with immutable objects, - I think it's only a serious problem in that case - but we can bring this discussion earlier of course, as readonly properties certainly has some effect on the clonability of objects. When I started working on implemen