ID: 19411 Updated by: [EMAIL PROTECTED] Reported By: ceo at l-i-e dot com -Status: Analyzed +Status: Closed Bug Type: Feature/Change Request Operating System: All PHP Version: 4.2.2 New Comment:
So, with the Reflection API this is possible -> closing Previous Comments: ------------------------------------------------------------------------ [2004-01-10 12:08:26] php at thekid dot de The Reflection API in PHP5 can tell you where a class was defined. See http://www.sitten-polizei.de/php/reflection_api/docs/language.reflection.class.reflection_class.html for details. ------------------------------------------------------------------------ [2002-09-17 23:41:39] [EMAIL PROTECTED] The engine can't always guarantee to be able to know exactly where the class was defined. For instance, the class might be an internal class (like the Directory class) defined by an extension, or it might have been generated by an eval statement. The definition location should be fairly easy to store/recall - just add a field to zend_class_entry, and tweak the parser so that the error message is more meaningful. I'll forward this on to some other developers and we'll see what comes up. Until this is implemented, you can use something like this from your unix/cygwin shell prompt: grep -ni 'class User' $(find -name '*.php') ------------------------------------------------------------------------ [2002-09-17 22:26:42] ceo at l-i-e dot com It's a FEATURE REQUEST, not a support question. Currently, PHP's error message when encountering: class foo { the SECOND time simply tells me it's "already defined". While that would be useful if I was, say, including the same file twice, it's not particularly useful when trying to integrate two (or more) object-oriented 3rd-party libraries. The error message would be infinitely more useful if it included the __FILE__ and __LINE__ of the first: class foo { This is essentially the same problem/solution as the old "headers already sent" problem, which now explicitly states which line/file caused the original out ------------------------------------------------------------------------ [2002-09-17 21:12:27] [EMAIL PROTECTED] Sorry, but the bug system is not the appropriate forum for asking support questions. Your problem does not imply a bug in PHP itself. For a list of more appropriate places to ask for help using PHP, please visit http://www.php.net/support.php Thank you for your interest in PHP. ------------------------------------------------------------------------ [2002-09-14 22:13:28] ceo at l-i-e dot com It would be Really Nifty (tm) if the class system would tell me *WHERE* somebody has already defined "class foo" when it won't let me create class foo because it already exists. Some bozo is making me use "class User" (how original) but I've got no idea where the *other* class User is and which one will be less hassle to change, and PHP ain't telling :-( I hate inexperienced OO programmers. They cause more problems than if we just made them not use OO in the first p ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=19411&edit=1