DDC-221: ClassLoader breaks when className starts with \ #277

Open
opened 2026-01-22 12:33:18 +01:00 by admin · 0 comments
Owner

Originally created by @doctrinebot on GitHub (Dec 22, 2009).

Jira issue originally created by user nicokaiser:

The ClassLoader seems to ignore classNames that start with "".

When it is instantiated in tools/sandbox/doctrine.php with a parameter instead of for the global namespace, it does not find "\Doctrine\Common\Cli\Tasks\HelpTask" (but finds all classes that start with "Doctrine"). To reproduce, change this line in tools/sandbox/doctrine.php

$classLoader = new \Doctrine\Common\ClassLoader();

to

$classLoader = new \Doctrine\Common\ClassLoader('Doctrine');

The script fails now:
PHP Fatal error: Class '\Doctrine\Common\Cli\Tasks\HelpTask' not found in /home/kaiser/doctrine/doctrine/lib/Doctrine/Common/Cli/TaskNamespace.php on line 81

Registering the ClassLoader only for some specific namespaces (e.g. "Doctrine", "Entities", "Proxies") is vital for inclusion in an existing Zend autoloading environment...

Originally created by @doctrinebot on GitHub (Dec 22, 2009). Jira issue originally created by user nicokaiser: The ClassLoader seems to ignore classNames that start with "\". When it is instantiated in tools/sandbox/doctrine.php with a parameter instead of for the global namespace, it does not find "\Doctrine\Common\Cli\Tasks\HelpTask" (but finds all classes that start with "Doctrine"). To reproduce, change this line in tools/sandbox/doctrine.php `$classLoader = new \Doctrine\Common\ClassLoader();` to `$classLoader = new \Doctrine\Common\ClassLoader('Doctrine');` The script fails now: PHP Fatal error: Class '\Doctrine\Common\Cli\Tasks\HelpTask' not found in /home/kaiser/doctrine/doctrine/lib/Doctrine/Common/Cli/TaskNamespace.php on line 81 Registering the ClassLoader only for some specific namespaces (e.g. "Doctrine", "Entities", "Proxies") is vital for inclusion in an existing Zend autoloading environment...
admin added the Bug label 2026-01-22 12:33:18 +01:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#277