ID:               30453
 Comment by:       xuefer at 21cn dot com
 Reported By:      guth at fiifo dot u-psud dot fr
 Status:           Assigned
 Bug Type:         Scripting Engine problem
 Operating System: *
 PHP Version:      5CVS-2005-06-19
 Assigned To:      dmitry
 New Comment:

"extends" a parent class is exactly same when you want to "new" a
class

module.php:
// compile time binding (but "include" is "runtime")
<?php class module {} ?>

Does not work:
<?php
include 'module.php';
// runtime binding: undefined GroupModule now
// if you do "$a = new GroupModule();", same error
class ClassGroupModule extends GroupModule {}
// runtime binding
class GroupModule extends Module {}
?>

But this works:
<?php
// compile time binding
class Module {} 
// runtime binding, GroupModule defined at compile time: OK
// you can "$a = new GroupModule();" here also
class ClassGroupModule extends GroupModule {}
// compile time binding
class GroupModule extends Module {}
?>

And this works:
<?php
include 'module.php';
// runtime binding
class GroupModule extends Module {}
// runtime binding
class ClassGroupModule extends GroupModule {}
?>


compile time -> runtime
this might be hard for php user to figure it out. improve document
should be enough, i guess


Previous Comments:
------------------------------------------------------------------------

[2005-06-19 14:44:43] [EMAIL PROTECTED]

module.php:
<?php class module {} ?>

Does not work:
<?php
include 'module.php';
class ClassGroupModule extends GroupModule {}
class GroupModule extends Module {}
?>

But this works:
<?php
class Module {} 
class ClassGroupModule extends GroupModule {}
class GroupModule extends Module {}
?>

And this works:
<?php
include 'module.php';
class GroupModule extends Module {}
class ClassGroupModule extends GroupModule {}
?>



------------------------------------------------------------------------

[2005-05-09 11:31:13] [EMAIL PROTECTED]

Andi, (or Dmitry maybe?) can you look into this?


------------------------------------------------------------------------

[2004-10-16 02:06:37] guth at fiifo dot u-psud dot fr

Description:
------------
Look at the following code...

Note that there is no difference between the first case and the third
case. I just add an include in the first case.

Reproduce code:
---------------
test3.php :

<?php

include "test4.php";

class ClassGroupModule extends GroupModule implements GroupInterface {
}

abstract class GroupModule extends Module { }

?>


<?php

include "test4.php";

class ClassGroupModule extends GroupModule implements GroupInterface {
}

abstract class GroupModule { }

?>

<?php

abstract class Module { }

interface GroupInterface { }

class ClassGroupModule extends GroupModule implements GroupInterface {
}

abstract class GroupModule extends Module { }

?>

test4.php

<?php
abstract class Module { }

interface GroupInterface { }
?>

Expected result:
----------------
Case 1 :
- Should work

Case 2 :
- Should work

Case 3 :
- Should work

Actual result:
--------------
Case 1 :
Fatal error: Class 'GroupModule' not found in /www/test3.php on line 4

Case 2 :
- Works fine

Case 3 :
- Works fine


------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=30453&edit=1

Reply via email to