Re: [PHP-DEV] [VOTE] Type casting in array destructuring expressions

2020-04-23 Thread Enno Woortmann
Am 09.04.2020 um 11:41 schrieb Enno Woortmann: Hi together, I have opened the voting for adding type casting in array destructuring expressions: https://wiki.php.net/rfc/typecast_array_desctructuring As the future scopes section of this proposal includes additional possible topics (eg

Re: [PHP-DEV] Type hints in array destructuring expressions

2020-04-21 Thread Enno Woortmann
Am 16.04.2020 um 16:50 schrieb Nikita Popov: As you say, this syntax will likely run into parsing issues. Once you take into account that types aren't just "int", but also "Foo|Bar", and also consider that we have support for references in unpacking, you could be left with something like

Re: [PHP-DEV] Type hints in array destructuring expressions

2020-04-16 Thread Enno Woortmann
Hi, - It has been requested several times on this list to stop using the wording "type hint" and instead write "type declaration" ;) I've updated the RFC to use the "type declaration" wording, thanks for the hint :) - When I see this example in the RFC: ``` $years = [["now", 2020],

Re: [PHP-DEV] Type hints in array destructuring expressions

2020-04-16 Thread Enno Woortmann
Agree this would slow things down but if it could be potentially type checked on the assignment with type constraint in front of the variable name I think that would be a neat feature. So to work as a function parameter but not like a typed property. Hi Michał, A type check during the

[PHP-DEV] Type hints in array destructuring expressions

