As of PHP 7.4.0, if the parameter flags is passed,
uopz_flags() throws a RuntimeException,
if OPcache is enabled,
and the class entry of class
or the function entry of function is immutable.
If the method name is set to an empty string, then the flags for the CLASS itself will be affected, instead of an individual method. This can be used to remove the "final" attribute from a class. <?php declare(strict_types=1);
final class MyClass { function mymethod() {} }; uopz_flags(MyClass::class, '', 0); ?>
Note: Although not documented, setting the method to NULL will also target the CLASS flags, however, that syntax will clash with strict types because of the developer's improper function signature.
To clarify the above hint: "...the class entry of class or the function entry of function is immutable"
Neither PHP class or function definitions have any "immutable" keyword - so this note is confusing, as it implies that a PHP programmer has any control over this. In reality, the "immutable" state mentioned is an internally-controlled optimization/shared memory feature of OPcache.
Consequently, if one has a need to set (alter) the flags of a PHP class or function by means of "uopz_flags()", then it is necessary to EXCLUDE the PHP script of the referenced class or function from OPcache, using the "opcache.blacklist_filename" INI parameter.