On Tue, May 14, 2019 at 4:45 PM Nikita Popov <nikita....@gmail.com> wrote:
> On Tue, May 14, 2019 at 4:37 PM Marco Pivetta <ocram...@gmail.com> wrote: > >> >> On Tue, May 14, 2019 at 4:29 PM Benjamin Morel <benjamin.mo...@gmail.com> >> wrote: >> >>> I like the explicitness of the proposal, but only if performance is as >>> good >>> as (array) cast. One of the reasons we use casting to array in libraries >>> is >>> not only to access all properties at once, but also because it's fast as >>> it's implemented as an opcode and not a function call. Would this >>> function >>> come with its own opcode, like strlen() / gettype() / etc.? >>> >>> Ben >>> >> >> Indeed. Besides that, this is a good chance to have an explicit `object` >> parameter type. >> >> @Nikic is the return type also `array`, according to reflection? >> > > I'd prefer not to add either of them until the question of type > annotations on internal functions is solved more comprehensively in PHP 8. > In particular adding an "object" type will currently add additional cost to > the call. I hope that we'll solve this problem in PHP 8 and annotate > functions with types in a comprehensive way (including existing functions, > like get_object_vars). > > Nikita > Any more feedback on the addition of get_mangled_object_vars()? Regarding the typehints, I've added an "array" return type for get_object_vars() in PHP 8 ( https://github.com/php/php-src/commit/252216b2ded7d3808e2a909bfea1e805ee17cde5) and will do the same for this function. The argument type is still blocked on some preparatory work. Nikita