DDC-260: Add additional info to ReflectionException in ClassMetadata #321

Closed
opened 2026-01-22 12:34:48 +01:00 by admin · 6 comments
Owner

Originally created by @doctrinebot on GitHub (Jan 16, 2010).

Jira issue originally created by user shurakai:

I was thinking about adding an additional exception to the ClassMetadata class. For example when using reflection for recieving an attribute and an exception is raised (for example because the attribute does not exist), the debug information could be improved. I thought one could catch the ReflectionException and throw a DoctrineReflectionException or something like that and add some additional information like what the name of the currently processed class is

Originally created by @doctrinebot on GitHub (Jan 16, 2010). Jira issue originally created by user shurakai: I was thinking about adding an additional exception to the ClassMetadata class. For example when using reflection for recieving an attribute and an exception is raised (for example because the attribute does not exist), the debug information could be improved. I thought one could catch the ReflectionException and throw a DoctrineReflectionException or something like that and add some additional information like what the name of the currently processed class is
admin added the Improvement label 2026-01-22 12:34:48 +01:00
admin closed this issue 2026-01-22 12:34:49 +01:00
Author
Owner

@doctrinebot commented on GitHub (Jan 16, 2010):

Comment created by romanb:

I dont think that would be overly useful as the exceptions from php are pretty good. Can you show an example of the error, the message you get and the improved message you would like to get instead?

@doctrinebot commented on GitHub (Jan 16, 2010): Comment created by romanb: I dont think that would be overly useful as the exceptions from php are pretty good. Can you show an example of the error, the message you get and the improved message you would like to get instead?
Author
Owner

@doctrinebot commented on GitHub (Jan 16, 2010):

Comment created by shurakai:

Hi Roman,

i ran the doctrine CLI tool and tried "schema-tool". One of my PHP entities classes hadn't all properties defined in my YAML files (I'm wondering why Doctrine needs to perform Reflection on my PHP classes when converting from YAML...?) and I recieve this error:

{quote} PHP Fatal error: Uncaught exception 'ReflectionException' with message 'Property children does not exist' in /var/workspaces/project/library/Doctrine/ORM/Mapping/ClassMetadata.php:244
Stack trace:
#0 /var/workspaces/project/library/Doctrine/ORM/Mapping/ClassMetadata.php(244): ReflectionClass->getProperty('children')
#1 /var/workspaces/project/library/Doctrine/ORM/Mapping/ClassMetadataInfo.php(1298): Doctrine\ORM\Mapping\ClassMetadata->_storeAssociationMapping(Object(Doctrine\ORM\Mapping\OneToManyMapping))
#2 /var/workspaces/project/library/Doctrine/ORM/Mapping/Driver/YamlDriver.php(266): Doctrine\ORM\Mapping\ClassMetadataInfo->mapOneToMany(Array)
#3 /var/workspaces/project/library/Doctrine/ORM/Mapping/ClassMetadataFactory.php(195): Doctrine\ORM\Mapping\Driver\YamlDriver->loadMetadataForClass('Core\Block\Item...', Object(Doctrine\ORM\Mapping\ClassMetadata))
#4 /var/workspaces/project/library/Doctrine/ORM/Mapping/ClassMetadataFactory.php(111): Doctrine\ORM\Mapping\ClassMetadataFactory->_loadMetadata('Core\Block\Item...')
#5 /va in /var/workspaces/project/library/Doctrine/ORM/Mapping/ClassMetadata.php on line 244
{quote}

The problem here is, that I'm not told in which class the problem occurs because PHP automatically shortens the parameters displayed. Therefore, I need to guess, and thats definitely something I don't want to do.

The errormessage I'd like to see:

. The error occurred in class .

So in this case:

{quote}Property children does not exist. The error occurred in class Core\Block\Item\Panel\AbstractPanel{quote}

@doctrinebot commented on GitHub (Jan 16, 2010): Comment created by shurakai: Hi Roman, i ran the doctrine CLI tool and tried "schema-tool". One of my PHP entities classes hadn't all properties defined in my YAML files (I'm wondering why Doctrine needs to perform Reflection on my PHP classes when converting from YAML...?) and I recieve this error: {quote} PHP Fatal error: Uncaught exception 'ReflectionException' with message 'Property children does not exist' in /var/workspaces/project/library/Doctrine/ORM/Mapping/ClassMetadata.php:244 Stack trace: #0 /var/workspaces/project/library/Doctrine/ORM/Mapping/ClassMetadata.php(244): ReflectionClass->getProperty('children') #1 /var/workspaces/project/library/Doctrine/ORM/Mapping/ClassMetadataInfo.php(1298): Doctrine\ORM\Mapping\ClassMetadata->_storeAssociationMapping(Object(Doctrine\ORM\Mapping\OneToManyMapping)) #2 /var/workspaces/project/library/Doctrine/ORM/Mapping/Driver/YamlDriver.php(266): Doctrine\ORM\Mapping\ClassMetadataInfo->mapOneToMany(Array) #3 /var/workspaces/project/library/Doctrine/ORM/Mapping/ClassMetadataFactory.php(195): Doctrine\ORM\Mapping\Driver\YamlDriver->loadMetadataForClass('Core\Block\Item...', Object(Doctrine\ORM\Mapping\ClassMetadata)) #4 /var/workspaces/project/library/Doctrine/ORM/Mapping/ClassMetadataFactory.php(111): Doctrine\ORM\Mapping\ClassMetadataFactory->_loadMetadata('Core\Block\Item...') #5 /va in /var/workspaces/project/library/Doctrine/ORM/Mapping/ClassMetadata.php on line 244 {quote} The problem here is, that I'm not told in which class the problem occurs because PHP automatically shortens the parameters displayed. Therefore, I need to guess, and thats definitely something I don't want to do. The errormessage I'd like to see: <ReflectionExceptionMessage>. The error occurred in class <namespace><className>. So in this case: {quote}Property children does not exist. The error occurred in class Core\Block\Item\Panel\AbstractPanel{quote}
Author
Owner

@doctrinebot commented on GitHub (Jan 21, 2010):

Comment created by shurakai:

This should fix this issue

@doctrinebot commented on GitHub (Jan 21, 2010): Comment created by shurakai: This should fix this issue
Author
Owner

@doctrinebot commented on GitHub (Jan 21, 2010):

Comment created by @guilhermeblanco:

In r7041 this issue was fixed.

Thanks for the patch!

@doctrinebot commented on GitHub (Jan 21, 2010): Comment created by @guilhermeblanco: In r7041 this issue was fixed. Thanks for the patch!
Author
Owner

@doctrinebot commented on GitHub (Jan 21, 2010):

Issue was closed with resolution "Fixed"

@doctrinebot commented on GitHub (Jan 21, 2010): Issue was closed with resolution "Fixed"
Author
Owner

@doctrinebot commented on GitHub (Dec 13, 2015):

Imported 1 attachments from Jira into https://gist.github.com/9b82263fa4659f96cab3

@doctrinebot commented on GitHub (Dec 13, 2015): Imported 1 attachments from Jira into https://gist.github.com/9b82263fa4659f96cab3 - [10307_Mapping.patch](https://gist.github.com/9b82263fa4659f96cab3#file-10307_Mapping-patch)
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#321