IsResource

Inspired by a recent discussion in the PHP Internals, I decided to provide a userland solution. Check this:

<?php

$hash = hash_init('md5');

// vanilla functions:
is_resource($hash); // true in PHP <= 7.1, false in PHP >= 7.2
get_resource_type($hash); // "Hash Context" in PHP <= 7.1, various errors otherwise

// library functions:
\Arokettu\IsResource\is_resource($hash); // true
\Arokettu\IsResource\get_resource_type($hash); // "Hash Context"

Get it on my dev portal: https://sandfox.dev/php/is-resource.html

Comments

Comments powered by Disqus