Re: [PHP-DEV] Interfaces and ReflectionMethod::isConstructor()

2020-03-29 Thread Sebastian Bergmann
Am 28.03.2020 um 08:44 schrieb Sebastian Bergmann: I can deal with this in PHPUnit's code either way, but need to know what the plan here is. I worked around the issue now [1]. -- [1] https://github.com/sebastianbergmann/phpunit/commit/477798f6b226e830d358bc102cd02bb2e52cfdb2 -- PHP Interna

Re: [PHP-DEV] Re: [RFC][DISCUSSION] Change var_export() array syntax to use shorthand arrays

2020-03-29 Thread Sherif Ramadan
Hey Andrea, Thanks for that. Good catch on the stdClass and __set_state parts. I neglected those in RFC, but I will add them. But they are still all forwards compatible changes so no major impact. On Sun, Mar 29, 2020 at 6:42 PM Andrea Faulds wrote: > Hi again, > > Andrea Faulds wrote: > > Hi S

Re: [PHP-DEV] [RFC] [DISCUSSION] Compact Object Property Assignment

2020-03-29 Thread Levi Morrison via internals
The current RFC text is not consistent with using `=` or `=>` for the assignments. The assignment `=` is vastly more common, though, and I don't understand why if we are using an array syntax we aren't using `=>`. I intend to vote no. I agree that we need to do something in this space, but this is

RE: [PHP-DEV] Feature request - allow to append multiple elements to an array

2020-03-29 Thread Iván Arias
>> $arr[] = 1, 2, 3; // push these 3 values >> $arr[] = 1, 2, ... [3, 4, 5], 6; // push these 6 values > >Just to play with this... - normally an assignment evaluates to the >value being assigned: > >var_dump($arr[] = 1); // int(1) > >What would this produce? > >var_dump($arr[] = 1, 2, 3); > >The f

[PHP-DEV] Re: [RFC][DISCUSSION] Change var_export() array syntax to use shorthand arrays

2020-03-29 Thread Andrea Faulds
Hi again, Andrea Faulds wrote: Hi Sherif, Sherif Ramadan wrote: I'm proposing a new RFC to change var_export()'s array syntax to use the short hand array syntax instead. The RFC is available here https://wiki.php.net/rfc/var-export-array-syntax This is a forwards-compatible change proposed

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

2020-03-29 Thread Andrea Faulds
Hi Sherif, Sherif Ramadan wrote: I'm proposing a new RFC to change var_export()'s array syntax to use the short hand array syntax instead. The RFC is available here https://wiki.php.net/rfc/var-export-array-syntax This is a forwards-compatible change proposed for and targeting PHP 8.0. I'd li

Re: [PHP-DEV] [RFC] switch expression

2020-03-29 Thread Stanislav Malyshev
Hi! > 1. It uses the same AST, code generation and opcodes as the switch, I > don't agree that it is significantly different than the switch that we > already have. This is reasoning in wrong direction. Nobody cares which opcode it uses. It is significantly different *for the user*, the fact that

Re: [PHP-DEV] [RFC] switch expression

2020-03-29 Thread Ilija Tovilo
Hi Larry Thanks for your suggestion. I chose to use switch instead of match for a couple of reasons: 1. It uses the same AST, code generation and opcodes as the switch, I don't agree that it is significantly different than the switch that we already have. 2. Adding the `match` keyword is a break

Re: [PHP-DEV] [RFC] switch expression

2020-03-29 Thread G. P. B.
On Sun, 29 Mar 2020 at 23:54, Stanislav Malyshev wrote: > Hi! > > > My recommendation would be to just borrow Rust's keyword: > > > > $result = match ($var) { > > $expression => $expression; > > $expression => $expression; > > $expression => $expression; > > default => $expression; > > }

Re: [PHP-DEV] [RFC] [DISCUSSION] Compact Object Property Assignment

2020-03-29 Thread Larry Garfield
On Sun, Mar 29, 2020, at 3:57 PM, Jakob Givoni wrote: > Hi Rowan, > > On Sun, Mar 29, 2020 at 10:00 AM Rowan Tommins > wrote: > > > > > myObj.with { > > foo = 10 > > bar = foo + 20 > > } > > > > I really like the suggested "with" syntax, - in fact I had > contemplated something like t

Re: [PHP-DEV] [RFC] switch expression

2020-03-29 Thread Stanislav Malyshev
Hi! > My recommendation would be to just borrow Rust's keyword: > > $result = match ($var) { > $expression => $expression; > $expression => $expression; > $expression => $expression; > default => $expression; > } Yes, this would be much better idea. -- Stas Malyshev smalys...@gmail.com

