Skip to content
This repository has been archived by the owner on Mar 17, 2021. It is now read-only.

"Use" statement for annotation is missing in cache file #41

Open
AliAmjid opened this issue Jul 20, 2019 · 3 comments
Open

"Use" statement for annotation is missing in cache file #41

AliAmjid opened this issue Jul 20, 2019 · 3 comments

Comments

@AliAmjid
Copy link

AliAmjid commented Jul 20, 2019

Im not sure if is this bug or i m just doing things in wrong way.

My problem is this:

	/**
	 * @Aop\Before("methodAnnotatedWith(app\Model\Anotations\Resource)")
	 */
	public function resource(Aop\JoinPoint\BeforeMethod $beforeMethod) {

		$annotations = $this->annotationReader->getMethodAnnotations($beforeMethod->getTargetReflection());
		//Throws Err
		//[Semantical Error] The annotation "@resource" in method presenter::actionDefault() was never imported.
		// Did you maybe forget to add a "use" statement for this annotation?
	}

When i try to get annotation from generated class i get error cause
use namespace\to\Resource statement for annotation is missing in generated presenter

@dakorpar
Copy link
Member

dakorpar commented Aug 1, 2019

@AliAmjid can you provide me sample project so I can take a look into it? thanks

@AliAmjid
Copy link
Author

AliAmjid commented Aug 16, 2019

It's probably the same issue like this: #6

@AliAmjid
Copy link
Author

Issue is in generated class by AOP, it copies annotation of method but it dosent copy "use statement of annotation".

for example like this:

i have a class sth. like this

use App\My\Annotations\myAnotation;
class myService {

	/** @myAnotation(type=delete) */
	protected function deleteResource() {

	}

}

And genereated class by aop will look sth like this

//And this is generated class

//use App\My\Annotations\myAnotation;  <--- this "use" is missing in generated file
class aop_genereated_class_my_service extends myService {

	/** @myAnotation(type=delete) */
	protected function deleteResource() {

	}

}

So in result when i will try read method annotation it would throw error cause of that missing "use.

		$annotations = $this->annotationReader->getMethodAnnotations($beforeMethod->getTargetReflection());

I over-pass this by using full namspace of annotation like this

	/** @App\My\Annotations\myAnootation(type=delete) */

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants