Doctrine Common
  1. Doctrine Common
  2. DCOM-41

Make annotation parser a bit cleverer

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 2.0.2
    • Component/s: None
    • Labels:
      None

      Description

      From an initial look that I had at the annotation parser, it simply search for anything starting with an "@" somewhere in the doc comment and assumes that it is an annotation. Now, if someone uses the @ somewhere in his doc comment but not as an annotation, the parser breaks.

      An example for this can be found in the Doctrine code base, the following comment will result in a parse error:

          /**
           * Annotation     ::= "@" AnnotationName ["(" [Values] ")"]
           * AnnotationName ::= QualifiedName | SimpleName | AliasedName
           * QualifiedName  ::= NameSpacePart "\" {NameSpacePart "\"}* SimpleName
           * AliasedName    ::= Alias ":" SimpleName
           * NameSpacePart  ::= identifier
           * SimpleName     ::= identifier
           * Alias          ::= identifier
           *
           * @return mixed False if it is not a valid annotation.
           */
      

      Obviously the first @ is not used to refer to an annotation here. I think it makes sense to allow new annotations only to start at a new line, what do you think?

        Activity

        Johannes Schmitt created issue -
        Benjamin Eberlei made changes -
        Field Original Value New Value
        Description From an initial look that I had at the annotation parser, it simply search for anything starting with an "@" somewhere in the doc comment and assumes that it is an annotation. Now, if someone uses the @ somewhere in his doc comment but not as an annotation, the parser breaks.

        An example for this can be found in the Doctrine code base, the following comment will result in a parse error:

            /**
             * Annotation ::= "@" AnnotationName ["(" [Values] ")"]
             * AnnotationName ::= QualifiedName | SimpleName | AliasedName
             * QualifiedName ::= NameSpacePart "\" {NameSpacePart "\"}* SimpleName
             * AliasedName ::= Alias ":" SimpleName
             * NameSpacePart ::= identifier
             * SimpleName ::= identifier
             * Alias ::= identifier
             *
             * @return mixed False if it is not a valid annotation.
             */

        Obviously the first @ is not used to refer to an annotation here. I think it makes sense to allow new annotations only to start at a new line, what do you think?
        From an initial look that I had at the annotation parser, it simply search for anything starting with an "@" somewhere in the doc comment and assumes that it is an annotation. Now, if someone uses the @ somewhere in his doc comment but not as an annotation, the parser breaks.

        An example for this can be found in the Doctrine code base, the following comment will result in a parse error:

        {code}
            /**
             * Annotation ::= "@" AnnotationName ["(" [Values] ")"]
             * AnnotationName ::= QualifiedName | SimpleName | AliasedName
             * QualifiedName ::= NameSpacePart "\" {NameSpacePart "\"}* SimpleName
             * AliasedName ::= Alias ":" SimpleName
             * NameSpacePart ::= identifier
             * SimpleName ::= identifier
             * Alias ::= identifier
             *
             * @return mixed False if it is not a valid annotation.
             */
        {code}

        Obviously the first @ is not used to refer to an annotation here. I think it makes sense to allow new annotations only to start at a new line, what do you think?
        Benjamin Eberlei made changes -
        Status Open [ 1 ] Resolved [ 5 ]
        Fix Version/s 2.0.2 [ 10121 ]
        Resolution Fixed [ 1 ]
        Benjamin Eberlei made changes -
        Workflow jira [ 12463 ] jira-feedback2 [ 17888 ]
        Benjamin Eberlei made changes -
        Workflow jira-feedback2 [ 17888 ] jira-feedback3 [ 19851 ]

          People

          • Assignee:
            Benjamin Eberlei
            Reporter:
            Johannes Schmitt
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: