Bug #51489

Doctrine\Common\Annotations\AnnotationException thrown in file AnnotationException.php

Added by Christian Loock almost 2 years ago. Updated over 1 year ago.

Status:New Start date:2013-08-29
Priority:-- undefined -- Due date:
Assigned To:- % Done:

0%

Category:Annotations
Target version:-
PHP Version:5.4 Complexity:
Has patch:No Affected Flow version:Flow 2.0.0

Description

For some reason, the Annotation Parser does not recognize My Class being annotated as being an Annotation.

I tracked the issue down to the DocParser Class. Which uses PHPs \ReflectionClass->getDocComment and looks for @Annotation.

Now, the fun thing is, that the getDocComment method, only returns the actual comment, but strips all Annotations:

Here is what my DocBlock looks like:

...

/** * This annotations describes wether an action is part of a Tab Group, * which then will be displayed together with other * Actions of other controllers in a tabbed view in the admin backend * * @Annotation * @author Christian Loock <> * @Target({"METHOD"})
*/
class TabGroup {

..

And here is, what getDocComment returns:

string '/** * This annotations describes wether an action is part of a Tab Group, * which then will be displayed together with other * Actions of other controllers in a tabbed view in the admin backend
*/' (length=200)

Since this seems to be a Bug in a PHP function, you might consider not using it at this point, and use your own parser, to retrieve docblocks.

[Semantical Error] The class "VKF\Admin\Annotations\TabGroup" is not annotated with @Annotation. Are you sure this class can be used as annotation? If so, then you need to add @Annotation to the class doc comment of "VKF\Admin\Annotations\TabGroup". If it is indeed no annotation, then you need to add @IgnoreAnnotation("Admin\TabGroup") to the class doc comment of method VKF\Admin\Controller\CustomerController_Original::editAction().
21 Doctrine\Common\Annotations\AnnotationException::semanticalError("The class "VKF\Admin\Annotations\TabGroup" is not …troller\CustomerController_Original::editAction().")

20 Doctrine\Common\Annotations\DocParser::Annotation()

19 Doctrine\Common\Annotations\DocParser::Annotations()

18 Doctrine\Common\Annotations\DocParser::parse("/**⏎ * @Admin\TabGroup("customerEdit")⏎ * …\VKF\Admin\Domain\Model\Customer $customer⏎ */", "method VKF\Admin\Controller\CustomerController_Original::editAction()")

17 Doctrine\Common\Annotations\AnnotationReader::getMethodAnnotations(TYPO3\Flow\Reflection\MethodReflection)

16 TYPO3\Flow\Reflection\ReflectionService::getMethodAnnotations("VKF\Admin\Controller\CustomerController", "editAction", "TYPO3\Flow\Annotations\ValidationGroups")

15 TYPO3\Flow\Reflection\ReflectionService::getMethodAnnotation("VKF\Admin\Controller\CustomerController", "editAction", "TYPO3\Flow\Annotations\ValidationGroups")

14 TYPO3\Flow\Mvc\Controller\ActionController_Original::getActionValidationGroups(TYPO3\Flow\Object\ObjectManager)

13 TYPO3\Flow\Mvc\Controller\ActionController_Original::initializeActionMethodValidators()

12 TYPO3\Flow\Mvc\Controller\ActionController_Original::processRequest(TYPO3\Flow\Mvc\ActionRequest, TYPO3\Flow\Http\Response)

11 TYPO3\Flow\Mvc\Dispatcher_Original::dispatch(TYPO3\Flow\Mvc\ActionRequest, TYPO3\Flow\Http\Response)

10 TYPO3\Flow\Mvc\Dispatcher::dispatch(TYPO3\Flow\Mvc\ActionRequest, TYPO3\Flow\Http\Response)

9 call_user_func_array(array|2|, array|2|)

8 TYPO3\Flow\Mvc\Dispatcher::Flow_Aop_Proxy_invokeJoinPoint(TYPO3\Flow\Aop\JoinPoint)

7 TYPO3\Flow\Aop\Advice\AdviceChain::proceed(TYPO3\Flow\Aop\JoinPoint)

6 TYPO3\Flow\Security\Aspect\RequestDispatchingAspect_Original::blockIllegalRequestsAndForwardToAuthenticationEntryPoints(TYPO3\Flow\Aop\JoinPoint)

5 TYPO3\Flow\Aop\Advice\AroundAdvice::invoke(TYPO3\Flow\Aop\JoinPoint)

4 TYPO3\Flow\Aop\Advice\AdviceChain::proceed(TYPO3\Flow\Aop\JoinPoint)

3 TYPO3\Flow\Mvc\Dispatcher::dispatch(TYPO3\Flow\Mvc\ActionRequest, TYPO3\Flow\Http\Response)

2 TYPO3\Flow\Http\RequestHandler::handleRequest()

1 TYPO3\Flow\Core\Bootstrap::run()

Please include more helpful information!

History

#1 Updated by Christian Loock almost 2 years ago

If I change the docBlock like this for example:

/** * This annotations describes wether an action is part of @Annotation Tab Group, * * which then will be displayed together with other @Target("METHOD") * Actions of other controllers in a tabbed view in the admin backend * * @Annotation *
*/

The result looks like this:

/** * This annotations describes wether an action is part of @Annotation Tab Group, * * which then will be displayed together with other @Target("METHOD") * Actions of other controllers in a tabbed view in the admin backend
*/

For some reason, it does not like Annotations after the comment....

#2 Updated by Christian Loock almost 2 years ago

So I managed to figure out what the problem was.

My Annotation Class was not marked as final.

But still I dont really understand why this needs to be, in order to not strip the annotations from the docblock.

#3 Updated by Aimo Künkel over 1 year ago

I had the same issue.
It appeared ONLY if added properties to the annotation.
After marking the annotation class as final, i could add properties safely.
Also PHP 5.4 here.

Also available in: Atom PDF