Skip to content

Commit e6fac86

Browse files
committed
Accept flags argument in zend_lookup_class_ex()
Instead of a single boolean, so we have space for extension here.
1 parent cd6b7eb commit e6fac86

File tree

7 files changed

+15
-14
lines changed

7 files changed

+15
-14
lines changed

Zend/zend_API.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2892,7 +2892,7 @@ static int zend_is_callable_check_class(zend_string *name, zend_class_entry *sco
28922892
*strict_class = 1;
28932893
ret = 1;
28942894
}
2895-
} else if ((ce = zend_lookup_class_ex(name, NULL, 1)) != NULL) {
2895+
} else if ((ce = zend_lookup_class(name)) != NULL) {
28962896
zend_class_entry *scope;
28972897
zend_execute_data *ex = EG(current_execute_data);
28982898

Zend/zend_builtin_functions.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1057,7 +1057,7 @@ static void is_a_impl(INTERNAL_FUNCTION_PARAMETERS, zend_bool only_subclass) /*
10571057
if (!only_subclass && EXPECTED(zend_string_equals(instance_ce->name, class_name))) {
10581058
retval = 1;
10591059
} else {
1060-
ce = zend_lookup_class_ex(class_name, NULL, 0);
1060+
ce = zend_lookup_class_ex(class_name, NULL, ZEND_FETCH_CLASS_NO_AUTOLOAD);
10611061
if (!ce) {
10621062
retval = 0;
10631063
} else {
@@ -1504,7 +1504,7 @@ ZEND_FUNCTION(class_alias)
15041504
return;
15051505
}
15061506

1507-
ce = zend_lookup_class_ex(class_name, NULL, autoload);
1507+
ce = zend_lookup_class_ex(class_name, NULL, !autoload ? ZEND_FETCH_CLASS_NO_AUTOLOAD : 0);
15081508

15091509
if (ce) {
15101510
if (ce->type == ZEND_USER_CLASS) {

Zend/zend_closures.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ ZEND_METHOD(Closure, bind)
209209
zend_string *class_name = zval_get_tmp_string(scope_arg, &tmp_class_name);
210210
if (zend_string_equals_literal(class_name, "static")) {
211211
ce = closure->func.common.scope;
212-
} else if ((ce = zend_lookup_class_ex(class_name, NULL, 1)) == NULL) {
212+
} else if ((ce = zend_lookup_class(class_name)) == NULL) {
213213
zend_error(E_WARNING, "Class '%s' not found", ZSTR_VAL(class_name));
214214
zend_string_release_ex(class_name, 0);
215215
RETURN_NULL();

Zend/zend_compile.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6394,7 +6394,8 @@ zend_op *zend_compile_class_decl(zend_ast *ast, zend_bool toplevel) /* {{{ */
63946394
/* We currently don't early-bind classes that implement interfaces or use traits */
63956395
&& !(ce->ce_flags & (ZEND_ACC_IMPLEMENT_INTERFACES|ZEND_ACC_IMPLEMENT_TRAITS))) {
63966396
if (extends_ast) {
6397-
zend_class_entry *parent_ce = zend_lookup_class_ex(ce->parent_name, NULL, 0);
6397+
zend_class_entry *parent_ce = zend_lookup_class_ex(
6398+
ce->parent_name, NULL, ZEND_FETCH_CLASS_NO_AUTOLOAD);
63986399

63996400
if (parent_ce
64006401
&& !(CG(compiler_options) & ZEND_COMPILE_PRELOAD) /* delay inheritance till preloading */

Zend/zend_execute.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ ZEND_API void zend_execute(zend_op_array *op_array, zval *return_value);
4141
ZEND_API void execute_ex(zend_execute_data *execute_data);
4242
ZEND_API void execute_internal(zend_execute_data *execute_data, zval *return_value);
4343
ZEND_API zend_class_entry *zend_lookup_class(zend_string *name);
44-
ZEND_API zend_class_entry *zend_lookup_class_ex(zend_string *name, zend_string *lcname, int use_autoload);
44+
ZEND_API zend_class_entry *zend_lookup_class_ex(zend_string *name, zend_string *lcname, uint32_t flags);
4545
ZEND_API zend_class_entry *zend_get_called_scope(zend_execute_data *ex);
4646
ZEND_API zend_object *zend_get_this_object(zend_execute_data *ex);
4747
ZEND_API int zend_eval_string(char *str, zval *retval_ptr, char *string_name);

Zend/zend_execute_API.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -886,7 +886,7 @@ int zend_call_function(zend_fcall_info *fci, zend_fcall_info_cache *fci_cache) /
886886
}
887887
/* }}} */
888888

889-
ZEND_API zend_class_entry *zend_lookup_class_ex(zend_string *name, zend_string *key, int use_autoload) /* {{{ */
889+
ZEND_API zend_class_entry *zend_lookup_class_ex(zend_string *name, zend_string *key, uint32_t flags) /* {{{ */
890890
{
891891
zend_class_entry *ce = NULL;
892892
zval args[1], *zv;
@@ -925,7 +925,7 @@ ZEND_API zend_class_entry *zend_lookup_class_ex(zend_string *name, zend_string *
925925
/* The compiler is not-reentrant. Make sure we __autoload() only during run-time
926926
* (doesn't impact functionality of __autoload()
927927
*/
928-
if (!use_autoload || zend_is_compiling()) {
928+
if ((flags & ZEND_FETCH_CLASS_NO_AUTOLOAD) || zend_is_compiling()) {
929929
if (!key) {
930930
zend_string_release_ex(lc_name, 0);
931931
}
@@ -1006,7 +1006,7 @@ ZEND_API zend_class_entry *zend_lookup_class_ex(zend_string *name, zend_string *
10061006

10071007
ZEND_API zend_class_entry *zend_lookup_class(zend_string *name) /* {{{ */
10081008
{
1009-
return zend_lookup_class_ex(name, NULL, 1);
1009+
return zend_lookup_class_ex(name, NULL, 0);
10101010
}
10111011
/* }}} */
10121012

@@ -1397,8 +1397,8 @@ zend_class_entry *zend_fetch_class(zend_string *class_name, int fetch_type) /* {
13971397
}
13981398

13991399
if (fetch_type & ZEND_FETCH_CLASS_NO_AUTOLOAD) {
1400-
return zend_lookup_class_ex(class_name, NULL, 0);
1401-
} else if ((ce = zend_lookup_class_ex(class_name, NULL, 1)) == NULL) {
1400+
return zend_lookup_class_ex(class_name, NULL, fetch_type);
1401+
} else if ((ce = zend_lookup_class_ex(class_name, NULL, fetch_type)) == NULL) {
14021402
if (!(fetch_type & ZEND_FETCH_CLASS_SILENT) && !EG(exception)) {
14031403
if (fetch_sub_type == ZEND_FETCH_CLASS_INTERFACE) {
14041404
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
14191419
zend_class_entry *ce;
14201420

14211421
if (fetch_type & ZEND_FETCH_CLASS_NO_AUTOLOAD) {
1422-
return zend_lookup_class_ex(class_name, key, 0);
1423-
} else if ((ce = zend_lookup_class_ex(class_name, key, 1)) == NULL) {
1422+
return zend_lookup_class_ex(class_name, key, fetch_type);
1423+
} else if ((ce = zend_lookup_class_ex(class_name, key, fetch_type)) == NULL) {
14241424
if (fetch_type & ZEND_FETCH_CLASS_SILENT) {
14251425
return NULL;
14261426
}

Zend/zend_inheritance.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ static zend_class_entry *lookup_class(const zend_function *fe, zend_string *name
204204
return ce;
205205
}
206206
} else {
207-
ce = zend_lookup_class_ex(name, NULL, /* autoload */ 0);
207+
ce = zend_lookup_class_ex(name, NULL, ZEND_FETCH_CLASS_NO_AUTOLOAD);
208208
if (ce && class_visible(ce)) {
209209
return ce;
210210
}

0 commit comments

Comments
 (0)