ID:               38726
 Comment by:       dan dot marra at gmail dot com
 Reported By:      jiri dot brachtl at centrum dot cz
 Status:           No Feedback
 Bug Type:         Class/Object related
 Operating System: Windows XP SP2
 PHP Version:      5.1.6
 New Comment:

The follow example was requested. This should reproduce the error:

<?php
   function __autoload($classname)
   {
       require_once('include/'.$classname.'.php');
   }

   // in include/foo.php
   class foo {
      private $myVar;
      private $myDerivedClass;

      function __construct()
      {
         $this->myDerivedClass = new Bar();
      }
      
      function getAllVars()
      {
         $values = get_object_vars($this);
         foreach($values as $property => $value)
         {
             if(is_subclass_of($value, 'Foo'))
                 die('is a subclass!');
         }
      }
    }

//in include/bar.php
class Bar extends Foo
{
      private $anotherValue

      function __construct()
      {
           $this->anotherValue = 'foobar';
      }
}

$myclass = new Foo();
$myclass->getAllVars();


?>


this causes a fatal error where it cannot include 'test 1.php'.


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

[2006-09-13 01:00:01] php-bugs at lists dot php dot net

No feedback was provided for this bug for over a week, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".

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

[2006-09-05 17:10:52] [EMAIL PROTECTED]

And please use var_dump() instead of print_r().

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

[2006-09-05 17:09:58] [EMAIL PROTECTED]

Thank you for this bug report. To properly diagnose the problem, we
need a short but complete example script to be able to reproduce
this bug ourselves. 

A proper reproducing script starts with <?php and ends with ?>,
is max. 10-20 lines long and does not require any external 
resources such as databases, etc. If the script requires a 
database to demonstrate the issue, please make sure it creates 
all necessary tables, stored procedures etc.

Please avoid embedding huge scripts into the report.



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

[2006-09-05 17:04:43] jiri dot brachtl at centrum dot cz

Missing 'c' in function name is_subclass_of. Not so important.

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

[2006-09-05 16:58:48] jiri dot brachtl at centrum dot cz

Description:
------------
__autoload() fails to load class, when its name is used in the first
parameter of is_sublass_of().

Reproduce code:
---------------
function __autoload($className) {
  require_once $className . ".php";
}

//Both ClassName1 and ClassName2 are defined in separate files

print_r(
  is_sublass_of("ClassName1", "ClassName2")
);

Expected result:
----------------
0 or 1

Actual result:
--------------
//nothing, like void return type


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


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

Reply via email to