]> granicus.if.org Git - php/commitdiff
Fixed bug #29104 (Function declaration in method doesn't work)
authorDmitry Stogov <dmitry@php.net>
Wed, 27 Apr 2005 14:30:33 +0000 (14:30 +0000)
committerDmitry Stogov <dmitry@php.net>
Wed, 27 Apr 2005 14:30:33 +0000 (14:30 +0000)
NEWS
Zend/tests/bug29104.phpt [new file with mode: 0644]
Zend/zend_compile.c

diff --git a/NEWS b/NEWS
index 1b15745bbbc6d5aa05f7059dcf806e8d44a501d8..f50e5a28e6c1805ae86570cc19fca7815ae271b0 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -60,6 +60,7 @@ PHP                                                                        NEWS
   (Dmitry)
 - Fixed bug #29944 (Function defined in switch, crashes). (Dmitry)
 - Fixed bug #29583 (crash when echoing a COM object). (M.Sisolak, Wez)
+- Fixed bug #29104 (Function declaration in method doesn't work). (Dmitry)
 - Fixed bug #28839 (SIGSEGV in interactive mode (php -a)).
   (kameshj at fastmail dot fm)
 
diff --git a/Zend/tests/bug29104.phpt b/Zend/tests/bug29104.phpt
new file mode 100644 (file)
index 0000000..c7afbee
--- /dev/null
@@ -0,0 +1,27 @@
+--TEST--
+Bug #29104 Function declaration in method doesn't work 
+--FILE--
+<?php
+class A
+{ 
+  function g() 
+  { 
+    echo "function g - begin\n";
+    
+    function f() 
+    { 
+      echo "function f\n";
+    } 
+
+    echo "function g - end\n";
+  }
+}
+
+$a = new A;
+$a->g();
+f();
+?>
+--EXPECT--
+function g - begin
+function g - end
+function f
index 72bcba6d8a70dd7366f156f0c1b0127fd712cb7c..a9bcaf5f55f905c117edadf75219e642af69e6d4 100644 (file)
@@ -965,7 +965,7 @@ void zend_do_begin_function_declaration(znode *function_token, znode *function_n
        op_array.fn_flags = fn_flags;
        op_array.pass_rest_by_reference = 0;
 
-       op_array.scope = CG(active_class_entry);
+       op_array.scope = is_method?CG(active_class_entry):NULL;
        op_array.prototype = NULL;
 
        op_array.line_start = zend_get_compiled_lineno(TSRMLS_C);