|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2018-03-20 04:03 UTC] 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 ) ); PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Oct 26 22:00:01 2025 UTC |
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)Result: PHP Fatal error: Uncaught InvalidArgumentException: unexpected parameter combination, expected (class, function, flags) or (function, flags) Stack trace: #0: uopz_flags('MyClass', NULL, 0)No Opcode active. I even disabled WinCache and xdebug extensions and retestet. In addition, I moved the uopz extension to be first one .ini file. Result remains: PHP Fatal error: Uncaught InvalidArgumentException: unexpected parameter combination, expected (class, function, flags) or (function, flags) Stack trace: #0 E:\Hosted Sites\wwwroot\anamera_v2\test\syntax.php(6): uopz_flags('MyClass', NULL, 0) #1 {main} To me, the message does NOT indicate that "class" does not exist, it seems to state that the parameter signature doesn't match one of the two permitted variations. This is further supported by the fact that THIS will work just fine: var_dump( uopz_flags(MyClass::class, 'mymethod', 0) ); If the problem was an absent MyClass, then the combination MyClass::mymethod would also have failed. So - as long as a method parameter is not left NULL, the uopz_flags function will work as expected.