Skip to content

Commit 9d72d2f

Browse files
committed
Merge branch 'master' of https://github.com/php/php-src
2 parents bc032cb + 000cc04 commit 9d72d2f

File tree

91 files changed

+1515
-1646
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

91 files changed

+1515
-1646
lines changed

UPGRADING

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ PHP 8.0 UPGRADE NOTES
4242
. Any array that has a number n as its first numeric key will use n+1 for
4343
its next implicit key. Even if n is negative.
4444
RFC: https://wiki.php.net/rfc/negative_array_index
45+
. The default error_reporting level is now E_ALL. Previously it excluded
46+
E_NOTICE and E_DEPRECATED.
4547
. The @ operator will no longer silence fatal errors (E_ERROR, E_CORE_ERROR,
4648
E_COMPILE_ERROR, E_USER_ERROR, E_RECOVERABLE_ERROR, E_PARSE). Error handlers
4749
that expect error_reporting to be 0 when @ is used, should be adjusted to

Zend/tests/bug50810.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ var_dump($example->propertyBarExists());
4040

4141
?>
4242
--EXPECT--
43-
bool(true)
43+
bool(false)
4444
bool(true)
4545
bool(true)
4646
bool(true)

Zend/tests/method_exists_002.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ bool(true)
6262
bool(true)
6363
----
6464
bool(true)
65-
bool(true)
65+
bool(false)
6666
bool(true)
6767
----
6868
bool(true)

Zend/zend.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ ZEND_API zend_bool zend_rc_debug = 0;
9494
static ZEND_INI_MH(OnUpdateErrorReporting) /* {{{ */
9595
{
9696
if (!new_value) {
97-
EG(error_reporting) = E_ALL & ~E_NOTICE & ~E_STRICT & ~E_DEPRECATED;
97+
EG(error_reporting) = E_ALL;
9898
} else {
9999
EG(error_reporting) = atoi(ZSTR_VAL(new_value));
100100
}

Zend/zend_builtin_functions.c

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1125,7 +1125,8 @@ ZEND_FUNCTION(method_exists)
11251125
zval *klass;
11261126
zend_string *method_name;
11271127
zend_string *lcname;
1128-
zend_class_entry * ce;
1128+
zend_class_entry *ce;
1129+
zend_function *func;
11291130

11301131
ZEND_PARSE_PARAMETERS_START(2, 2)
11311132
Z_PARAM_ZVAL(klass)
@@ -1143,28 +1144,29 @@ ZEND_FUNCTION(method_exists)
11431144
}
11441145

11451146
lcname = zend_string_tolower(method_name);
1146-
if (zend_hash_exists(&ce->function_table, lcname)) {
1147-
zend_string_release_ex(lcname, 0);
1148-
RETURN_TRUE;
1149-
} else if (Z_TYPE_P(klass) == IS_OBJECT) {
1147+
func = zend_hash_find_ptr(&ce->function_table, lcname);
1148+
zend_string_release_ex(lcname, 0);
1149+
1150+
if (func) {
1151+
RETURN_BOOL(!(func->common.fn_flags & ZEND_ACC_PRIVATE) || func->common.scope == ce);
1152+
}
1153+
1154+
if (Z_TYPE_P(klass) == IS_OBJECT) {
11501155
zend_object *obj = Z_OBJ_P(klass);
1151-
zend_function *func = Z_OBJ_HT_P(klass)->get_method(&obj, method_name, NULL);
1156+
func = Z_OBJ_HT_P(klass)->get_method(&obj, method_name, NULL);
11521157
if (func != NULL) {
11531158
if (func->common.fn_flags & ZEND_ACC_CALL_VIA_TRAMPOLINE) {
11541159
/* Returns true to the fake Closure's __invoke */
11551160
RETVAL_BOOL(func->common.scope == zend_ce_closure
11561161
&& zend_string_equals_literal(method_name, ZEND_INVOKE_FUNC_NAME));
11571162

1158-
zend_string_release_ex(lcname, 0);
11591163
zend_string_release_ex(func->common.function_name, 0);
11601164
zend_free_trampoline(func);
11611165
return;
11621166
}
1163-
zend_string_release_ex(lcname, 0);
11641167
RETURN_TRUE;
11651168
}
11661169
}
1167-
zend_string_release_ex(lcname, 0);
11681170
RETURN_FALSE;
11691171
}
11701172
/* }}} */

