|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #58521 runkit_class_adopt doesn't work as expected
Submitted: 2009-01-27 04:57 UTC Modified: 2013-02-23 18:33 UTC
From: luka8088 at gmail dot com Assigned: pollita (profile)
Status: Closed Package: runkit (PECL)
PHP Version: 5.2.5 OS: Windows
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: luka8088 at gmail dot com
New email:
PHP Version: OS:


 [2009-01-27 04:57 UTC] luka8088 at gmail dot com
I think this should work without errors.... And that would make runkit very useful for dynamic inheritance ... This is an example how to use one universal sql object that would load proper sql driver dynamically ... 

Reproduce code:

class sql_mysql {
  function connect () {
    $this->link = 'Mysql Link';

class sql_oracle {
  function connect () {
    $this->link = 'Oracle Link';

class sql {

  function open ($driver, $connect_string) {
    runkit_class_adopt('sql', "sql_$driver");

  function close () {


$sql = new sql();
$sql->open('mysql', '...');
echo $sql->link . "\n";


$sql->open('oracle', '...');
echo $sql->link . "\n";


Expected result:
Mysql Link
string(9) "sql_mysql"
Oracle Link
string(10) "sql_oracle"

Actual result:
Mysql Link
Error: Class sql has no parent to emancipate from ...
Mysql Link

It seams that runkit just copies class methods, and does not actually extend the class, and becouse of that it cannot emancipate and again adopt it dynamically ...


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2013-02-23 18:33 UTC]
-Status: Open +Status: Closed -Assigned To: +Assigned To: pollita
 [2013-02-23 18:33 UTC]
The fix for this bug has been committed.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at

 For Windows:
Thank you for the report, and for helping us make PHP better.
PHP Copyright © 2001-2022 The PHP Group
All rights reserved.
Last updated: Sun Jan 23 09:03:35 2022 UTC