Broken object model when extending tidy
| Bug #50558 | Broken object model when extending tidy | |||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Submitted: | 2009-12-23 10:43 UTC | Modified: | 2009-12-25 01:36 UTC |
|
||||||||||
| 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 commits
[2009-12-25 01:36 UTC] pierrick@php.net