aop-php / aop Goto Github PK
View Code? Open in Web Editor NEWAOP in PHP
License: Other
AOP in PHP
License: Other
Mon\Plugin\Config::get() // work
\Mon\Plugin\Config::get() // Doesn't work
I'm adding
aop_add_before('eio_*', 'got_eio_call');
I got the fatal :
Fatal error: You must specify a class and a property name in ....
Hi,
I'm in a weird situation.
AOP installed successfully. I can see it in phpinfo()
.
When i'm trying the aop_add_before example on the wiki, i get do my best stuff !
instead of I was called before doing stuff...do my best stuff !
What the problem could be?
I would like to be able to declare more than one Pointcut expression for an advice.
I have seen the boolean operators && and || used in the comments on the following issue, but have not been able to use them within my own expressions. They are not shown in the documentation, and I have not been able to find an existing unit test for them.
Are they actually supported?
Thank you.
Being used to the syntax of FLOW3's pointcut expressions, I'd be missing some of that with this extension. See http://flow3.typo3.org/documentation/guide/partiii/aspectorientedprogramming.html#pointcuts for the supported designators and syntax.
What is your take on keeping it simple vs. adding such features?
Currently, master does not compile against php 5.5:
(master) ~/Projects/AOP$ make
/bin/sh /Users/ralphschindler/Projects/AOP/libtool --mode=compile cc -I. -I/Users/ralphschindler/Projects/AOP -DPHP_ATOM_INC -I/Users/ralphschindler/Projects/AOP/include -I/Users/ralphschindler/Projects/AOP/main -I/Users/ralphschindler/Projects/AOP -I/Users/ralphschindler/.php/5.5.0/include/php -I/Users/ralphschindler/.php/5.5.0/include/php/main -I/Users/ralphschindler/.php/5.5.0/include/php/TSRM -I/Users/ralphschindler/.php/5.5.0/include/php/Zend -I/Users/ralphschindler/.php/5.5.0/include/php/ext -I/Users/ralphschindler/.php/5.5.0/include/php/ext/date/lib -DHAVE_CONFIG_H -g -O2 -c /Users/ralphschindler/Projects/AOP/aop.c -o aop.lo
mkdir .libs
cc -I. -I/Users/ralphschindler/Projects/AOP -DPHP_ATOM_INC -I/Users/ralphschindler/Projects/AOP/include -I/Users/ralphschindler/Projects/AOP/main -I/Users/ralphschindler/Projects/AOP -I/Users/ralphschindler/.php/5.5.0/include/php -I/Users/ralphschindler/.php/5.5.0/include/php/main -I/Users/ralphschindler/.php/5.5.0/include/php/TSRM -I/Users/ralphschindler/.php/5.5.0/include/php/Zend -I/Users/ralphschindler/.php/5.5.0/include/php/ext -I/Users/ralphschindler/.php/5.5.0/include/php/ext/date/lib -DHAVE_CONFIG_H -g -O2 -c /Users/ralphschindler/Projects/AOP/aop.c -fno-common -DPIC -o .libs/aop.o
/Users/ralphschindler/Projects/AOP/aop.c:645:35: warning: incompatible pointer types assigning to 'zval **(*)(zval *, zval *, const zend_literal *)' from
'zend_object_get_property_ptr_ptr_t' (aka 'zval **(*)(zval *, zval *, int, const struct _zend_literal *)') [-Wincompatible-pointer-types]
zend_std_get_property_ptr_ptr = std_object_handlers.get_property_ptr_ptr;
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/ralphschindler/Projects/AOP/aop.c:646:46: warning: incompatible pointer types assigning to 'zend_object_get_property_ptr_ptr_t' (aka 'zval **(*)(zval *, zval *, int, const struct
_zend_literal *)') from 'zval **(zval *, zval *, const zend_literal *)' [-Wincompatible-pointer-types]
std_object_handlers.get_property_ptr_ptr = zend_std_get_property_ptr_ptr_overload;
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/ralphschindler/Projects/AOP/aop.c:649:19: error: non-object type 'void (zend_op_array *)' is not assignable
zend_execute = aop_execute;
~~~~~~~~~~~~ ^
/Users/ralphschindler/Projects/AOP/aop.c:1020:81: error: no member named 'Ts' in 'struct _zend_execute_data'
to_return_ptr_ptr = &(*(temp_variable *)((char *) current_execute_data->Ts + current_execute_data->opline->result.var)).var.ptr;
~~~~~~~~~~~~~~~~~~~~ ^
/Users/ralphschindler/Projects/AOP/aop.c:1106:37: warning: implicit declaration of function 'zend_vm_stack_push_nocheck' is invalid in C99 [-Wimplicit-function-declaration]
zend_vm_stack_push_nocheck((void *) (zend_uintptr_t)i TSRMLS_CC);
^
/Users/ralphschindler/Projects/AOP/aop.c:1107:74: error: too few arguments to function call, expected 1, have 0
zend_vm_stack_clear_multiple(TSRMLS_C);
~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^
/Users/ralphschindler/.php/5.5.0/include/php/Zend/zend_execute.h:290:1: note: 'zend_vm_stack_clear_multiple' declared here
static zend_always_inline void zend_vm_stack_clear_multiple(int nested TSRMLS_DC)
^
/Users/ralphschindler/Projects/AOP/aop.c:1245:50: error: too few arguments to function call, expected 1, have 0
zend_vm_stack_clear_multiple(TSRMLS_C);
~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^
/Users/ralphschindler/.php/5.5.0/include/php/Zend/zend_execute.h:290:1: note: 'zend_vm_stack_clear_multiple' declared here
static zend_always_inline void zend_vm_stack_clear_multiple(int nested TSRMLS_DC)
^
/Users/ralphschindler/Projects/AOP/aop.c:1403:23: error: non-object type 'void (zend_op_array *)' is not assignable
zend_execute = _zend_execute;
~~~~~~~~~~~~ ^
3 warnings and 5 errors generated.
make: *** [aop.lo] Error 1
In the introduction, it is not clear where the AOP code should be saved. Will it be in the class file? Thanks!
Introductions (see http://flow3.typo3.org/documentation/guide/partiii/aspectorientedprogramming.html#introductions) are a powerful feature - how is your opinion about that?
i created a test:
https://github.com/hemon/phpio/blob/master/test/redis2.php
class(myredis) is a wrapper class for redis, it has a margic method __call() to call real method defined in class(redis);
WHEN:
It would be nice to be able to declare advice only after a method returns normally, using aop_add_afterreturning
. The existing aop_add_after()
would be a "superset" of this, so to speak… See http://flow3.typo3.org/documentation/guide/partiii/aspectorientedprogramming.html#after-returning-advice for the FLOW3 documentation on that feature.
This crashes with "Too many level of nested advices" :
class MyClass {
public $property;
}
function defaultGetter(AopJoinpoint $joinpoint)
{
$var = $joinpoint->getPropertyName();
$object = $joinpoint->getObject();
if (!isset($object->$var)) {
$object->$var = "default value";
}
return $object->$var;
}
aop_add_around("read MyClass->property", "defaultGetter");
$myObject = new MyClass();
echo $myObject->property;
Thanks for thinking about this kind of enhancement.
For all aop_add_around
the callback parameter wait a zval (z
) it's should be directly a calllback (f
)
f - function or array containing php method call info (returned as zend_fcall_info and zend_fcall_info_cache)
But something wrong in
zend_call_function
the callack is transformed to an emptyarray
PHP_FUNCTION(aop_add_before)
{
char *selector;
int selector_len;
zend_fcall_info fci;
zend_fcall_info_cache fcic;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sf", &selector, &selector_len, &fci, &fcic) == FAILURE) {
return;
}
add_pointcut(fci, fcic, selector, selector_len, AOP_KIND_BEFORE TSRMLS_CC);
}
static void add_pointcut (zend_fcall_info fci, zend_fcall_info_cache fcic, char *selector, int selector_len, int type TSRMLS_DC) {
pointcut *pc;
int count;
aop_g(count_pcs)++;
count=aop_g(count_pcs)-1;
if (aop_g(count_pcs)==1) {
aop_g(pcs) = emalloc(sizeof(pointcut *));
} else {
aop_g(pcs) = erealloc(aop_g(pcs),aop_g(count_pcs)*sizeof(pointcut *));
}
pc = emalloc(sizeof(pointcut));
pc->selector = selector;
pc->fci = fci;
pc->fcic = fcic;
pc->kind_of_advice = type;
parse_pointcut(&pc);
aop_g(pcs)[count] = pc;
}
Hi all,
First off, I'm loving this extension!
I'm not sure if this is currently supported but shouldn't this work:
My\Namespace\Path\*->*()
or My\Namespace\Path\*->set*()
It doesn't appear this is directly referenced in the docs but I assumed it was possible since this works My\Namespace\Path\MyClass->*()
.
When using aop_add_around() and you omitt the call to $joinpoint->-process(), the PHP process ends without any response to the browser. It should maybe raise an exception or warning or return null so the execution can continue.
This issue happened on Windows 7 with PHP 5.4
the tgz package for release 0.2.0 is empty. therefore, this release cannot be installed using pyrus.
I think it's too bad to using a class form the constants registration
use AOP_AROUND
or AOP\AROUND
() all functions
*-> all properties of all objects in the root namespace
->() all methods of all objects in the root namespace
AOP_KIND_BEFORE_METHOD => only object's methods, not functions
AOP_KIND_BEFORE_FUNCTION => only functions
getTriggeringMethodName => only method name, error if in function or property
getTriggeringFunctionName => only method name, error if in function or property
The 'configure' script does not check for the presence of the pcre library.
First, thanks for your implementation of AOP in PHP. Hope this will live and grow (more users, and as simple as it is to use now).
My little bug report however :
It does not work when using extension Zend Debugger.
My testing environment is :
Once ou call an URL with the debugger's parameters, that activate it (automatic when from Eclipse), it debugs well, but aop_add_* calls don't crash, but don't do anything. Advices are then not called at all.
That's not a problem for me : I go to Xdebug, as your extension works very well with it.
Thanks again.
Bonne journée.
I see this in your documentation :
$assigned = $aop_tjp->getAssignedValue();
if ($assigned !== 'PHP') {
$assigned .= ' and PHP';
}
$assigned gets a reference to the assigned value, so if we modify it, it alters the assigned value. Cool. (note : it bugs with my current 0.2.0 version of AOP-PHP ! your sample at 2.1.7 of your documentation don't work, $developper->preferences is still "Java". I'd prefer use aop_add_after() but it stills don't work but my turnaround bellow)
But how can I do that stuff : ?
$assigned = $aop_tjp->getAssignedValue();
$assigned = 'PHP';
If I do that assigned value is not changed : in fact $assigned becomes a new string containing "PHP" and is not the reference to the assigned value anymore.
Today's turnaround :
static $dont_recurse = false;
if (!$done_recurse) {
$assigned = $aop_tjp->getAssignedValue();
$object = $aop_tip->getObject();
$property = $aop_top->getPropertyName();
$dont_recurse = true;
$object->$property = 'PHP';
$dont_recurse = false;
}
Another way to do that ?
If not, suggested improvement on AOP-PHP :
$aop_tip->setAssignedValue('PHP');
Hi,
I want to read object property in AOP but have Fatal error
PHP Fatal error: Too many level of nested advices. Are there any recursive call ? in /var/www/test/test.php on line 12
How to properly read property in object using AOP ?
I need this to build inteligent ORM.
Not sure if you should consider this as a bug.
As a reminder, I added a test (tests/keywords/001.phpt) in ae488af
Example code:
class Form {
function render(array $aParams = []) {
return 'foo';
}
}
class Csrf {
function aroundFormRender() {
#echo 'bar';
throw new Exception('bar');
}
}
$oForm = new Form();
$oCsrf = new Csrf();
aop_add_around('Form->render()', array($oCsrf, 'aroundFormRender'));
echo $oForm->render();
It would be nice to be able to declare advice only after a method throws an exception, using aop_add_afterthrowing
. The existing aop_add_after()
would be a "superset" of this, so to speak… See http://flow3.typo3.org/documentation/guide/partiii/aspectorientedprogramming.html#after-throwing-advice for the FLOW3 documentation on that feature.
Just installed aop-beta via pecl. While checking to make sure the module is loaded correctly I see the below errors. I'm unclear on how this error occurs but I figured I'd report it anyhow.
Potentially noteworthy: PHP was compiled from source with --enable-debug and --enable-maintainer-zts
php -i |grep -i aop
aop
[Wed Nov 21 16:13:09 2012] Script: '-'
/tmp/pear/temp/AOP/aop.c(140) : Freeing 0x7F5B74F8BBD8 (8192 bytes), script=-
/software/php-5.4.8/Zend/zend_alloc.c(2529) : Actual location (location was relayed)
[Wed Nov 21 16:13:09 2012] Script: '-'
/tmp/pear/temp/AOP/aop.c(145) : Freeing 0x7F5B74F91CF8 (72 bytes), script=-
=== Total 2 memory leaks detected ===
It would be nice to be able to remove pointcuts.
This could for example be interesting for unit tests, but also for example when you want to debug certain code temporarily and then remove the callbacks to avoid any performance loss.
Hi.
I installed the version 0.2.0 of aop extension.
I run some phpunit test suite and the process silently crashes at random tests.
If I run the tests one at time, the tests run fine.
No error is reported in php error log.
It took me some time until I figured out what could be passed to the aop_add_before
method.
For example:
aop_add_before('*', function() { })
causes a segmentation fault
aop_add_before('*', 'test')
causes a "Bad Params" error, but does not really give any indication of what is wrong
Maybe we can add something more specific for these cases.
I'm not a Bison/re2c expert but the pdo_sql_parser
using it, maybe we can do the same thing
When accessing an undefined property I would still expect the default PHP error message, sth like Undefined property: A\B\C::$d
.
Right now, however, I get a segmentation fault if there are any advices registered.
I've been looking through the docs and issues, but I couldn't find information (apart from some property metrics) about the performance impact this extension has.
Have you done any benchmarks?
<?php
class AdminDeniedException extends Exception {
}
function doAdminStuff(){
echo "do admin stuff\n";
}
function adviceForDoAdmin(){
global $role;
if ( $role != 'admin' ) {
throw new AdminDeniedException();
}
}
function adviceForException($obj){
$method = $obj->getFunctionName();
try {
$obj->process();
}
catch(AdminDeniedException $e){
echo "no privilige to access $method\n";
}
}
aop_add_before('doAdmin*()' , 'adviceForDoAdmin');
aop_add_around('doAdmin*()', 'adviceForException');
try {
doAdminStuff();
} catch(Exception $e) {
echo "unknown exception";
}
?>
In code above, I want to use aop to manage priviliges and deal with exceptions. but when i put admin advice before exception advice, it will throw a Fata error as follows.
"Fatal error: Problem in AOP Callback in /home/kufazhang/workcode/php-dev/c.php on line 26"
But shouldn't it output "unknow exception"?
I was able to compile version 0.2.0 on Windows 7, with MS Visual C++ 2008 without a hitch, however after trying to upgrade to the latest, I am now running into problems, that seem to have to do with C / C++ strict syntax.
The first line in question occurs here, where a function is called before the variables are declared. It looks like the MS Compiler, is expecting a strict 'C' syntax wherein all variable declarations are required at the beginning of the function or class definition.
Any plans on adapting the library to the MS Compilers?
https://github.com/AOP-PHP/AOP/blob/master/aop.c#L248-L249
Thank you
Here is a stack trace of the error I am encountering:
C:\php-sdk\php53dev\vc9\x86\php-5.3.18-src>nmake
Microsoft (R) Program Maintenance Utility Version 9.00.30729.01
Copyright (C) Microsoft Corporation. All rights reserved.
Recreating build dirs
aop.c
ext\AOP\aop.c(249) : error C2143: syntax error : missing ';' before 'type'
ext\AOP\aop.c(250) : error C2275: 'zval' : illegal use of this type as an expression
c:\php-sdk\php53dev\vc9\x86\php-5.3.18-src\zend\zend.h(286) : see declaration of 'zval'
ext\AOP\aop.c(250) : error C2065: 'aop_object' : undeclared identifier
ext\AOP\aop.c(251) : error C2065: 'i' : undeclared identifier
ext\AOP\aop.c(251) : error C2065: 'i' : undeclared identifier
ext\AOP\aop.c(251) : error C2065: 'i' : undeclared identifier
ext\AOP\aop.c(252) : error C2065: 'i' : undeclared identifier
ext\AOP\aop.c(279) : error C2065: 'aop_object' : undeclared identifier
ext\AOP\aop.c(279) : warning C4047: '=' : 'int' differs in levels of indirection from 'zval '
ext\AOP\aop.c(279) : error C2065: 'aop_object' : undeclared identifier
ext\AOP\aop.c(279) : error C2065: 'aop_object' : undeclared identifier
ext\AOP\aop.c(279) : error C2223: left of '->refcount__gc' must point to struct/union
ext\AOP\aop.c(279) : error C2065: 'aop_object' : undeclared identifier
ext\AOP\aop.c(279) : error C2223: left of '->is_ref__gc' must point to struct/union
ext\AOP\aop.c(280) : error C2065: 'aop_object' : undeclared identifier
ext\AOP\aop.c(280) : error C2100: illegal indirection
ext\AOP\aop.c(280) : error C2224: left of '.type' must have struct/union type
ext\AOP\aop.c(281) : error C2065: 'aop_object' : undeclared identifier
ext\AOP\aop.c(281) : error C2223: left of '->value' must point to struct/union
ext\AOP\aop.c(282) : error C2065: 'aop_object' : undeclared identifier
ext\AOP\aop.c(282) : warning C4047: '=' : 'zval *' differs in levels of indirection from 'int'
ext\AOP\aop.c(283) : error C2065: 'aop_object' : undeclared identifier
ext\AOP\aop.c(283) : warning C4047: 'function' : 'zval *' differs in levels of indirection from 'int'
ext\AOP\aop.c(283) : warning C4024: 'zval_addref_p' : different types for formal and actual parameter 1
ext\AOP\aop.c(284) : error C2065: 'aop_object' : undeclared identifier
ext\AOP\aop.c(284) : warning C4047: 'return' : 'zval *' differs in levels of indirection from 'int'
ext\AOP\aop.c(314) : error C2143: syntax error : missing ';' before 'type'
ext\AOP\aop.c(315) : error C2275: 'pointcut' : illegal use of this type as an expression
c:\php-sdk\php53dev\vc9\x86\php-5.3.18-src\ext\aop\aop.h(96) : see declaration of 'pointcut'
ext\AOP\aop.c(315) : error C2065: 'current_pc' : undeclared identifier
ext\AOP\aop.c(316) : error C2275: 'pointcut' : illegal use of this type as an expression
c:\php-sdk\php53dev\vc9\x86\php-5.3.18-src\ext\aop\aop.h(96) : see declaration of 'pointcut'
ext\AOP\aop.c(316) : error C2065: 'temp' : undeclared identifier
ext\AOP\aop.c(316) : error C2100: illegal indirection
ext\AOP\aop.c(329) : error C2065: 'temp' : undeclared identifier
ext\AOP\aop.c(336) : error C2065: 'current_pc' : undeclared identifier
ext\AOP\aop.c(336) : error C2065: 'temp' : undeclared identifier
ext\AOP\aop.c(336) : error C2100: illegal indirection
ext\AOP\aop.c(339) : error C2065: 'obj' : undeclared identifier
ext\AOP\aop.c(339) : warning C4047: '=' : 'int' differs in levels of indirection from 'AopJoinpoint_object *'
ext\AOP\aop.c(340) : error C2065: 'obj' : undeclared identifier
ext\AOP\aop.c(340) : error C2223: left of '->current_pointcut' must point to struct/union
ext\AOP\aop.c(340) : error C2065: 'current_pc' : undeclared identifier
ext\AOP\aop.c(342) : error C2065: 'obj' : undeclared identifier
ext\AOP\aop.c(342) : error C2223: left of '->pos' must point to struct/union
ext\AOP\aop.c(343) : error C2065: 'obj' : undeclared identifier
ext\AOP\aop.c(343) : error C2223: left of '->advice' must point to struct/union
ext\AOP\aop.c(344) : error C2065: 'obj' : undeclared identifier
ext\AOP\aop.c(344) : error C2223: left of '->kind_of_advice' must point to struct/union
ext\AOP\aop.c(344) : error C2065: 'current_pc' : undeclared identifier
ext\AOP\aop.c(344) : error C2223: left of '->kind_of_advice' must point to struct/union
ext\AOP\aop.c(345) : error C2065: 'obj' : undeclared identifier
ext\AOP\aop.c(345) : error C2223: left of '->object' must point to struct/union
ext\AOP\aop.c(346) : error C2065: 'obj' : undeclared identifier
ext\AOP\aop.c(346) : error C2223: left of '->to_return_ptr_ptr' must point to struct/union
ext\AOP\aop.c(347) : error C2065: 'obj' : undeclared identifier
ext\AOP\aop.c(347) : error C2223: left of '->value' must point to struct/union
ext\AOP\aop.c(348) : error C2065: 'obj' : undeclared identifier
ext\AOP\aop.c(348) : error C2223: left of '->ex' must point to struct/union
ext\AOP\aop.c(349) : error C2065: 'obj' : undeclared identifier
ext\AOP\aop.c(349) : error C2223: left of '->object' must point to struct/union
ext\AOP\aop.c(350) : error C2065: 'obj' : undeclared identifier
ext\AOP\aop.c(350) : error C2223: left of '->scope' must point to struct/union
ext\AOP\aop.c(351) : error C2065: 'obj' : undeclared identifier
ext\AOP\aop.c(351) : error C2223: left of '->called_scope' must point to struct/union
ext\AOP\aop.c(354) : error C2065: 'obj' : undeclared identifier
ext\AOP\aop.c(354) : error C2223: left of '->args' must point to struct/union
ext\AOP\aop.c(356) : error C2065: 'obj' : undeclared identifier
ext\AOP\aop.c(356) : error C2223: left of '->args_overloaded' must point to struct/union
ext\AOP\aop.c(357) : error C2065: 'obj' : undeclared identifier
ext\AOP\aop.c(357) : error C2223: left of '->exception' must point to struct/union
ext\AOP\aop.c(358) : error C2065: 'current_pc' : undeclared identifier
ext\AOP\aop.c(358) : error C2223: left of '->kind_of_advice' must point to struct/union
ext\AOP\aop.c(360) : error C2065: 'current_pc' : undeclared identifier
ext\AOP\aop.c(360) : warning C4047: 'function' : 'pointcut *' differs in levels of indirection from 'int'
ext\AOP\aop.c(360) : warning C4024: 'execute_pointcut' : different types for formal and actual parameter 1
ext\AOP\aop.c(363) : error C2065: 'current_pc' : undeclared identifier
ext\AOP\aop.c(363) : error C2223: left of '->kind_of_advice' must point to struct/union
ext\AOP\aop.c(365) : error C2065: 'current_pc' : undeclared identifier
ext\AOP\aop.c(365) : warning C4047: 'function' : 'pointcut *' differs in levels of indirection from 'int'
ext\AOP\aop.c(365) : warning C4024: 'execute_pointcut' : different types for formal and actual parameter 1
ext\AOP\aop.c(366) : error C2065: 'obj' : undeclared identifier
ext\AOP\aop.c(366) : error C2223: left of '->value' must point to struct/union
ext\AOP\aop.c(367) : error C2065: 'obj' : undeclared identifier
ext\AOP\aop.c(367) : error C2223: left of '->value' must point to struct/union
ext\AOP\aop.c(367) : error C2198: 'zval_addref_p' : too few arguments for call
ext\AOP\aop.c(368) : error C2065: 'obj' : undeclared identifier
ext\AOP\aop.c(368) : error C2223: left of '->value' must point to struct/union
ext\AOP\aop.c(372) : error C2065: 'obj' : undeclared identifier
ext\AOP\aop.c(372) : error C2223: left of '->args_overloaded' must point to struct/union
ext\AOP\aop.c(372) : error C2065: 'obj' : undeclared identifier
ext\AOP\aop.c(372) : error C2223: left of '->args' must point to struct/union
ext\AOP\aop.c(372) : warning C4047: 'function' : 'int' differs in levels of indirection from 'zval *'
ext\AOP\aop.c(372) : warning C4024: '_test_func_pointcut_and_execute' : different types for formal and actual parameter 7
ext\AOP\aop.c(372) : error C2198: '_test_func_pointcut_and_execute' : too few arguments for call
ext\AOP\aop.c(374) : error C2065: 'current_pc' : undeclared identifier
ext\AOP\aop.c(374) : error C2223: left of '->kind_of_advice' must point to struct/union
ext\AOP\aop.c(375) : error C2065: 'current_pc' : undeclared identifier
ext\AOP\aop.c(375) : error C2223: left of '->kind_of_advice' must point to struct/union
ext\AOP\aop.c(377) : error C2065: 'obj' : undeclared identifier
ext\AOP\aop.c(377) : error C2223: left of '->exception' must point to struct/union
ext\AOP\aop.c(379) : error C2065: 'current_pc' : undeclared identifier
ext\AOP\aop.c(379) : warning C4047: 'function' : 'pointcut *' differs in levels of indirection from 'int'
ext\AOP\aop.c(379) : warning C4024: 'execute_pointcut' : different types for formal and actual parameter 1
ext\AOP\aop.c(381) : error C2065: 'obj' : undeclared identifier
ext\AOP\aop.c(381) : error C2223: left of '->value' must point to struct/union
ext\AOP\aop.c(382) : error C2065: 'obj' : undeclared identifier
ext\AOP\aop.c(382) : error C2223: left of '->value' must point to struct/union
ext\AOP\aop.c(382) : error C2198: 'zval_addref_p' : too few arguments for call
ext\AOP\aop.c(383) : error C2065: 'obj' : undeclared identifier
ext\AOP\aop.c(383) : error C2223: left of '->value' must point to struct/union
ext\AOP\aop.c(385) : error C2065: 'current_pc' : undeclared identifier
ext\AOP\aop.c(385) : error C2223: left of '->kind_of_advice' must point to struct/union
ext\AOP\aop.c(386) : error C2065: 'current_pc' : undeclared identifier
ext\AOP\aop.c(386) : warning C4047: 'function' : 'pointcut *' differs in levels of indirection from 'int'
ext\AOP\aop.c(386) : warning C4024: 'execute_pointcut' : different types for formal and actual parameter 1
ext\AOP\aop.c(387) : error C2065: 'obj' : undeclared identifier
ext\AOP\aop.c(387) : error C2223: left of '->value' must point to struct/union
ext\AOP\aop.c(388) : error C2065: 'obj' : undeclared identifier
ext\AOP\aop.c(388) : fatal error C1003: error count exceeds 100; stopping compilation
NMAKE : fatal error U1077: '"C:\Program Files\Microsoft Visual Studio 9.0\VC\Bin\cl.exe"' : return code '0x2'
Stop.
The error:
Fatal error: Call to undefined method AopJoinpoint::getTriggeringObject()...
PHP: 5.4.5
AOP 0.2.0
Update: I've discovered that AopJoinpoint has been refactored so the method is now getPointcut().
not very important but it does not work :
var_dump($jp); // AopJoinPoint
In Chrome / Chromium : Erreur 324 (net::ERR_EMPTY_RESPONSE) : Le serveur a mis fin à la connexion sans envoyer de données.
Would it be possible to have a hook for the construction of an object? I guess it would be possible if an object has a __construct
method, but maybe it is possible to provide a more robust hook.
Out of my depth to fix
Have written a test that fails for me
--TEST--
Try using finfo_open (may cause segmentation fault)
--FILE--
<?php
class mytest {
public function test() {
return finfo_open(FILEINFO_MIME_TYPE);
}
}
$test = new mytest();
$test->test();
echo 'PASS';
?>
--EXPECT--
PASS
It will be nice to have a class for Aop routines, because object oriented style is smarter, allows inheritance and logical composition.
For example:
$aspect = new Aspect(); // <-- Class defined in the extension
$aspect->addBefore('MyServices->doStuff()', $advice); // <-- aop_add_before()
Example of use:
class TestAspect extends Aspect
{
public function aroundStuff(AopJoinPoint $joinpoint)
{
$joinpoint->process();
$returnValue = $joinpoint->getReturnedValue();
$returnValue = str_replace('best', 'very best', $returnValue);
$joinpoint->setReturnedValue($returnValue);
}
public function register()
{
// aop_add_around('MyServices->doStuff()', array($this, 'aroundStuff'));
$this->addAround('MyServices->doStuff()', array($this, 'aroundStuff'));
}
}
$testAspect = new TestAspect();
// Object-oriented style with inheritance and encapsulation:
$testAspect->register();
// Procedural style:
// aop_add_around('MyServices->doStuff()', array($testAspect, 'aroundStuff'));
Dear Gerald and Julien,
I consider your extension very powerful, easy to use and would like to compose it into a real application to watch methods and their input parameters.
Unfortunately the last released version 0.2.2b1 is not stable enough and causes HTTP request abortion in special case.
I found out the bug causing the aborting is fixed in the master version.
The application I currently worked on is a large business web application with important customers (BMW for example), so I cannot afford to use any PHP extension in beta version.
Would you be so kind to share the AOP extension roadmap, please? I would appreciate if you would release a stable version of the extension within few months.
Do not hesitate to contact me directly on [email protected].
I am looking forward to your reply, with best regards,
Marek Sykora, web developer,
Intraworlds GmbH
Release Candidate for version 1
For pointcut expressions that are complex or used often, a named pointcut is very helpful. Here is how FLOW3 does it: http://flow3.typo3.org/documentation/guide/partiii/aspectorientedprogramming.html#pointcuts
new CONST for Method and Function
AOP_KIND_METHOD
AOP_KIND_FUNCTION
Related to #52 in functions, absolute namespaces are not understood by the extension when related to functions
This crashes with a segmentation fault (using AOP-PHP 0.2.0 / PHP 5.4) :
function function1() {
echo "function1 ";
}
function function2() {
echo "function2 ";
}
function advice1() {
echo "advice 1 ";
// the crash happens here, when advice1() is called by the AOP extension
aop_add_before("function2()", "advice2");
echo "done ";
}
function advice2() {
echo "advice 2 ";
echo "done ";
}
aop_add_before("function1()", "advice1");
function1();
function2();
When declaring a pointcut on a method, the advice should not be called for the overriden method of a child class !
But it does.
class Markus
{
function loves() { echo "Markus love cookies "; }
}
class Miky extends Markus
{
function loves() { echo "Miky loves cheesecakes "; }
}
aop_add_before("Markus->loves()", function() { echo "What does Markus love ? "; });
$miky = new Miky();
$miky->loves();
This tells :
What does Markus love ? Miky loves cheesecakes
This should tell, because I never call Markus->loves() :
Miky loves cheesecakes
Must be fixed. Thanks.
I think we should lowercase the aop.so. By (untold ?) convention, extensions libraries seems to be lowercase.
Please have a look to this example.
I want to force the day to begin before the man can wake up.
And I want to force the night to end before the day can begin.
All of this with AOP-PHP of course.
class Night {
public static function end() { echo "the night ends "; }
}
class Day {
public static function begin() { echo "the sun rises "; }
}
class Man {
public function wakeup() { echo "the man wakes up "; }
}
aop_add_before("Day->begin()", array("Night", "end"));
aop_add_before("Man->wakeup()", array("Day", "begin"));
$me = new Man();
$me->wakeup();
But it won't work with current version 0.2.0 (my php is 5.4).
I am waiting for this result :
the night ends the sun rises the man wakes up
the sun rises the man wakes up
Will AOP-PHP allow this ?
First, very useful extension! We can definately use this in Doctrine (optionally) to avoid proxy code generation.
I am not sure if this is in the scope of an AOP extension, but would it be possible to have hooks for property access (read/write) as well? We could use this in Doctrine to implement Change Tracking for objects.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.