From:             degeb...@php.net
Operating system: Irrelevant
PHP version:      5.3.1
PHP Bug Type:     Class/Object related
Bug description:  Broken object model when extending tidy

Description:
------------
When extending the class tidy (http://docs.php.net/class.tidy) with a
subtype MyTidy, the PHP engine fails type checks for MyTidy (probably
easier to explain using code).

This is inconsistent with normal behavior in the object model. is_a($o,
get_class($o)) should always be true if $o is an object, that is an object
should always be an instance of its own class.

Reproduce code:
---------------
<?php
class MyTidy extends tidy
{
    // foo
}

function doSomething(MyTidy $o) 
{
    var_dump($o);
}

$o = new MyTidy();

var_dump(is_a($o, get_class($o)), get_class($o));
doSomething($o);

Expected result:
----------------
bool(true)
string(7) "MyTidy"
object(MyTidy)#1 (2) {
  ["errorBuffer"]=>
  NULL
  ["value"]=>
  NULL
}

Actual result:
--------------
bool(false)
string(6) "MyTidy"
PHP Catchable fatal error:  Argument 1 passed to doSomething() must be an
instance of MyTidy, instance of tidy given, called in /home/daniel/test.php
on line 16 and defined in /home/daniel/test.php on line 7

Catchable fatal error: Argument 1 passed to doSomething() must be an
instance of MyTidy, instance of tidy given, called in /home/daniel/test.php
on line 16 and defined in /home/daniel/test.php on line 7

-- 
Edit bug report at http://bugs.php.net/?id=50558&edit=1
-- 
Try a snapshot (PHP 5.2):            
http://bugs.php.net/fix.php?id=50558&r=trysnapshot52
Try a snapshot (PHP 5.3):            
http://bugs.php.net/fix.php?id=50558&r=trysnapshot53
Try a snapshot (PHP 6.0):            
http://bugs.php.net/fix.php?id=50558&r=trysnapshot60
Fixed in SVN:                        
http://bugs.php.net/fix.php?id=50558&r=fixed
Fixed in SVN and need be documented: 
http://bugs.php.net/fix.php?id=50558&r=needdocs
Fixed in release:                    
http://bugs.php.net/fix.php?id=50558&r=alreadyfixed
Need backtrace:                      
http://bugs.php.net/fix.php?id=50558&r=needtrace
Need Reproduce Script:               
http://bugs.php.net/fix.php?id=50558&r=needscript
Try newer version:                   
http://bugs.php.net/fix.php?id=50558&r=oldversion
Not developer issue:                 
http://bugs.php.net/fix.php?id=50558&r=support
Expected behavior:                   
http://bugs.php.net/fix.php?id=50558&r=notwrong
Not enough info:                     
http://bugs.php.net/fix.php?id=50558&r=notenoughinfo
Submitted twice:                     
http://bugs.php.net/fix.php?id=50558&r=submittedtwice
register_globals:                    
http://bugs.php.net/fix.php?id=50558&r=globals
PHP 4 support discontinued:          http://bugs.php.net/fix.php?id=50558&r=php4
Daylight Savings:                    http://bugs.php.net/fix.php?id=50558&r=dst
IIS Stability:                       
http://bugs.php.net/fix.php?id=50558&r=isapi
Install GNU Sed:                     
http://bugs.php.net/fix.php?id=50558&r=gnused
Floating point limitations:          
http://bugs.php.net/fix.php?id=50558&r=float
No Zend Extensions:                  
http://bugs.php.net/fix.php?id=50558&r=nozend
MySQL Configuration Error:           
http://bugs.php.net/fix.php?id=50558&r=mysqlcfg

Reply via email to