Commit 0e66515c856 for php
commit 0e66515c856834a93c2822b90014fca87770d671
Merge: 13b89e20cb0 020d4741745
Author: Arnaud Le Blanc <arnaud.lb@gmail.com>
Date: Fri Nov 6 17:13:53 2026 +0100
Merge branch 'PHP-8.5' into PHP-8.6
* PHP-8.5:
Fix GH-25238: ReflectionProperty::isInitialized() skips lazy init once cached (#25239)
diff --cc ext/reflection/php_reflection.c
index 5bdd5e18bf2,b799b034764..696828578fc
--- a/ext/reflection/php_reflection.c
+++ b/ext/reflection/php_reflection.c
@@@ -2007,12 -2111,12 +2007,12 @@@ ZEND_METHOD(ReflectionFunctionAbstract
/* {{{ Returns the attributes of this function */
ZEND_METHOD(ReflectionFunctionAbstract, getAttributes)
{
- reflection_object *intern;
- zend_function *fptr;
- uint32_t target;
+ const reflection_object *intern;
+ const zend_function *fptr;
GET_REFLECTION_OBJECT_PTR(fptr);
-
+
+ uint32_t target;
if (fptr->common.scope && (fptr->common.fn_flags & (ZEND_ACC_CLOSURE|ZEND_ACC_FAKE_CLOSURE)) != ZEND_ACC_CLOSURE) {
target = ZEND_ATTRIBUTE_TARGET_METHOD;
} else {
@@@ -3382,21 -3555,7 +3382,21 @@@ static void reflection_method_invoke(IN
* Else, we verify that the given object is an instance of the class.
*/
if (mptr->common.fn_flags & ZEND_ACC_STATIC) {
- object = NULL;
+ if (object) {
+ zend_string *method_name = get_active_function_or_method_name();
+ zend_error(
+ E_DEPRECATED,
+ "Calling %pS() for static method %pS::%pS() does not need an object parameter",
+ method_name,
+ mptr->common.scope->name,
+ mptr->common.function_name
+ );
+ zend_string_release(method_name);
+ if (UNEXPECTED(EG(exception))) {
+ RETURN_THROWS();
+ }
+ object = NULL;
- }
++ }
obj_ce = mptr->common.scope;
} else {
if (!object) {
@@@ -6291,34 -6469,39 +6291,36 @@@ ZEND_METHOD(ReflectionProperty, isIniti
RETURN_BOOL(!Z_ISUNDEF_P(member_p));
}
RETURN_FALSE;
- } else {
- int retval;
-
- if (!object) {
- zend_argument_type_error(1, "must be provided for instance properties");
- RETURN_THROWS();
- }
+ }
+ if (!object) {
+ zend_argument_type_error(1, "must be provided for instance properties");
+ RETURN_THROWS();
+ }
- /* TODO: Should this always use intern->ce? */
- if (!instanceof_function(Z_OBJCE_P(object), ref->prop ? ref->prop->ce : intern->ce)) {
- _DO_THROW("Given object is not an instance of the class this property was declared in");
- RETURN_THROWS();
- }
+ /* TODO: Should this always use intern->ce? */
+ if (!instanceof_function(Z_OBJCE_P(object), ref->prop ? ref->prop->ce : intern->ce)) {
+ zend_throw_exception(reflection_exception_ptr, "Given object is not an instance of the class this property was declared in", 0);
+ RETURN_THROWS();
+ }
- if (ref->cache_slot[0] == Z_OBJCE_P(object)) {
- uintptr_t prop_offset = (uintptr_t) ref->cache_slot[1];
+ if (ref->cache_slot[0] == Z_OBJCE_P(object)) {
+ uintptr_t prop_offset = (uintptr_t) ref->cache_slot[1];
- if (EXPECTED(IS_VALID_PROPERTY_OFFSET(prop_offset))) {
- zval *value = OBJ_PROP(Z_OBJ_P(object), prop_offset);
- if (EXPECTED(!Z_ISUNDEF_P(value) || !zend_object_is_lazy(Z_OBJ_P(object)))) {
- RETURN_BOOL(!Z_ISUNDEF_P(value));
- }
+ if (EXPECTED(IS_VALID_PROPERTY_OFFSET(prop_offset))) {
+ zval *value = OBJ_PROP(Z_OBJ_P(object), prop_offset);
- RETURN_BOOL(!Z_ISUNDEF_P(value));
++ if (EXPECTED(!Z_ISUNDEF_P(value) || !zend_object_is_lazy(Z_OBJ_P(object)))) {
++ RETURN_BOOL(!Z_ISUNDEF_P(value));
+ }
}
+ }
- const zend_class_entry *old_scope = EG(fake_scope);
- EG(fake_scope) = intern->ce;
- retval = Z_OBJ_HT_P(object)->has_property(Z_OBJ_P(object),
- ref->unmangled_name, ZEND_PROPERTY_EXISTS, ref->cache_slot);
- EG(fake_scope) = old_scope;
+ const zend_class_entry *old_scope = EG(fake_scope);
+ EG(fake_scope) = intern->ce;
+ int retval = Z_OBJ_HT_P(object)->has_property(Z_OBJ_P(object),
+ ref->unmangled_name, ZEND_PROPERTY_EXISTS, ref->cache_slot);
+ EG(fake_scope) = old_scope;
- RETVAL_BOOL(retval);
- }
+ RETVAL_BOOL(retval);
}
/* }}} */