[php-src] master: Merge branch 'PHP-8.6'

From: Date: Fri, 06 Nov 2026 16:15:30 +0000
Subject: [php-src] master: Merge branch 'PHP-8.6'
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-143368@lists.php.net to get a copy of this message
Author: Arnaud Le Blanc (arnaud-lb) Date: 2026-11-06T17:14:48+01:00 Commit: https://github.com/php/php-src/commit/088f299f1e577174aa0f94c26feb898ea4662d52 Raw diff: https://github.com/php/php-src/commit/088f299f1e577174aa0f94c26feb898ea4662d52.diff Merge branch 'PHP-8.6' * PHP-8.6: Fix GH-25238: ReflectionProperty::isInitialized() skips lazy init once cached (#25239) Changed paths: A ext/reflection/tests/gh25238.phpt M ext/reflection/php_reflection.c Diff: diff --git a/ext/reflection/php_reflection.c b/ext/reflection/php_reflection.c index bd786e8d4ab5..d312f125cb88 100644 --- a/ext/reflection/php_reflection.c +++ b/ext/reflection/php_reflection.c @@ -2011,7 +2011,7 @@ ZEND_METHOD(ReflectionFunctionAbstract, getAttributes) 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; @@ -3396,7 +3396,7 @@ static void reflection_method_invoke(INTERNAL_FUNCTION_PARAMETERS, bool variadic RETURN_THROWS(); } object = NULL; - } + } obj_ce = mptr->common.scope; } else { if (!object) { @@ -6308,7 +6308,9 @@ ZEND_METHOD(ReflectionProperty, isInitialized) 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)); + } } } diff --git a/ext/reflection/tests/gh25238.phpt b/ext/reflection/tests/gh25238.phpt new file mode 100644 index 000000000000..24c4b754cabc --- /dev/null +++ b/ext/reflection/tests/gh25238.phpt @@ -0,0 +1,74 @@ +--TEST-- +GH-25238 (ReflectionProperty::isInitialized() does not initialize lazy objects once its cache slot is warm) +--FILE-- +<?php + +class Line { + public string $label = ''; +} + +class NoDefault { + public string $label; +} + +$class = new ReflectionClass(Line::class); +$property = new ReflectionProperty(Line::class, 'label'); + +foreach (['first', 'second', 'third'] as $label) { + $line = $class->newLazyGhost(function (Line $line) use ($label) { + $line->label = $label; + }); + var_dump($property->isInitialized($line)); + var_dump($class->isUninitializedLazyObject($line)); + var_dump($line->label); +} + +foreach (['first', 'second'] as $label) { + $line = $class->newLazyProxy(function () use ($label) { + $line = new Line(); + $line->label = $label; + return $line; + }); + var_dump($property->isInitialized($line)); + var_dump($class->isUninitializedLazyObject($line)); + var_dump($property->isInitialized($line)); + var_dump($line->label); +} + +$line = new Line(); +unset($line->label); +var_dump($property->isInitialized($line)); + +$class = new ReflectionClass(NoDefault::class); +$property = new ReflectionProperty(NoDefault::class, 'label'); + +for ($i = 0; $i < 2; $i++) { + $object = $class->newLazyGhost(function (NoDefault $object) {}); + var_dump($property->isInitialized($object)); + var_dump($class->isUninitializedLazyObject($object)); +} + +?> +--EXPECT-- +bool(true) +bool(false) +string(5) "first" +bool(true) +bool(false) +string(6) "second" +bool(true) +bool(false) +string(5) "third" +bool(true) +bool(false) +bool(true) +string(5) "first" +bool(true) +bool(false) +bool(true) +string(6) "second" +bool(false) +bool(false) +bool(false) +bool(false) +bool(false)

« previous php.cvs (#143368) next »