1.2.1232. Typehints/CouldBeResource

Mark arguments, properties and return types that can be set to resource.

resource is an internal PHP type, and it should be a scalar type, yet it is not implement yet (as of PHP 8.2). It is still used as such by Exakat.

<?php

class x {
    // $p holds a resource
    private $p;

    function __construct() {
        $this->p = fopen('/tmp/file.txt', 'w+');
    }
}
?>

1.2.1232.1. Specs

Short name

Typehints/CouldBeResource

Rulesets

All, Changed Behavior, Typechecks

Exakat since

2.4.5

PHP Version

All

Severity

Minor

Time To Fix

Quick (30 mins)

Precision

High

Features

resource, typehint

Available in

Entreprise Edition, Exakat Cloud