Skip to content
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

Don't work extend compiled parent #125

Closed
4n70w4 opened this issue Mar 22, 2020 · 4 comments · Fixed by #181
Closed

Don't work extend compiled parent #125

4n70w4 opened this issue Mar 22, 2020 · 4 comments · Fixed by #181

Comments

@4n70w4
Copy link

4n70w4 commented Mar 22, 2020

Sources:

class MetaCrawlerService extends CrawlerService

CrawlerService and MetaCrawlerService have pointcuts. But after compiling gets:

class MetaCrawlerService_KGlnUTY extends MetaCrawlerService implements WeavedInterface
abstract class CrawlerService_NXUWZ0A extends CrawlerService implements WeavedInterface

I expected that MetaCrawlerService_KGlnUTY will extend CrawlerService_NXUWZ0A or something similar.

Workaround:

  • copy MetaCrawlerService as is MetaCrawlerService_XXX
  • replace in MetaCrawlerService_XXX extends CrawlerService to CrawlerService_NXUWZ0A
  • replace in MetaCrawlerService_KGlnUTY extends MetaCrawlerService to MetaCrawlerService_XXX
  • in all methods of CrawlerService_NXUWZ0A replace
        if (!$this->isAspect) {
            $this->isAspect = true;
            call_user_func_array([$this, 'parent::' . __FUNCTION__], func_get_args());
            return;
        }

to

        if (!$this->isAspect) {
            $this->isAspect = true;

            $class = (new \ReflectionObject($this))->getParentClass();

            $rc1 = new \ReflectionClass($class->name);

            do {
                $method = new \ReflectionMethod($rc1->getParentClass()->name, __FUNCTION__);
                $rc1 = new \ReflectionClass($method->class);
            } while($rc1->implementsInterface(WeavedInterface::class) );

            $method = new \ReflectionMethod($rc1->name, __FUNCTION__);
            $method->invokeArgs($this, func_get_args());
            
            return;
        }

Without this gets exception:

Symfony\Component\Debug\Exception\FatalThrowableError  : Maximum function nesting level of '256' reached, aborting!

  at /var/www/app/vendor/ray/aop/src/ReflectiveMethodInvocation.php:110
    106|     {
    107|         if ($this->interceptors === [] && \is_callable($this->callable)) {
    108|             return call_user_func_array($this->callable, (array) $this->arguments);
    109|         }
  > 110|         $interceptor = array_shift($this->interceptors);
    111|         if ($interceptor instanceof MethodInterceptor) {
    112|             return $interceptor->invoke($this);
    113|         }
    114|
@koriym
Copy link
Member

koriym commented Mar 24, 2020

@4n70w4 Thanks for the reporting issue.
Would you mind create the unit test?

@4n70w4
Copy link
Author

4n70w4 commented Mar 26, 2020

@koriym I do not know how to do it((

@koriym
Copy link
Member

koriym commented Mar 26, 2020

@4n70w4 I see.

@koriym
Copy link
Member

koriym commented Jan 28, 2022

Fixed with #181

Feel free to open if not fixed!

@koriym koriym closed this as completed Jan 28, 2022
@koriym koriym linked a pull request Jan 28, 2022 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants