symfony / polyfill

PHP polyfills

Home Page:https://symfony.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[PHP 7.4] Add get_mangled_object_vars()

IonBazan opened this issue · comments

There is a new function coming in PHP 7.4 called get_mangled_object_vars() which returns same result as (array) $object with the exception that it ignores overloaded array casts, such as used by ArrayObject.
Output is also similar to get_object_vars() but it also shows protected and private fields.

To implement that we will probably need to use ReflectionObject.

PHP implementation and phpt test:
php/php-src@eecd896

There's also mb_str_split() and password_algos() which could be polyfilled.

For get_mangled_vars() I'd recommend using something like getArrayObjectProperties for ArrayObject and ArrayIterator, and using (array) for anything else, for decent performances (then we might add more exceptions as they are reported.)

PR(s) welcome :)