goaop-laravel-bridge icon indicating copy to clipboard operation
goaop-laravel-bridge copied to clipboard

@Declareparents annotation throws UnexpectedValueException

Open Yoshiro-Sasagawa opened this issue 3 years ago • 0 comments

I'm trying to use inter-type declarations with this nice package but I can't make it work and almost gave up unfortunately.

I've read the documentation of original framework at http://go.aopphp.com/docs/pointcuts-and-advices/ then I wrote some codes but I've got UnexpectedValueException like following.

Unexpected token in the TestController before App\Aspect\FooAspect->introduction, defined in projectroot/app/Aspect/FooAspect.php:0. Expected one of: ->, nsSeparator, )

Go\Core\AbstractAspectLoaderExtension::parseTokenStream vendor/goaop/framework/src/Core/AbstractAspectLoaderExtension.php:139

I dig into jakubledl/dissect package that throws actual error and it says "$eof is undefind" but I can't figure out what that means exactly.

Another example like @LoggerInterface annotation works fine as it was documented.

However, does @Declareparents work with laravel ?

My envornment is like

PHP: 7.3.28  
"goaop/framework": "2.3.4",
"goaop/goaop-laravel-bridge": "^1.1.1",
"laravel/framework": "8.0",
"nikic/php-parser": "4.6.0",
"jakubledl/dissect": "v1.0.1"

Aspect

class FooAspect implements Aspect
{
    /**
     * @DeclareParents(value="TestController", interface="FooInterface", defaultImpl="FooImpl")
     * @var null
     */
    protected $introduction = null;
}

Controller

class TestController extends Controller {
	public function index() {
		echo 'foo';
	}
}

Interface

Interface FooInterface {
  public function foo ();
}

Trait

trait FooImpl {
        public function foo() {
                echo 'foo';
        }
}

Yoshiro-Sasagawa avatar May 29 '21 05:05 Yoshiro-Sasagawa