2020-04-16 Thread Enno Woortmann
Hi together, as the voting for the "Type casting in array destructuring expressions" shows a clear direction to be declined (sad faces on my side, I really would've liked it as a feature completion of the casting feature set without the need for a really new syntax, as the parser also already

[PHP-DEV] [VOTE] Type casting in array destructuring expressions

2020-04-09 Thread Enno Woortmann
Hi together, I have opened the voting for adding type casting in array destructuring expressions: https://wiki.php.net/rfc/typecast_array_desctructuring As the future scopes section of this proposal includes additional possible topics (eg. strict casts or the alternative solution via regular

Re: [PHP-DEV] [RFC] [DISCUSSION] Type casting in array destructuring expressions

2020-04-08 Thread Enno Woortmann
Am 07.04.2020 um 19:24 schrieb Claude Pache: Le 7 avr. 2020 à 17:09, Enno Woortmann a écrit : As the proposal explicitly aims at type casts when working with data from a untyped source (eg. iterating over a CSV file, XML without a XSD defining the types of the elements) I feel

Re: [PHP-DEV] [RFC] [DISCUSSION] Type casting in array destructuring expressions

2020-04-07 Thread Enno Woortmann
Am 07.04.2020 um 13:14 schrieb Nicolas Grekas: Le mar. 7 avr. 2020 à 12:07, Enno Woortmann a écrit : Am 25.03.2020 um 18:53 schrieb Enno Woortmann: Hi, I've written the RFC and implemented a first patch concerning the idea to allow type casting in array destructuring expressions

Re: [PHP-DEV] [RFC] [DISCUSSION] Type casting in array destructuring expressions

2020-04-07 Thread Enno Woortmann
Am 25.03.2020 um 18:53 schrieb Enno Woortmann: Hi, I've written the RFC and implemented a first patch concerning the idea to allow type casting in array destructuring expressions. The RFC is located at https://wiki.php.net/rfc/typecast_array_desctructuring The patch can be found in MR 5296

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

2020-03-28 Thread Enno Woortmann
Hi Michael, why not simply use array_push with multiple arguments? Something like: $a = []; array_push($a, ...array_fill(0, 10, 'x')); echo print_r($a, true); Cheers, Enno Am 29.03.2020 um 00:07 schrieb Michael Voříšek - ČVUT FEL: Hi all PHP gurus! This is a feature request / RFC for the

Re: [PHP-DEV] [RFC] [DISCUSSION] Type casting in array destructuring expressions

2020-03-26 Thread Enno Woortmann
$handle = fopen('test.csv', 'r'); while (($data = fgetcsv($handle)) !== false) { [int $id, string $data, int $year] = $data; // do something with the correctly typed variables } The code would trigger a fatal error when strict_types are enabled. With strict_types disabled it would

Re: [PHP-DEV] [RFC] [DISCUSSION] Type casting in array destructuring expressions

2020-03-26 Thread Enno Woortmann
Hi Levi, Am 25.03.2020 um 21:44 schrieb Levi Morrison: To me, this is almost a good idea. However, I would want regular type checking, not casts. Importantly, regular type checks would fit well on allowing array destructuring directly in function signatures, which would basically be a form of

[PHP-DEV] [RFC] [DISCUSSION] Type casting in array destructuring expressions

2020-03-25 Thread Enno Woortmann
Hi, I've written the RFC and implemented a first patch concerning the idea to allow type casting in array destructuring expressions. The RFC is located at https://wiki.php.net/rfc/typecast_array_desctructuring The patch can be found in MR 5296 located at

[PHP-DEV] Type casting while array destructuring

2020-03-24 Thread Enno Woortmann
Hi, currently when using array destructuring the variables are assigned as they are. For example we split a string with explode all variables will contain strings: $data = "foo:*:1023:1000::/home/foo:/bin/sh"; [$user, $pass, $uid, $gid, $gecos, $home, $shell] = explode(":", $data); If we want

Re: [PHP-DEV] Replacing array_slice

2018-07-17 Thread Enno Woortmann
Am 17.07.2018 um 07:35 schrieb Zeev Suraski: On 17 Jul 2018, at 7:12, Levi Morrison wrote: Fixing `array_slice` would probably do more harm than good at this stage. Instead I would like to provide an alternative function that does not have all this baggage, and will have decent performance

Re: [PHP-DEV] [VOTE] array_key_first(), array_key_last(), array_value_first(), array_value_last()

2018-07-16 Thread Enno Woortmann
Am 09.07.2018 um 13:16 schrieb Woortmann, Enno: Hi, as the discussion got no new contributions I'd like to start the voting for the RFC fo add new functions for the handling of outer array elements. https://wiki.php.net/rfc/array_key_first_last To have a better separation I split up the

Re: [PHP-DEV] Re:[PHP-DEV] [VOTE] array_key_first(),array_key_last(), array_value_first(),array_value_last()

2018-07-11 Thread Enno Woortmann
Am 11.07.2018 um 20:18 schrieb Levi Morrison: In my opinion neither rejecting the RFC nor changing it to return tuples solves the underlying problem. What is the underlying problem in your opinion? My opinion is that the core problem is that these functions cannot be efficiently implemented

Re: [PHP-DEV] [RFC][Under Discussion] Add functions array_key_first()and array_key_last()

2018-07-04 Thread Enno Woortmann
Am 28.06.2018 um 16:52 schrieb Levi Morrison: I think there has been a lack of discussion about why this is desired. For me, it's always been implementing certain kinds of iterators that wrap arrays. This means that functions which return both the key and value are optimal for me. As I already

Re: [PHP-DEV] [RFC][Under Discussion] Add functions array_key_first() and array_key_last()

2018-06-17 Thread Enno Woortmann
Hi niel, Am 18.06.2018 um 01:59 schrieb niel: However my main concern that a non-array variable or a non-existent value, are an error and need to be handled appropriately, has not changed. IMO, a notice/warning does little to nothing in helping the programmer determine the problem and track

Re: [PHP-DEV] xmlrpc extension maintainership?

2018-06-17 Thread Enno Woortmann
Am 17.06.2018 um 22:59 schrieb Stanislav Malyshev: Hi! About 2 years ago, in https://externals.io/message/94540#94546, you expressed interest in maintaining XML-RPC extension. I haven't seen any activity from you since then. Are you still interested? If so, it might be a good idea to look

Re: [PHP-DEV] [RFC][Under Discussion] Add functions array_key_first() and array_key_last()

2018-06-17 Thread Enno Woortmann
Hi Alice, Am 17.06.2018 um 22:16 schrieb Alice Wonder: boolean is a value, null is the absence of a value, which is more accurate, no? In my opinion that's the argument to return null for either parameters which aren't an array or empty arrays simply because a first/last key isn't present

Re: [PHP-DEV] [RFC][Under Discussion] Add functions array_key_first() and array_key_last()

2018-06-15 Thread Enno Woortmann
Hi niel, On 15.06.2018 at 17:37 niel wrote: What is the behaviour if the array does not exist? From the current RFC it appears it would return null? Wouldn't it be better to return false for this situation? Thanks for the comment. Why do you think false would be a better return value?

[PHP-DEV] Re: [RFC][Under Discussion] Add functions array_key_first() and array_key_last()

2018-06-14 Thread Enno Woortmann
Hi, On 13.06.2018 at 23:10, Christoph M. Becker wrote: I suggest to address Côme's suggestion[1] on this mailing list and especially in the RFC (the template[2] offers “Open Issues” and “Rejected Features” sections). [1] I've added the "Open

[PHP-DEV] [RFC][Under Discussion] Add functions array_key_first() and array_key_last()

2018-06-13 Thread Enno Woortmann
Hello internals, I've changed the status of the currently introduced RFC to add the functions array_key_first() and array_key_last() to "Under Discussion". https://wiki.php.net/rfc/array_key_first_last Regards, Enno -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe,

[PHP-DEV] Re: Add functions array_key_first() and array_key_last()

2018-06-11 Thread Enno Woortmann
Hi Christoph, On 11.06.2018 at 15:21, Christoph M. Becker wrote: You should have RFC karma now. Thanks for the RFC karma, everything worked fine. I've created a new RFC for this topic located at https://wiki.php.net/rfc/array_key_first_last Thanks, Enno --- Diese E-Mail wurde von Avast

[PHP-DEV] Add functions array_key_first() and array_key_last()

2018-06-11 Thread Enno Woortmann
Hello Internals, I'd like to ask for feedback for my idea. Some years ago a pull request came up to add array_key_first(), array_key_last(), and array_key_index() functions (#347 ). In the meantime a RFC was published to integrate the functions