|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2007-07-03 08:09 UTC] bugotech at gmail dot com
Description:
------------
If you declare class A with a method in one file and you declare class as extending class A, you cannot declare the method of class A in class B.
Reproduce code:
---------------
File a.php:
<?
class A
{
public function Test()
{
echo("Test to class A");
}
}
?>
File b.php:
<?
class B extends A
{
public function WriteIn()
{
$this->Test();
}
}
?>
File c.php:
<?
bcompiler_load('./a.obj');
bcompiler_load('./b.obj'); // Here this the erro
$obj = new B();
$obj->Test();
$obj->WriteIn();
?>
Expected result:
----------------
That it functions
Actual result:
--------------
unable inherit class B
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Oct 31 23:00:01 2025 UTC |
Thats a tough one... Simple solution, use "include" instead of bcompiler_load. The problem is the "late binding" syndrome. When b.php is compiled, two instructions are inserted into the "main" function: line # op fetch ext operands ------------------------------------------------------------------------------- 3 0 ZEND_FETCH_CLASS :0, 'CLASSA' 1 ZEND_DECLARE_INHERITED_CLASS null, '%00classb%2Froot%2Fzobo%2Fbcompiler%2Ftests%2F11510%2Fb.php0x865502a', 'classb' This brings out another problem. most bcompiler loading functions (bcompiler_load, bcompiler_load_exe...) do not evaluate the returning op_array. So no late inheriting (bad). The problem is not so severe until you compile more files that have late binging classes to one binary file. Then the "main" functions of each file overlaps and only the last gets executed.