#34109 [Opn->Bgs]: __autoload interupting normal "code flow"
| From: | sniper@php.net | Date: | Fri, 12 Aug 2005 20:41:13 +0000 |
| Subject: | #34109 [Opn->Bgs]: __autoload interupting normal "code flow" | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-83481@lists.php.net to get a copy of this message | ||
ID: 34109
Updated by: sniper@php.net
Reported By: info at tphnet dot com
-Status: Open
+Status: Bogus
Bug Type: Class/Object related
Operating System: Windows XP SP2
PHP Version: 5.0.4
New Comment:
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to
report
a bug at http://bugs.php.net/how-to-report.php
Previous Comments:
------------------------------------------------------------------------
[2005-08-12 22:01:22] info at tphnet dot com
Description:
------------
I've been toying around a bit with the __autoload() functionallity and
along the way found some strange behaviour.
I'm not entirely sure it's bug, but it's at least not working as I
would expect it.
I created a system which allows classes to register themselfs with a
"registration object" when loaded. When registering, some checks are
executed to (for example) see if the class that's being registered is
of the right type.
Below is a very simplified version of my script, it serves no purpose
but to show my problem.
Reproduce code:
---------------
Index.php
<?php
function __autoload($class){
include($class . '.php');}
$Class = new Class2();
?>
Class1.php
<?php
class Class1{
public static function CheckClass2(){
is_subclass_of('Class2', 'Class1');}}
?>
Class2.php
<?php
Class1::CheckClass2();
class Class2 extends Class1{}
?>
Expected result:
----------------
When running Index.php, a blank page should be displayed.
Actual result:
--------------
When running Index.php, the following error appears:
Warning: Unknown class passed as parameter in Class1.php on line 7
I can only assume that by using the __autload() function the normal
flow of code processing is changed in some way.
Class2 seems not to be defined by the time the CheckClass2() method is
called, even though Class2.php should've been included before
Class1.php (where this method is located).
When I manually include both files in Index.php the code works fine,
same goes for placing the call to CheckClass2() below the definition of
Class2.
Again, I'm not sure whether this is a bug or just "the way it works".
It's although not what I would expect to happen...
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=34109&edit=1