|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2013-02-23 18:33 UTC] pollita@php.net
-Status: Open
+Status: Closed
-Assigned To:
+Assigned To: pollita
[2013-02-23 18:33 UTC] pollita@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Mon Oct 27 11:00:01 2025 UTC |
Description: ------------ 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: --------------- <?php 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"); $this->connect($connect_string); } function close () { runkit_class_emancipate('sql'); } } $sql = new sql(); $sql->open('mysql', '...'); echo $sql->link . "\n"; var_dump(get_parent_class($sql)); $sql->close(); $sql->open('oracle', '...'); echo $sql->link . "\n"; var_dump(get_parent_class($sql)); ?> Expected result: ---------------- Output: Mysql Link string(9) "sql_mysql" Oracle Link string(10) "sql_oracle" Actual result: -------------- Output: Mysql Link bool(false) Error: Class sql has no parent to emancipate from ... Mysql Link bool(false) 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 ...