Edit report at http://bugs.php.net/bug.php?id=53705&edit=1
ID: 53705 Updated by: [email protected] Reported by: inbox at astions dot com Summary: Add AOP & Interception Filter Support -Status: Open +Status: Wont fix Type: Feature/Change Request Package: *Programming Data Structures Operating System: NA PHP Version: Irrelevant Block user comment: N Private report: N New Comment: You could do exactly the same thing with a __call() wrapper method in the class assuming you are able to modify the class and make the methods provate so they can only be called via the __call() wrapper. The overhead of checking every function call for before, filter and after trigger methods in an interpreted scripting language prevents this from being a realistic feature request. Previous Comments: ------------------------------------------------------------------------ [2011-01-10 07:59:26] inbox at astions dot com Description: ------------ I propose a modification to the PHP core adding the following features. (Not all inclusive, I'll try to include everything I think needs to be added). I guess this could be called interception. The official name is AOP. What it would enable you to do is intercept method calls immediately before and after they are executed. It would also enable you to filter the arguments sent to the methods. We would need: A way to enable this feature. A way to add interceptions A way to list interceptions A way to remove interceptions The ability to view interceptions in standard debug backtraces. Test script: --------------- interception::attachBefore('className', 'methodName', 'classToExecute', 'methodToExecute'); interception::attachFilter('className', 'methodName', 'classToExecute', 'methodToExecute'); interception::attachAfter('className', 'methodName', 'classToExecute', 'methodToExecute'); interception::detachBefore('className', 'methodName', 'classToExecute', 'methodToExecute'); interception::detachFilter('className', 'methodName', 'classToExecute', 'methodToExecute'); interception::detachAfter('className', 'methodName', 'classToExecute', 'methodToExecute'); $list = interception::getAll(); $list = interception::getForClass('className', [methodName]); interception::clearAll(); Expected result: ---------------- When attaching an intercept before a method call, the methodToExecute will receive the exact same arguments as the intercepted methodName. Immediately after methodToExecute has completed, methodName will then be executed. When attaching an intercept filter, the methodToExecute method will receive the exact same arguments as the intercepted methodName passed by reference (maybe). It can then modify the arguments if required. When attaching an intercept after a method call, the methodToExecute will receive the exact same arguments as the intercepted methodName in addition to the return value of methodName. ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/bug.php?id=53705&edit=1
