Doc #76117 [Asn->Fbk]: uopz flags is NOT for classes, but methods

From: Date: Tue, 20 Mar 2018 17:43:26 +0000
Subject: Doc #76117 [Asn->Fbk]: uopz flags is NOT for classes, but methods
References: 1  Groups: php.doc.bugs 
Request: Send a blank email to doc-bugs+get-15545@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=76117&edit=1 ID: 76117 Updated by: cmb@php.net Reported by: Andy_Schmidt at HM-Software dot com Summary: uopz flags is NOT for classes, but methods -Status: Assigned +Status: Feedback Type: Documentation Problem Package: Documentation problem Operating System: any PHP Version: 7.2.3 Assigned To: cmb Block user comment: N Private report: N New Comment: Thanks for testing. However, my test script works for me on Windows with PHP 5.6 with UOPZ 2.0.7 and PHP 7.1 and 7.2 with UOPZ 5.0.2, which is to be expected from looking at the relevant code[1]. The InvalidArgumentException would be thrown, though, if an yet undefined class would be passed as first parameter to uopz_flags(). Is there perhaps an issue with OPcache? Note that UOPZ should be loaded before OPcache. [1] <https://github.com/krakjoe/uopz/blob/v5.0.2/uopz.c#L530> Previous Comments: ------------------------------------------------------------------------ [2018-03-20 15:18:17] Andy_Schmidt at HM-Software dot com Result: PHP Fatal error: Uncaught InvalidArgumentException: unexpected parameter combination, expected (class, function, flags) or (function, flags) Stack trace: #0: uopz_flags('MyClass', NULL, 0) ------------------------------------------------------------------------ [2018-03-20 12:36:37] cmb@php.net Please try: <?php final class MyClass { function mymethod() {} }; var_dump( ( new ReflectionClass( 'MyClass') )->isFinal() ); uopz_flags(MyClass::class, null, 0); var_dump( ( new ReflectionClass( 'MyClass') )->isFinal() ); This should print: bool(true) bool(false) ------------------------------------------------------------------------ [2018-03-20 04:03:49] Andy_Schmidt at HM-Software dot com Description: ------------ --- From manual page: http://www.php.net/function.uopz-flags --- The manual incorrectly states: "Get or set flags on function or class". This implies to the reader that either the flags of a standalone function, or the flags of the class itself (such as "final class {}") can be queried or manipulated. In reality with version UOPZ 5.02 one can only reference a function or a class::method! One simply cannot omit the function name (e.g., making it NULL, or '' - it can't even be '__construct') The correct text shoud read: "Get or set flags on function or class method" ... "Get or set the flags on a method or function entry at runtime" ... function The name of the function or method Test script: --------------- final class MyClass { function mymethod() {} }; var_dump( ( new ReflectionClass( 'MyClass') )->isFinal() ); if ( !defined( 'ZEND_ACC_FETCH' ) ) define( 'ZEND_ACC_FETCH', PHP_INT_MAX ); // Works: var_dump( uopz_flags( 'MyClass', 'mymethod' , ZEND_ACC_FETCH ) ); // Fails: var_dump( uopz_flags( 'MyClass', '' , ZEND_ACC_FETCH ) ); var_dump( uopz_flags( 'MyClass', NULL , ZEND_ACC_FETCH ) ); ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=76117&edit=1

« previous php.doc.bugs (#15545) next »