Re: [PHP-DEV] [RFC] switch expression

2020-03-29 Thread Larry Garfield
On Sun, Mar 29, 2020, at 4:04 PM, Ilija Tovilo wrote: > > Having two syntaxes for one keyword is not a good idea, > > We're already doing that. What about classes vs anonymous objects? > Functions vs closures? > They're using the same keywords. There's no confusion. > > Ilija There's subtle and

Re: [PHP-DEV] [RFC] switch expression

2020-03-29 Thread G. P. B.
On Sun, 29 Mar 2020 at 23:04, Ilija Tovilo wrote: > > Having two syntaxes for one keyword is not a good idea, > > We're already doing that. What about classes vs anonymous objects? > Functions vs closures? > They're using the same keywords. There's no confusion. > > Ilija > > -- > PHP Internals -

Re: [PHP-DEV] [VOTE] Userspace operator overloading

2020-03-29 Thread Terje Slettebø
Stanislav wrote: I think "as long as it is not overused" are the key words there. We have a very limited number of internal classes with operator overloading I think the whole point of leaving it to extensions was ensuring it's not overused. And now I see people arguing "well, if it's availabl

Re: [PHP-DEV] [RFC] Allow trailing comma in parameter lists

2020-03-29 Thread Jakob Givoni
Hi Rowan, On Sat, Mar 28, 2020 at 4:01 PM Rowan Tommins wrote: > > While I'd personally be fine with this change, I think we should > understand why the previous proposal failed rather than just hoping the > vote goes differently this time. I think you have a good point here. I've only been arou

Re: [PHP-DEV] Feature request - allow to append multiple elements to an array

2020-03-29 Thread Jakob Givoni
On Sun, Mar 29, 2020 at 4:08 AM Iván Arias wrote: > > $arr[] = 1, 2, 3; // push these 3 values > $arr[] = 1, 2, ... [3, 4, 5], 6; // push these 6 values Just to play with this... - normally an assignment evaluates to the value being assigned: var_dump($arr[] = 1); // int(1) What would this prod

Re: [PHP-DEV] [RFC] [DISCUSSION] Compact Object Property Assignment

