Hi.

This is quick patch. I didn't think/read source carefully, but
it compiles following scripts and it works.

<?php

class A {
  function foo() {
   echo 'A';
  }
}

class B extends A{
  function foo() {
   echo 'B';
  }
}


$A = new A;
$B = new B;

$A->foo();
$B->foo();


?>

It echos "AB" with this patch.

[yohgaki@dev TEST-DEV]$ cat ttt.php
<?php

class A {
  function foo() {
   echo 'A';
  }
}

class B {
  function foo() {
   echo 'B';
  }
  function foo() {
   echo 'C';
  }
}


$A = new A;
$B = new B;

$A->foo();
$B->foo();


?>
[yohgaki@dev TEST-DEV]$ ./sapi/cli/php ttt.php
PHP Fatal error:  Cannot redeclare method foo() in ttt.php on line 13
ttt.php(13) : Fatal error - Cannot redeclare method foo()

Fatal error: Cannot redeclare method foo() in ttt.php on line 13

--
Yasuo Ohgaki
/usr/bin/diff: conflicting specifications of output style
--- zend_compile.c.~1.226.~     Tue Mar 26 03:48:18 2002
+++ zend_compile.c      Wed Mar 27 01:13:14 2002
@@ -732,8 +732,15 @@
        op_array.return_reference = return_reference;
 
        if (is_method) {
-               if (zend_hash_add(&CG(active_class_entry)->function_table, name, 
name_len+1, &op_array, sizeof(zend_op_array), (void **) &CG(active_op_array)) == 
FAILURE) {
-                       zend_error(E_ERROR, "Cannot redeclare method %s()", name);
+               zend_class_entry *parent_class;
+               if (Z_STRVAL(CG(active_ce_parent_class_name)) &&
+                       zend_hash_find(CG(class_table), 
+Z_STRVAL(CG(active_ce_parent_class_name)), 
+Z_STRLEN(CG(active_ce_parent_class_name))+1, (void **) &parent_class) == SUCCESS) {
+                       zend_hash_update(&CG(active_class_entry)->function_table, 
+name, name_len+1, &op_array, sizeof(zend_op_array), (void **) &CG(active_op_array));
+               }
+               else {
+                       if (zend_hash_add(&CG(active_class_entry)->function_table, 
+name, name_len+1, &op_array, sizeof(zend_op_array), (void **) &CG(active_op_array)) 
+== FAILURE) {
+                               zend_error(E_ERROR, "Cannot redeclare method %s()", 
+name);
+                       }
                }
        } else {
                zend_op *opline = get_next_op(CG(active_op_array) TSRMLS_CC);

-- 
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to