1.2.928. PHP 8.1 Resources Turned Into Objects

Multiple PHP native functions now return objects, not resources. Any check on those values with is_resource() is now going to fail.

The affected functions are the following :

<?php

$pspell = new pspell_new(en, , , ,
                     (PSPELL_FAST|PSPELL_RUN_TOGETHER));
var_dump(is_resource($pspell)); // true in PHP 8.0,
                                                         // false in PHP 8.1

?>

See also UPGRADING PHP 8.1.

1.2.928.1. Suggestions

  • Change the condition from is_resource() to instanceof

1.2.928.2. Specs

Short name

Php/Php81RemovesResources

Rulesets

All, Changed Behavior, CompatibilityPHP80

Exakat since

2.2.0

PHP Version

All

Severity

Major

Time To Fix

Quick (30 mins)

Changed Behavior

PHP 8.1 - More

Precision

Very high

Features

resource

Available in

Entreprise Edition, Exakat Cloud