#37233 [NEW]: Includes, inheritance and interface cause error
From: paul at stunning-stuff dot com
Operating system: Win XP Pro SP2
PHP version: 5.1.2
PHP Bug Type: Class/Object related
Bug description: Includes, inheritance and interface cause error
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 bug report at http://bugs.php.net/?id=37233&edit=1
--
Try a CVS snapshot (PHP 4.4): http://bugs.php.net/fix.php?id=37233&r=trysnapshot44
Try a CVS snapshot (PHP 5.1): http://bugs.php.net/fix.php?id=37233&r=trysnapshot51
Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=37233&r=trysnapshot60
Fixed in CVS: http://bugs.php.net/fix.php?id=37233&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=37233&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=37233&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=37233&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=37233&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=37233&r=support
Expected behavior: http://bugs.php.net/fix.php?id=37233&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=37233&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=37233&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=37233&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=37233&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=37233&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=37233&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=37233&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=37233&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=37233&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=37233&r=mysqlcfg
Thread (4 messages)
- paul at stunning-stuff dot com