New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ISSUE, Calling a exteded function from parent class, doesn't work. #131

Closed
eriknyk opened this Issue Feb 12, 2014 · 4 comments

Comments

2 participants
@eriknyk

eriknyk commented Feb 12, 2014

Hi, If I have a class

class Greeting
{
    public hello($name)
    {
        echo "hello $name";
    }
}

And I extend this class

class Example extends Greeting
{
}

And I have defined on my aspect class:

@Before("execution(public Example->*(*))")

And I execute a Example instance.

$e = new Example();
$e->hello("erik");

I doesn't work, the aspect class is not matching the class Example->*.

The unique way to do this works, was adding a method calling the parent class in Example class, so:

class Example extends Greeting
{
    public hello($name)
    {
        parent::hello($name);
    }
}

But it really doesn't a solution, because the idea of extending classes is do not repeat code.
Can you tell if it fixable?

Best Regards.

@lisachenko

This comment has been minimized.

Show comment
Hide comment
@lisachenko

lisachenko Feb 13, 2014

Member

Hi, Erik!

Yeap, this issue is one of the known limitation of framework. During the class loading process I don't know information about parent class, because it's not loaded into memory, so I can not override parent method in the child with custom logic. AOP intercepts only concrete methods in the concrete class and can not check methods in extending classes.

However, it will be possible in the future to recursively load classes and interfaces before PHP to build an hierarchy, but I don't want to implement this logic right now, because it can break a lot of things.

Member

lisachenko commented Feb 13, 2014

Hi, Erik!

Yeap, this issue is one of the known limitation of framework. During the class loading process I don't know information about parent class, because it's not loaded into memory, so I can not override parent method in the child with custom logic. AOP intercepts only concrete methods in the concrete class and can not check methods in extending classes.

However, it will be possible in the future to recursively load classes and interfaces before PHP to build an hierarchy, but I don't want to implement this logic right now, because it can break a lot of things.

@eriknyk

This comment has been minimized.

Show comment
Hide comment
@eriknyk

eriknyk Feb 13, 2014

It would be more usable your framework, because extensive projects have a lot of extending classes, that is my case,.. I can't use go-aop-php without this capability,..
I think that getting all extending methods, functions and properties recursively should works..
Well, I've waiting for news,..
Thanks a lot for your response.

Best Regards.

eriknyk commented Feb 13, 2014

It would be more usable your framework, because extensive projects have a lot of extending classes, that is my case,.. I can't use go-aop-php without this capability,..
I think that getting all extending methods, functions and properties recursively should works..
Well, I've waiting for news,..
Thanks a lot for your response.

Best Regards.

lisachenko added a commit that referenced this issue Apr 30, 2014

Trigger recursive loading of classes to build a correct hierarchy and…
… to have an access to correct token reflection data, related to #131

lisachenko added a commit that referenced this issue Apr 30, 2014

@lisachenko

This comment has been minimized.

Show comment
Hide comment
@lisachenko

lisachenko Apr 30, 2014

Member

@eriknyk you could try to use feature/static-inheritance branch, it should handle inheritance now )

Member

lisachenko commented Apr 30, 2014

@eriknyk you could try to use feature/static-inheritance branch, it should handle inheritance now )

@lisachenko

This comment has been minimized.

Show comment
Hide comment
@lisachenko

lisachenko May 24, 2014

Member

Resolved by #150

Member

lisachenko commented May 24, 2014

Resolved by #150

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment