summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNikita Popov <nikita.ppv@gmail.com>2019-05-24 14:41:38 +0200
committerNikita Popov <nikita.ppv@gmail.com>2019-05-27 09:36:25 +0200
commite6fac86dc35b876d2958ce77c01bb05bd7068ac3 (patch)
tree779eab359ecd2c14c6a642ac0d2dd228da60b372
parentcd6b7ebb680c66b4de0274bbc0c8b4a52ae09a88 (diff)
downloadphp-git-e6fac86dc35b876d2958ce77c01bb05bd7068ac3.tar.gz
Accept flags argument in zend_lookup_class_ex()
Instead of a single boolean, so we have space for extension here.
-rw-r--r--Zend/zend_API.c2
-rw-r--r--Zend/zend_builtin_functions.c4
-rw-r--r--Zend/zend_closures.c2
-rw-r--r--Zend/zend_compile.c3
-rw-r--r--Zend/zend_execute.h2
-rw-r--r--Zend/zend_execute_API.c14
-rw-r--r--Zend/zend_inheritance.c2
7 files changed, 15 insertions, 14 deletions
diff --git a/Zend/zend_API.c b/Zend/zend_API.c
index a6115db38c..0dafa9d7db 100644
--- a/Zend/zend_API.c
+++ b/Zend/zend_API.c
@@ -2892,7 +2892,7 @@ static int zend_is_callable_check_class(zend_string *name, zend_class_entry *sco
*strict_class = 1;
ret = 1;
}
- } else if ((ce = zend_lookup_class_ex(name, NULL, 1)) != NULL) {
+ } else if ((ce = zend_lookup_class(name)) != NULL) {
zend_class_entry *scope;
zend_execute_data *ex = EG(current_execute_data);
diff --git a/Zend/zend_builtin_functions.c b/Zend/zend_builtin_functions.c
index b8b8257569..5fc69c24bf 100644
--- a/Zend/zend_builtin_functions.c
+++ b/Zend/zend_builtin_functions.c
@@ -1057,7 +1057,7 @@ static void is_a_impl(INTERNAL_FUNCTION_PARAMETERS, zend_bool only_subclass) /*
if (!only_subclass && EXPECTED(zend_string_equals(instance_ce->name, class_name))) {
retval = 1;
} else {
- ce = zend_lookup_class_ex(class_name, NULL, 0);
+ ce = zend_lookup_class_ex(class_name, NULL, ZEND_FETCH_CLASS_NO_AUTOLOAD);
if (!ce) {
retval = 0;
} else {
@@ -1504,7 +1504,7 @@ ZEND_FUNCTION(class_alias)
return;
}
- ce = zend_lookup_class_ex(class_name, NULL, autoload);
+ ce = zend_lookup_class_ex(class_name, NULL, !autoload ? ZEND_FETCH_CLASS_NO_AUTOLOAD : 0);
if (ce) {
if (ce->type == ZEND_USER_CLASS) {
diff --git a/Zend/zend_closures.c b/Zend/zend_closures.c
index 70b70d9723..faeadd6fd7 100644
--- a/Zend/zend_closures.c
+++ b/Zend/zend_closures.c
@@ -209,7 +209,7 @@ ZEND_METHOD(Closure, bind)
zend_string *class_name = zval_get_tmp_string(scope_arg, &tmp_class_name);
if (zend_string_equals_literal(class_name, "static")) {
ce = closure->func.common.scope;
- } else if ((ce = zend_lookup_class_ex(class_name, NULL, 1)) == NULL) {
+ } else if ((ce = zend_lookup_class(class_name)) == NULL) {
zend_error(E_WARNING, "Class '%s' not found", ZSTR_VAL(class_name));
zend_string_release_ex(class_name, 0);
RETURN_NULL();
diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c
index b66ac4dcba..d0d5c7af19 100644
--- a/Zend/zend_compile.c
+++ b/Zend/zend_compile.c
@@ -6394,7 +6394,8 @@ zend_op *zend_compile_class_decl(zend_ast *ast, zend_bool toplevel) /* {{{ */
/* We currently don't early-bind classes that implement interfaces or use traits */
&& !(ce->ce_flags & (ZEND_ACC_IMPLEMENT_INTERFACES|ZEND_ACC_IMPLEMENT_TRAITS))) {
if (extends_ast) {
- zend_class_entry *parent_ce = zend_lookup_class_ex(ce->parent_name, NULL, 0);
+ zend_class_entry *parent_ce = zend_lookup_class_ex(
+ ce->parent_name, NULL, ZEND_FETCH_CLASS_NO_AUTOLOAD);
if (parent_ce
&& !(CG(compiler_options) & ZEND_COMPILE_PRELOAD) /* delay inheritance till preloading */
diff --git a/Zend/zend_execute.h b/Zend/zend_execute.h
index c3fee42f24..36a47a01dc 100644
--- a/Zend/zend_execute.h
+++ b/Zend/zend_execute.h
@@ -41,7 +41,7 @@ ZEND_API void zend_execute(zend_op_array *op_array, zval *return_value);
ZEND_API void execute_ex(zend_execute_data *execute_data);
ZEND_API void execute_internal(zend_execute_data *execute_data, zval *return_value);
ZEND_API zend_class_entry *zend_lookup_class(zend_string *name);
-ZEND_API zend_class_entry *zend_lookup_class_ex(zend_string *name, zend_string *lcname, int use_autoload);
+ZEND_API zend_class_entry *zend_lookup_class_ex(zend_string *name, zend_string *lcname, uint32_t flags);
ZEND_API zend_class_entry *zend_get_called_scope(zend_execute_data *ex);
ZEND_API zend_object *zend_get_this_object(zend_execute_data *ex);
ZEND_API int zend_eval_string(char *str, zval *retval_ptr, char *string_name);
diff --git a/Zend/zend_execute_API.c b/Zend/zend_execute_API.c
index 0d5ceb8627..575f285167 100644
--- a/Zend/zend_execute_API.c
+++ b/Zend/zend_execute_API.c
@@ -886,7 +886,7 @@ int zend_call_function(zend_fcall_info *fci, zend_fcall_info_cache *fci_cache) /
}
/* }}} */
-ZEND_API zend_class_entry *zend_lookup_class_ex(zend_string *name, zend_string *key, int use_autoload) /* {{{ */
+ZEND_API zend_class_entry *zend_lookup_class_ex(zend_string *name, zend_string *key, uint32_t flags) /* {{{ */
{
zend_class_entry *ce = NULL;
zval args[1], *zv;
@@ -925,7 +925,7 @@ ZEND_API zend_class_entry *zend_lookup_class_ex(zend_string *name, zend_string *
/* The compiler is not-reentrant. Make sure we __autoload() only during run-time
* (doesn't impact functionality of __autoload()
*/
- if (!use_autoload || zend_is_compiling()) {
+ if ((flags & ZEND_FETCH_CLASS_NO_AUTOLOAD) || zend_is_compiling()) {
if (!key) {
zend_string_release_ex(lc_name, 0);
}
@@ -1006,7 +1006,7 @@ ZEND_API zend_class_entry *zend_lookup_class_ex(zend_string *name, zend_string *
ZEND_API zend_class_entry *zend_lookup_class(zend_string *name) /* {{{ */
{
- return zend_lookup_class_ex(name, NULL, 1);
+ return zend_lookup_class_ex(name, NULL, 0);
}
/* }}} */
@@ -1397,8 +1397,8 @@ check_fetch_type:
}
if (fetch_type & ZEND_FETCH_CLASS_NO_AUTOLOAD) {
- return zend_lookup_class_ex(class_name, NULL, 0);
- } else if ((ce = zend_lookup_class_ex(class_name, NULL, 1)) == NULL) {
+ return zend_lookup_class_ex(class_name, NULL, fetch_type);
+ } else if ((ce = zend_lookup_class_ex(class_name, NULL, fetch_type)) == NULL) {
if (!(fetch_type & ZEND_FETCH_CLASS_SILENT) && !EG(exception)) {
if (fetch_sub_type == ZEND_FETCH_CLASS_INTERFACE) {
zend_throw_or_error(fetch_type, NULL, "Interface '%s' not found", ZSTR_VAL(class_name));
@@ -1419,8 +1419,8 @@ zend_class_entry *zend_fetch_class_by_name(zend_string *class_name, zend_string
zend_class_entry *ce;
if (fetch_type & ZEND_FETCH_CLASS_NO_AUTOLOAD) {
- return zend_lookup_class_ex(class_name, key, 0);
- } else if ((ce = zend_lookup_class_ex(class_name, key, 1)) == NULL) {
+ return zend_lookup_class_ex(class_name, key, fetch_type);
+ } else if ((ce = zend_lookup_class_ex(class_name, key, fetch_type)) == NULL) {
if (fetch_type & ZEND_FETCH_CLASS_SILENT) {
return NULL;
}
diff --git a/Zend/zend_inheritance.c b/Zend/zend_inheritance.c
index 36d765386d..8541a22df0 100644
--- a/Zend/zend_inheritance.c
+++ b/Zend/zend_inheritance.c
@@ -204,7 +204,7 @@ static zend_class_entry *lookup_class(const zend_function *fe, zend_string *name
return ce;
}
} else {
- ce = zend_lookup_class_ex(name, NULL, /* autoload */ 0);
+ ce = zend_lookup_class_ex(name, NULL, ZEND_FETCH_CLASS_NO_AUTOLOAD);
if (ce && class_visible(ce)) {
return ce;
}