Add get_resource_id() function

php.internals

Nikita Popov

6 years ago
Hi internals, This originally came up in the "Stricter type-checks for arithmetic/bitwise operators" thread. I would like to add a get_resource_id() function, which does the same as an (int) $resource cast, just in a more explicit way, that does not require the reader to be familiar with PHP language minutiae. There is no plan to deprecate or remove the (int) $resource form. This is similar to the recently added get_mangled_object_vars() function, which is (about) the same as an (array) $object cast, but makes the intention of working with mangled properties clearer clearer. The get_resource_id() name is based on the already existing get_resource_type() function. The implementation is trivial and available at https://github.com/php/php-src/pull/5427. Regards, Nikita

Nikita Popov

6 years ago
On Tue, Apr 21, 2020 at 12:44 PM Nikita Popov <nikita.ppv@gmail.com> wrote:
> Hi internals, > > This originally came up in the "Stricter type-checks for > arithmetic/bitwise operators" thread. I would like to add a > get_resource_id() function, which does the same as an (int) $resource cast, > just in a more explicit way, that does not require the reader to be > familiar with PHP language minutiae. There is no plan to deprecate or > remove the (int) $resource form. > > This is similar to the recently added get_mangled_object_vars() function, > which is (about) the same as an (array) $object cast, but makes the > intention of working with mangled properties clearer clearer. > > The get_resource_id() name is based on the already existing > get_resource_type() function. > > The implementation is trivial and available at > https://github.com/php/php-src/pull/5427. >
As there haven't been objections here and reception on the PR positive, I went ahead and merged this. Nikita