#37233 [Bgs]: Includes, inheritance and interface cause error

From: Date: Fri, 28 Apr 2006 18:58:40 +0000
Subject: #37233 [Bgs]: Includes, inheritance and interface cause error
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-96331@lists.php.net to get a copy of this message
ID: 37233 Updated by: bjori@php.net Reported By: paul at stunning-stuff dot com Status: Bogus Bug Type: Class/Object related Operating System: Win XP Pro SP2 PHP Version: 5.1.2 New Comment: > Did you even read my post? Yes. > And what 'resolution' is that...? Won't fix? >What am I supposed to do with a pre-compiled answer like that Did you read my standard answer? This is dupe of bug #30453 and bug #30452 > What would be a better place for me to post a request for change like the one described in my first post? It's been denied already. You can easily get around this by moving "require_once 'language_manager.class.php';" into "functionCausingError". And, if you have read the manual (php.net/oop5.autoload), you'd know you could also get around this like this; function __autoload($class) { require_once strtolower($class). ".class.php"; } -Hannes Previous Comments: ------------------------------------------------------------------------ [2006-04-28 18:13:44] paul at stunning-stuff dot com Did you even read my post? "the resolution is likely to be the same." And what 'resolution' is that...? Won't fix? What am I supposed to do with a pre-compiled answer like that, if you give me one of those standard answers at least have the courtesy to read my post in its entirety. Not just the first line. What would be a better place for me to post a request for change like the one described in my first post? Thanks, Paul ------------------------------------------------------------------------ [2006-04-28 13:25:22] bjori@php.net Please do not submit the same bug more than once. An existing bug report already describes this very problem. Even if you feel that your issue is somewhat different, the resolution is likely to be the same. Thank you for your interest in PHP. ------------------------------------------------------------------------ [2006-04-28 06:27:35] paul at stunning-stuff dot com Description: ------------ I have seen 2 reports (#30452 & #30453) that seem similar to this bug. Both of them were closed with the message 'Won't fix'. I don't think this is fair, it is a bug and it should be fixed because it seriously limits the OOP capabilities of PHP5. I included a feasible real-world example that shows why this bug should be fixed (I tried to make it as short as possible). Running index.php will cause a Fatal Error because Manager could not be found in language_manager.class.php on line 6. This happens because Manager is declared after LanguageManager is declared, even though (visually) manager.class.php is included before language_manager.class.php. The strange thing is, when Manager doesn't implement the interface Whatever, everything is fine! If it works without an interface it should work with an interface as well. Thanks for the time and effort you guys spend on making a great programming language. I know it's free, so I am not going to demand a fix :-), I'll just say 'pretty please' instead ;-). Thanks, Paul Reproduce code: --------------- index.php <?php // We require this file because we plan to use a manager object in here. require_once 'manager.class.php'; ?> manager.class.php <?php // Manager implements Whatever. require_once 'whatever.class.php'; // Manager uses LanguageManager to translate errors. require_once 'language_manager.class.php'; class Manager implements Whatever { public function functionCausingError() { // LanguageManager is used to translate an error caused in this function. $languageManager = new LanguageManager(); } } ?> language_manager.class.php <?php // LanguageManager extends Manager. require_once 'manager.class.php'; class LanguageManager extends Manager { } ?> whatever.class.php <?php interface Whatever { } ?> Expected result: ---------------- No output Actual result: -------------- Fatal error: Class 'Manager' not found in C:\Web Server\Web Root\sandbox\bug\language_manager.class.php on line 6 ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=37233&edit=1

« previous php.bugs (#96331) next »