Req #76865 [Com]: RFC: make `array_*` functions handling `iterable`, not only `array`

From: Date: Wed, 12 Sep 2018 01:29:11 +0000
Subject: Req #76865 [Com]: RFC: make `array_*` functions handling `iterable`, not only `array`
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-216999@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=76865&edit=1 ID: 76865 Comment by: scif-1986 at ya dot ru Reported by: scif-1986 at ya dot ru Summary: RFC: make array_* functions handling iterable, not only array Status: Open Type: Feature/Change Request Package: Arrays related PHP Version: Next Minor Version Block user comment: N Private report: N New Comment: Actually, these functions will still return an array as a result :) Also, I can't find any suitable name for such functions. iterable_diff()? Looks ugly. And array will still be the valid input. Previous Comments: ------------------------------------------------------------------------ [2018-09-12 01:20:21] carusogabriel@php.net This is something I'd love to see implemented, but, I don't know if we should change the array_* functions. By they starting with "array_", we presume that one of the arguments is gonna be an array, not an iterable. I can try to create POC within the next weeks and open for discussion on internals@ :) ------------------------------------------------------------------------ [2018-09-12 01:04:19] scif-1986 at ya dot ru Description: ------------ The iterable pseudo-type has been introduced for a while and is very useful. While array_*() core functions are still doesn't support iterable as argument and works with array only. Obviously, I'm talking about array_map()/array_column()/array_diff(),array_chunk()/array_combine()… which don't change an argument by pointer. Sorry, don't know C, so it's just an idea :) ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=76865&edit=1

« previous php.bugs (#216999) next »