mirror of
https://github.com/doctrine/orm.git
synced 2026-03-23 22:42:18 +01:00
DDC-221: ClassLoader breaks when className starts with \ #279
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
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...
@doctrinebot commented on GitHub (Dec 22, 2009):
Comment created by nicokaiser:
... or will the "IsolatedClassLoader" be the one to use for such environments?
@doctrinebot commented on GitHub (Dec 22, 2009):
Comment created by nicokaiser:
The same happens when I change doctrine.php to use the IsolatedClassLoader:
@doctrinebot commented on GitHub (Dec 22, 2009):
Comment created by romanb:
This sounds like it was caused by the recent CLI refactorings.
A class name passed to a class loader should never start with a backslash, class names in strings are always fully-qualified, hence the leading backslash is senseless.
So I am curious as to where/why the class loader gets "\Doctrine\Common\Cli\Tasks\HelpTask" instead of "Doctrine\Common\Cli\Tasks\HelpTask".
I'm sure this is caused by the new CLI code.
@doctrinebot commented on GitHub (Dec 22, 2009):
Comment created by romanb:
This should be fixed now. However, the CLI does still not work well. Just tested "doctrine orm:schema-tool --create" and it quits with a "Fatal error: Call to undefined method Doctrine\ORM\Tools\Cli\Tasks\SchemaToolTask::getEntityManager() in /Users/robo/dev/php/Doctrine/lib/Doctrine/ORM/Tools/Cli/Tasks/SchemaToolTask.php on line 144"
@doctrinebot commented on GitHub (Dec 22, 2009):
Comment created by romanb:
Ok, this is now fixed, too. Guilherme is working on some improvements.
The CLI should work now but it does currently not recognize the $globalArguments. Thats why you will probably need to specify the --class-dir on the CLI manually currently.
@doctrinebot commented on GitHub (Dec 22, 2009):
Comment created by romanb:
I'll mark this one as resolved and open a new issue for Guilherme concerning the global CLI arguments.
If this issue is not fixed for you feel free to reopen.
@doctrinebot commented on GitHub (Dec 22, 2009):
Issue was closed with resolution "Fixed"