php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Return to Bug #63834
Patch 63834-2.patch revision 2012-12-31 11:49 UTC by krakjoe@php.net
revision 2012-12-31 11:36 UTC by krakjoe@php.net
Patch 63834.patch revision 2012-12-31 11:11 UTC by krakjoe@php.net

Patch 63834-2.patch for Class/Object related Bug #63834

Patch version 2012-12-31 11:36 UTC

Return to Bug #63834 | Download this patch
This patch is obsolete

Obsoleted by patches:

Patch Revisions:

Developer: krakjoe@php.net

--- virgin/Zend/zend_builtin_functions.c	2012-12-31 11:30:58.558277790 +0000
+++ patched/Zend/zend_builtin_functions.c	2012-12-31 11:31:07.471326573 +0000
@@ -44,6 +44,8 @@
 static ZEND_FUNCTION(define);
 static ZEND_FUNCTION(defined);
 static ZEND_FUNCTION(get_class);
+static ZEND_FUNCTION(get_calling_method);
+static ZEND_FUNCTION(get_calling_class);
 static ZEND_FUNCTION(get_called_class);
 static ZEND_FUNCTION(get_parent_class);
 static ZEND_FUNCTION(method_exists);
@@ -255,6 +257,8 @@
 	ZEND_FE(define,				arginfo_define)
 	ZEND_FE(defined,			arginfo_defined)
 	ZEND_FE(get_class,			arginfo_get_class)
+	ZEND_FE(get_calling_method,	arginfo_zend__void)
+	ZEND_FE(get_calling_class,	arginfo_zend__void)
 	ZEND_FE(get_called_class,	arginfo_zend__void)
 	ZEND_FE(get_parent_class,	arginfo_get_class)
 	ZEND_FE(method_exists,		arginfo_method_exists)
@@ -771,6 +775,45 @@
 }
 /* }}} */
 
+/* {{{ proto string get_calling_method()
+   Retrieves the function name of the calling method */
+ZEND_FUNCTION(get_calling_method)
+{
+	zend_execute_data *ex;
+	
+	if (zend_parse_parameters_none() == FAILURE) {
+		return;
+	}
+	
+	ex = EG(current_execute_data)->prev_execute_data;
+	
+	if (ex && ex->function_state.function) {
+		RETURN_STRING(ex->function_state.function->common.function_name, 1);	
+	} else zend_error(E_WARNING, "get_calling_method() called from outside a class");
+
+	RETURN_FALSE;
+} 
+/* }}} */
+
+/* {{{ proto string get_calling_class()
+   Retrieves the class name of the calling scope */
+ZEND_FUNCTION(get_calling_class)
+{
+	zend_execute_data *ex;
+	
+	if (zend_parse_parameters_none() == FAILURE) {
+		return;
+	}
+	
+	ex = EG(current_execute_data)->prev_execute_data;
+	
+	if (ex && ex->current_scope) {
+		RETURN_STRINGL(ex->current_scope->name, ex->current_scope->name_length, 1);	
+	} else zend_error(E_WARNING, "get_calling_class() called from outside a class");
+
+	RETURN_FALSE;
+} /* }}} */
+
 /* {{{ proto string get_called_class()
    Retrieves the "Late Static Binding" class name */
 ZEND_FUNCTION(get_called_class)
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Mar 28 10:01:26 2024 UTC