Zend/zend_closures.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,8 @@ ZEND_METHOD(Closure, call)
179179
if (fci_cache.function_handler->common.fn_flags & ZEND_ACC_GENERATOR) {
180180
/* copied upon generator creation */
181181
GC_DELREF(&closure->std);
182-
} else if (fci_cache.function_handler->common.fn_flags & ZEND_ACC_HEAP_RT_CACHE) {
182+
} else if (ZEND_USER_CODE(my_function.type)
183+
&& fci_cache.function_handler->common.fn_flags & ZEND_ACC_HEAP_RT_CACHE) {
183184
efree(ZEND_MAP_PTR(my_function.op_array.run_time_cache));
184185
}
185186
}

Zend/zend_compile.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3053,7 +3053,7 @@ ZEND_API zend_uchar zend_get_call_op(const zend_op *init_op, zend_function *fbc)
30533053
if (fbc) {
30543054
if (fbc->type == ZEND_INTERNAL_FUNCTION && !(CG(compiler_options) & ZEND_COMPILE_IGNORE_INTERNAL_FUNCTIONS)) {
30553055
if (init_op->opcode == ZEND_INIT_FCALL && !zend_execute_internal) {
3056-
if (!(fbc->common.fn_flags & (ZEND_ACC_ABSTRACT|ZEND_ACC_DEPRECATED|ZEND_ACC_HAS_TYPE_HINTS|ZEND_ACC_RETURN_REFERENCE))) {
3056+
if (!(fbc->common.fn_flags & (ZEND_ACC_ABSTRACT|ZEND_ACC_DEPRECATED))) {
30573057
return ZEND_DO_ICALL;
30583058
} else {
30593059
return ZEND_DO_FCALL_BY_NAME;

Zend/zend_compile.h

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ typedef struct _zend_oparray_context {
229229
/* op_array or class is preloaded | | | */
230230
#define ZEND_ACC_PRELOADED (1 << 10) /* X | X | | */
231231
/* | | | */
232-
/* Class Flags (unused: 16...) | | | */
232+
/* Class Flags (unused: 22...) | | | */
233233
/* =========== | | | */
234234
/* | | | */
235235
/* Special class types | | | */
@@ -278,7 +278,7 @@ typedef struct _zend_oparray_context {
278278
/* Class has unresolved variance obligations. | | | */
279279
#define ZEND_ACC_UNRESOLVED_VARIANCE (1 << 21) /* X | | | */
280280
/* | | | */
281-
/* Function Flags (unused: 28...30) | | | */
281+
/* Function Flags (unused: 17, 23, 26) | | | */
282282
/* ============== | | | */
283283
/* | | | */
284284
/* deprecation flag | | | */
@@ -314,15 +314,16 @@ typedef struct _zend_oparray_context {
314314
/* run_time_cache allocated on heap (user only) | | | */
315315
#define ZEND_ACC_HEAP_RT_CACHE (1 << 22) /* | X | | */
316316
/* | | | */
317-
/* method flag used by Closure::__invoke() | | | */
318-
#define ZEND_ACC_USER_ARG_INFO (1 << 23) /* | X | | */
317+
/* method flag used by Closure::__invoke() (int only) | | | */
318+
#define ZEND_ACC_USER_ARG_INFO (1 << 22) /* | X | | */
319319
/* | | | */
320320
#define ZEND_ACC_GENERATOR (1 << 24) /* | X | | */
321321
/* | | | */
322+
/* function was processed by pass two (user only) | | | */
322323
#define ZEND_ACC_DONE_PASS_TWO (1 << 25) /* | X | | */
323324
/* | | | */
324325
/* internal function is allocated at arena (int only) | | | */
325-
#define ZEND_ACC_ARENA_ALLOCATED (1 << 26) /* | X | | */
326+
#define ZEND_ACC_ARENA_ALLOCATED (1 << 25) /* | X | | */
326327
/* | | | */
327328
/* op_array is a clone of trait method | | | */
328329
#define ZEND_ACC_TRAIT_CLONE (1 << 27) /* | X | | */

Zend/zend_execute.c

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1044,7 +1044,7 @@ static zend_always_inline zend_bool zend_check_type(
10441044
zend_type type,
10451045
zval *arg, zend_class_entry **ce, void **cache_slot,
10461046
zval *default_value, zend_class_entry *scope,
1047-
zend_bool is_return_type, zend_bool is_internal_arg)
1047+
zend_bool is_return_type, zend_bool is_internal)
10481048
{
10491049
zend_reference *ref = NULL;
10501050

@@ -1089,10 +1089,15 @@ static zend_always_inline zend_bool zend_check_type(
10891089
return 1;
10901090
} else if (ref && ZEND_REF_HAS_TYPE_SOURCES(ref)) {
10911091
return 0; /* we cannot have conversions for typed refs */
1092+
} else if (is_internal && is_return_type) {
1093+
/* For internal returns, the type has to match exactly, because we're not
1094+
* going to check it for non-debug builds, and there will be no chance to
1095+
* apply coercions. */
1096+
return 0;
10921097
} else {
10931098
return zend_verify_scalar_type_hint(ZEND_TYPE_CODE(type), arg,
10941099
is_return_type ? ZEND_RET_USES_STRICT_TYPES() : ZEND_ARG_USES_STRICT_TYPES(),
1095-
is_internal_arg);
1100+
is_internal);
10961101
}
10971102

10981103
/* Special handling for IS_VOID is not necessary (for return types),
@@ -1153,7 +1158,7 @@ static zend_never_inline ZEND_ATTRIBUTE_UNUSED int zend_verify_internal_arg_type
11531158
break;
11541159
}
11551160

1156-
if (UNEXPECTED(!zend_check_type(cur_arg_info->type, arg, &ce, &dummy_cache_slot, NULL, fbc->common.scope, 0, /* is_internal_arg */ 1))) {
1161+
if (UNEXPECTED(!zend_check_type(cur_arg_info->type, arg, &ce, &dummy_cache_slot, NULL, fbc->common.scope, 0, /* is_internal */ 1))) {
11571162
return 0;
11581163
}
11591164
arg++;
@@ -1249,7 +1254,7 @@ static int zend_verify_internal_return_type(zend_function *zf, zval *ret)
12491254
return 1;
12501255
}
12511256

1252-
if (UNEXPECTED(!zend_check_type(ret_info->type, ret, &ce, &dummy_cache_slot, NULL, NULL, 1, 0))) {
1257+
if (UNEXPECTED(!zend_check_type(ret_info->type, ret, &ce, &dummy_cache_slot, NULL, NULL, 1, /* is_internal */ 1))) {
12531258
zend_verify_internal_return_error(zf, ce, ret);
12541259
return 0;
12551260
}

Zend/zend_portability.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -355,7 +355,7 @@ char *alloca();
355355

356356
#endif
357357

358-
#if (HAVE_ALLOCA || (defined (__GNUC__) && __GNUC__ >= 2)) && !(defined(ZTS)) && !(defined(ZTS) && defined(HPUX)) && !defined(DARWIN)
358+
#if (HAVE_ALLOCA || (defined (__GNUC__) && __GNUC__ >= 2)) && !(defined(ZTS) && defined(HPUX)) && !defined(DARWIN)
359359
# define ZEND_ALLOCA_MAX_SIZE (32 * 1024)
360360
# define ALLOCA_FLAG(name) \
361361
zend_bool name;

0 commit comments

Comments
 (0)