From:
Operating system: NA
PHP version: Irrelevant
Package: *Programming Data Structures
Bug Type: Feature/Change Request
Bug description:Add AOP & Interception Filter Support
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 bug report at http://bugs.php.net/bug.php?id=53705&edit=1
--
Try a snapshot (PHP 5.2):
http://bugs.php.net/fix.php?id=53705&r=trysnapshot52
Try a snapshot (PHP 5.3):
http://bugs.php.net/fix.php?id=53705&r=trysnapshot53
Try a snapshot (trunk):
http://bugs.php.net/fix.php?id=53705&r=trysnapshottrunk
Fixed in SVN:
http://bugs.php.net/fix.php?id=53705&r=fixed
Fixed in SVN and need be documented:
http://bugs.php.net/fix.php?id=53705&r=needdocs
Fixed in release:
http://bugs.php.net/fix.php?id=53705&r=alreadyfixed
Need backtrace:
http://bugs.php.net/fix.php?id=53705&r=needtrace
Need Reproduce Script:
http://bugs.php.net/fix.php?id=53705&r=needscript
Try newer version:
http://bugs.php.net/fix.php?id=53705&r=oldversion
Not developer issue:
http://bugs.php.net/fix.php?id=53705&r=support
Expected behavior:
http://bugs.php.net/fix.php?id=53705&r=notwrong
Not enough info:
http://bugs.php.net/fix.php?id=53705&r=notenoughinfo
Submitted twice:
http://bugs.php.net/fix.php?id=53705&r=submittedtwice
register_globals:
http://bugs.php.net/fix.php?id=53705&r=globals
PHP 4 support discontinued: http://bugs.php.net/fix.php?id=53705&r=php4
Daylight Savings: http://bugs.php.net/fix.php?id=53705&r=dst
IIS Stability:
http://bugs.php.net/fix.php?id=53705&r=isapi
Install GNU Sed:
http://bugs.php.net/fix.php?id=53705&r=gnused
Floating point limitations:
http://bugs.php.net/fix.php?id=53705&r=float
No Zend Extensions:
http://bugs.php.net/fix.php?id=53705&r=nozend
MySQL Configuration Error:
http://bugs.php.net/fix.php?id=53705&r=mysqlcfg