2020-03-29 Thread Jakob Givoni
Hi Andrea, On Sun, Mar 29, 2020 at 10:31 AM Andrea Faulds wrote: > > > (function ($obj) { > $foo = "foo"; > $bar = "bar"; > $baz = "baz"; > > $vars = get_defined_vars(); > foreach ($vars as $key => $value) { > $obj->$key = $value; >

Re: [PHP-DEV] [RFC] switch expression

2020-03-29 Thread Ilija Tovilo
> Having two syntaxes for one keyword is not a good idea, We're already doing that. What about classes vs anonymous objects? Functions vs closures? They're using the same keywords. There's no confusion. Ilija -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://

Re: [PHP-DEV] Feature request - allow to append multiple elementsto an array

2020-03-29 Thread Christoph M. Becker
On 29.03.2020 at 21:05, Manuel Canga wrote: > Maybe, PHP needs array_flatten like Ruby: > https://apidock.com/ruby/Array/flatten > > In this way, above code would be equal to: > > $res = array_flatten( array_map('make_res', $arr) ); You can already do $res = array_merge(...array_map('make_re

Re: [PHP-DEV] Function and operator overloading

2020-03-29 Thread Terje Slettebø
Hi Nikita. Thanks for your response and the links. I found the search engine you linked to working well. The reason I came to think of this issue was not as much to be able to do function overloading in general, but more from the fact that the discussion on operator overloading seemed to inv

Re: [PHP-DEV] [RFC] switch expression

2020-03-29 Thread Stanislav Malyshev
Hi! >> I'm still not sure why if we're calling it "switch" > > C# does it. Not to say everything they do is right but it's reassuring > that a big company like Microsoft had the same approach. No it isn't. Having two syntaxes for one keyword is not a good idea, whether Microsoft is doing it or n

Re: [PHP-DEV] [RFC] switch expression

2020-03-29 Thread Ilija Tovilo
Hi Stanislav > I'm still not sure why if we're calling it "switch" C# does it. Not to say everything they do is right but it's reassuring that a big company like Microsoft had the same approach. https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/switch https://docs.micros

Re: [PHP-DEV] [RFC] [DISCUSSION] Compact Object Property Assignment

2020-03-29 Thread Jakob Givoni
Hi Rowan, On Sun, Mar 29, 2020 at 10:00 AM Rowan Tommins wrote: > > myObj.with { > foo = 10 > bar = foo + 20 > } > I really like the suggested "with" syntax, - in fact I had contemplated something like that along the way. The slight "problem", I think, is that, as you mention, adding

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

2020-03-29 Thread Benjamin Morel
+1 for this. This is the syntax I'm using in brick/varexporter , and supporting it natively in var_export() makes sense. — Benjamin

Re: [PHP-DEV] [RFC] switch expression

2020-03-29 Thread Stanislav Malyshev
Hi! > You can take a look at the tests to get a feel for what it’s like: > > https://github.com/php/php-src/pull/5308/files > > Multiple conditions are possible: > > ``` > > return $day switch { > >     1, 7 => false, > >     2, 3, 4, 5, 6 => true, > > }; I'm still not sure why if we're ca

Re: [PHP-DEV] [VOTE] Userspace operator overloading

2020-03-29 Thread Stanislav Malyshev
Hi! > I think “as long as it is not overused” are the key words there. We have > a very limited number of internal classes with operator overloading I think the whole point of leaving it to extensions was ensuring it's not overused. And now I see people arguing "well, if it's available to extensi

Re: [PHP-DEV] Feature request - allow to append multiple elements to an array

2020-03-29 Thread Manuel Canga
Hi, Internals > > Em sáb., 28 de mar. de 2020 às 20:07, Michael Voříšek - ČVUT FEL < > voris...@fel.cvut.cz> escreveu: > > > Hi all PHP gurus! > > > > This is a feature request / RFC for the following use-case: > > > > $res = []; > > foreach ($arr as $i) { > > foreach (make_res($i) a

[PHP-DEV] [RFC] Ensure correct magic methods' signatures when typed

2020-03-29 Thread Gabriel Caruso
Hello internals. I'd like to discuss with you about https://github.com/php/php-src/pull/4177. I'll write a formal RFC for this during the week. Open question: ```php public function __constructor() {} ``` vs. ```php public function __constructor(): void {} ``` The same goes for `__destruct`,

[PHP-DEV] [RFC][DISCUSSION] Change var_export() array syntax to use short hand arrays

2020-03-29 Thread Sherif Ramadan
I'm proposing a new RFC to change var_export()'s array syntax to use the short hand array syntax instead. The RFC is available here https://wiki.php.net/rfc/var-export-array-syntax This is a forwards-compatible change proposed for and targeting PHP 8.0. I'd like to open up discussion.

Re: [PHP-DEV] [RFC] [DISCUSSION] Compact Object Property Assignment

2020-03-29 Thread Andrea Faulds
Hi Rowan, Rowan Tommins wrote: Hi Jakob, It occurred to me thinking about alternative syntaxes that COPA could be seen as a limited form of the "with" statement found in some languages, e.g. JS [1], VisualBasic [2], Delphi [3], Groovy [4] (note that with blocks in Python are something diffe

Re: [PHP-DEV] [RFC] [DISCUSSION] Compact Object Property Assignment

2020-03-29 Thread Rowan Tommins
On 28/03/2020 21:37, Jakob Givoni wrote: I really believe that COPA can help thousands of PHP developers without introducing any new complexities to the language and my hope is that perfect won't be the enemy of good this time around :-) Any last words unsaid before the final lap commences? H

Re: [PHP-DEV] [VOTE] Userspace operator overloading

2020-03-29 Thread Christoph M. Becker
On 28.03.2020 at 22:21, Andrea Faulds wrote: > Christoph M. Becker wrote: >> (frankly, I would not have not supported __concat() at all).  Also, >> overloaded operators should be programmed defensively, i.e. they should >> not accept arbitrary arguments (how could that even work?), but only >> tho

[PHP-DEV] Re: Interfaces and ReflectionMethod::isConstructor()

2020-03-29 Thread Christoph M. Becker
On 28.03.2020 at 08:44, Sebastian Bergmann wrote: > I recently received a bug report for PHPUnit [1] that with PHP 8 test > doubles (test stubs or mock objects) can no longer be created for > interfaces that declare a constructor. > > I was able to reproduce this [2] and learned that PHPUnit's > c

Re: [PHP-DEV] Feature request - allow to append multiple elements to an array

2020-03-29 Thread Iván Arias
Hi all, I think David's syntax make more sense. Maybe we could support multiple arguments for push operator, just like array_push does: $arr[] = 1, 2, 3; // push these 3 values $arr[] = 1, 2, ... [3, 4, 5], 6; // push these 6 values Regards, Iván Arias. Obtener Outlook para Android