DDC-78: Add Context Name to AnnotationsParser which is printed on Syntax Errors #94

Closed
opened 2026-01-22 12:26:49 +01:00 by admin · 4 comments
Owner

Originally created by @doctrinebot on GitHub (Oct 30, 2009).

Originally assigned to: @beberlei on GitHub.

Jira issue originally created by user @beberlei:

Currently its pretty hard to find out where exactly an error occured when an AnnotationsParser Syntax Error occurs.

My Proposal would be to extend \Doctrine\Common\Annotations\Parser:

public function parse($docBlockString, $contextName="")
{
    $this->contextName = $contextName;
    //...
}

private function syntaxError($expected, $token = null)
{
    // ...
   if(strlen($this->contextName)) {
        $message .= " in context '".$this->contextName."'";
    }
}

This way in the AnnotationsDriver you could add the contexts:

"Class Foo"
"Property Foo::$bar"

This would be an enourmuous help with finding syntax errors when you have lots of different annotated docblocks that are parsed.

Originally created by @doctrinebot on GitHub (Oct 30, 2009). Originally assigned to: @beberlei on GitHub. Jira issue originally created by user @beberlei: Currently its pretty hard to find out where exactly an error occured when an AnnotationsParser Syntax Error occurs. My Proposal would be to extend \Doctrine\Common\Annotations\Parser: ``` public function parse($docBlockString, $contextName="") { $this->contextName = $contextName; //... } private function syntaxError($expected, $token = null) { // ... if(strlen($this->contextName)) { $message .= " in context '".$this->contextName."'"; } } ``` This way in the AnnotationsDriver you could add the contexts: "Class Foo" "Property Foo::$bar" This would be an enourmuous help with finding syntax errors when you have lots of different annotated docblocks that are parsed.
admin added the Improvement label 2026-01-22 12:26:49 +01:00
admin closed this issue 2026-01-22 12:26:50 +01:00
Author
Owner

@doctrinebot commented on GitHub (Oct 30, 2009):

Comment created by romanb:

Sounds very useful to me. If you want you can implement that. Just make sure the context name is cleaned up properly so that no unwanted side-effects occur which could probably result in syntax errors with a wrong context name which would be extremely confusing.

@doctrinebot commented on GitHub (Oct 30, 2009): Comment created by romanb: Sounds very useful to me. If you want you can implement that. Just make sure the context name is cleaned up properly so that no unwanted side-effects occur which could probably result in syntax errors with a wrong context name which would be extremely confusing.
Author
Owner

@doctrinebot commented on GitHub (Oct 30, 2009):

Comment created by romanb:

(Btw. you are in the JIRA developers group now. Welcome! :)

@doctrinebot commented on GitHub (Oct 30, 2009): Comment created by romanb: (Btw. you are in the JIRA developers group now. Welcome! :)
Author
Owner

@doctrinebot commented on GitHub (Oct 30, 2009):

Comment created by @beberlei:

Fixed

@doctrinebot commented on GitHub (Oct 30, 2009): Comment created by @beberlei: Fixed
Author
Owner

@doctrinebot commented on GitHub (Oct 30, 2009):

Issue was closed with resolution "Fixed"

@doctrinebot commented on GitHub (Oct 30, 2009): Issue was closed with resolution "Fixed"
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#94