Re: [PHP-DEV][RFC] Cast in foreach

2019-02-21 Thread Kalle Sommer Nielsen
Den tor. 21. feb. 2019 kl. 14.16 skrev Chris Riley : > > Hi internals, > > I'd like to propose opening an rfc to make the following syntax legal: > > foreach($array as (int) $i) {} How would this interact with the foreach-list syntax? $data = [ ["id" => 1, "name" => 'Tom'], ["id" => 2,

Re: [PHP-DEV][RFC] Cast in foreach

2019-02-21 Thread Riikka Kalliomäki
On Thu, Feb 21, 2019 at 3:36 PM Kalle Sommer Nielsen wrote: > > Den tor. 21. feb. 2019 kl. 14.16 skrev Chris Riley : > > > > Hi internals, > > > > I'd like to propose opening an rfc to make the following syntax legal: > > > > foreach($array as (int) $i) {} > > How would this interact with the

Re: [PHP-DEV][RFC] Cast in foreach

2019-02-21 Thread Legale.legale
what about: foreach($array as $i=>$v) {} ?On Feb 21, 2019 13:15, Chris Riley wrote: > > Hi internals, > > I'd like to propose opening an rfc to make the following syntax legal: > > foreach($array as (int) $i) {} > > Which would be functionally equivalent to > > foreach($array as $i) { >

[PHP-DEV] PHP 7.3.3RC1 is available for testing

2019-02-21 Thread Christoph M. Becker
Hi, PHP 7.3.3RC1 has just been released and can be downloaded from: Or use the git tag: php-7.3.3RC1 The Windows binaries are available at: Please test it carefully, and report any bugs in the bug system. 7.3.3 should be

[PHP-DEV] PHP version 7.2.16RC1 is available for testing

2019-02-21 Thread Remi Collet
Hi, PHP 7.2.16 RC1 was just released and can be downloaded from: https://downloads.php.net/~remi/ Or using the git tag: php-7.2.16RC1 The Windows binaries are available at: http://windows.php.net/qa/ Please test it carefully, and report any bugs in the bug system. 7.2.16 should be

Re: [PHP-DEV][RFC] Cast in foreach

2019-02-21 Thread Marco Pivetta
On Thu, Feb 21, 2019 at 1:16 PM Chris Riley wrote: > Hi internals, > > I'd like to propose opening an rfc to make the following syntax legal: > > foreach($array as (int) $i) {} > > Which would be functionally equivalent to > > foreach($array as $i) { > $i=(int) $i; > } > > Thoughts? Feedback? >

[PHP-DEV][RFC] Cast in foreach

2019-02-21 Thread Chris Riley
Hi internals, I'd like to propose opening an rfc to make the following syntax legal: foreach($array as (int) $i) {} Which would be functionally equivalent to foreach($array as $i) { $i=(int) $i; } Thoughts? Feedback? ~C

[PHP-DEV] Optional catch binding

2019-02-21 Thread Roland Franssen
Hi Internals, I'd like to propose an idea to allow catching exceptions by type only, or globally, by any type. In case the "$e" variable or the exception type is redundant, it doesn't need to be specified: try { x(); } catch (\Throwable) { // ... } try { x(); } catch { // ... }

Re: [PHP-DEV] Optional catch binding

2019-02-21 Thread Dan Ackroyd
On Thu, 21 Feb 2019 at 15:46, Roland Franssen wrote: > For now, I'm aiming to get rid of "unused variable $e". You seem to be trying to alter the language to fit your code-style checker, rather than altering your code-style checker to fit the language. That seems back-to-front to me. Although

Re: [PHP-DEV] Optional catch binding

2019-02-21 Thread Roland Franssen
Hi, My final argument is it allows us to convey better semantics. Nevertheless, i understand these concerns; i cannot really disagree with that. I dont think "unused variable" is a code style matter, but actually more relates to static analysis. Which kinda raised the question; why do i have to

[PHP-DEV] Optional catch binding

2019-02-21 Thread Roland Franssen
Hi Internals, I'd like to propose an idea to allow catching exceptions by type only, or globally, by any type. In case the "$e" variable or the exception type is redundant, it doesn't need to be specified: try { x(); } catch (\Throwable) { // ... } try { x(); } catch { // ... }

Re: [PHP-DEV] Optional catch binding

2019-02-21 Thread Gabriel O
How is it another way of doing same thing? It’s same way without unnecessary stuff. It’s more intuitive, as it doesn’t make sense to force user to specify variable they don’t need. When learning PHP, I remember being surprised I’m forced to specify variable I am not going to use. Plenty other

Re: [PHP-DEV][RFC] Cast in foreach

2019-02-21 Thread Stanislav Malyshev
Hi! > I'd like to propose opening an rfc to make the following syntax legal: > > foreach($array as (int) $i) {} > > Which would be functionally equivalent to > > foreach($array as $i) { > $i=(int) $i; > } This doesn't seem to add anything to existing functionality - what's wrong with just

Re: [PHP-DEV] Optional catch binding

2019-02-21 Thread Roland Franssen
> it produces a warning - and it should, since what is being done is what usually should not be done I didn't want to turn this into an "error handling best practices" discussion. Exceptions might not be recommended to use for flow-control, yet this is possible today and really depends on the

Re: [PHP-DEV] Optional catch binding

2019-02-21 Thread Stanislav Malyshev
Hi! > Allthough global exception catching might not be a good practice per se, I > don't see a real reason to forbid it. However, these are 2 independent > features that can be voted for I guess. It's not forbidden now. But there's no reason to encourage it and develop a dedicated syntax for it.