php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #50558 Broken object model when extending tidy
Submitted: 2009-12-23 10:43 UTC Modified: 2009-12-25 01:36 UTC
Votes:1
Avg. Score:1.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:0 (0.0%)
From: degeberg@php.net Assigned:
Status: Closed Package: Tidy (PECL)
PHP Version: 5.3.1 OS: Irrelevant
Private report: No CVE-ID: None
 [2009-12-23 10:43 UTC] degeberg@php.net
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

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-12-25 01:35 UTC] svn@php.net
Automatic comment from SVN on behalf of pierrick
Revision: http://svn.php.net/viewvc/?view=revision&revision=292620
Log: Fixed bug #50558 (Broken object model when extending tidy)
 [2009-12-25 01:36 UTC] pierrick@php.net
This bug has been fixed in SVN.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
 
Thank you for the report, and for helping us make PHP better.


 [2010-02-11 17:36 UTC] svn@php.net
Automatic comment from SVN on behalf of johannes
Revision: http://svn.php.net/viewvc/?view=revision&revision=294893
Log: merge r292620: Fixed bug #50558 (Broken object model when extending tidy)
(pierrick)
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Dec 06 11:01:28 2024 UTC