Handle anonymous classes more gracefully#286
Conversation
It does not necessary hold a proxy class.
|
I think you also need to update |
|
|
||
| // Check for namespace alias | ||
| if (strpos($className, ':') !== false) { | ||
| if (! class_exists($className) && strpos($className, ':') !== false) { |
There was a problem hiding this comment.
I would use ! class_exists($className, false), to avoid triggering autoloaders for namespace aliases. Excluding anonymous classes does not need to trigger the autoloader.
There was a problem hiding this comment.
btw, other class_exists checks added in the PR in the anonymous class checks should probably do the same, as they are added before the resolution of the real class name which resolves aliases.
There was a problem hiding this comment.
I think that makes sense, since we want to test if the class is anonymous and anonymous classes surely don't require any autoloading.
| */ | ||
| public function getMetadataFor($className) | ||
| { | ||
| if (class_exists($className, false) && (new ReflectionClass($className))->isAnonymous()) { |
There was a problem hiding this comment.
should we put that after the check of the cache, to avoid paying the cost of this reflection check when retrieving metadata that was already loaded (which is something that the ORM does a lot, including in its critical path) ?
In some situations, they were mistaken for short aliases.
* doctrine/persistence to doctrine/persistence#286 * symfony/property-info to get symfony/symfony#40457
* doctrine/persistence to doctrine/persistence#286 * symfony/property-info to get symfony/symfony#40457
* doctrine/persistence to doctrine/persistence#286 * symfony/property-info to get symfony/symfony#40457
Fixes #24