mirror of
https://github.com/php/php-src.git
synced 2025-08-15 13:38:49 +02:00
Add support for using final properties in stubs (#17306)
This commit is contained in:
parent
e4ad271073
commit
684ef016e1
4 changed files with 25 additions and 1 deletions
|
@ -75,6 +75,8 @@ object(_ZendTestClass)#1 (3) {
|
|||
uninitialized(Traversable&Countable)
|
||||
["readonlyProp"]=>
|
||||
uninitialized(int)
|
||||
["finalProp"]=>
|
||||
uninitialized(int)
|
||||
["dnfProperty"]=>
|
||||
uninitialized(Iterator|(Traversable&Countable))
|
||||
}
|
||||
|
@ -93,6 +95,8 @@ object(Test)#4 (3) {
|
|||
uninitialized(Traversable&Countable)
|
||||
["readonlyProp"]=>
|
||||
uninitialized(int)
|
||||
["finalProp"]=>
|
||||
uninitialized(int)
|
||||
["dnfProperty"]=>
|
||||
uninitialized(Iterator|(Traversable&Countable))
|
||||
}
|
||||
|
|
|
@ -3103,6 +3103,10 @@ class PropertyInfo extends VariableLike
|
|||
$flags = $this->addFlagForVersionsAbove($flags, "ZEND_ACC_STATIC", PHP_70_VERSION_ID);
|
||||
}
|
||||
|
||||
if ($this->flags & Modifiers::FINAL) {
|
||||
$flags = $this->addFlagForVersionsAbove($flags, "ZEND_ACC_FINAL", PHP_84_VERSION_ID);
|
||||
}
|
||||
|
||||
if ($this->flags & Modifiers::READONLY) {
|
||||
$flags = $this->addFlagForVersionsAbove($flags, "ZEND_ACC_READONLY", PHP_81_VERSION_ID);
|
||||
} elseif ($this->classFlags & Modifiers::READONLY) {
|
||||
|
@ -3125,6 +3129,11 @@ class PropertyInfo extends VariableLike
|
|||
$fieldsynopsisElement->appendChild($doc->createElement("modifier", "static"));
|
||||
}
|
||||
|
||||
if ($this->flags & Modifiers::FINAL) {
|
||||
$fieldsynopsisElement->appendChild(new DOMText("\n "));
|
||||
$fieldsynopsisElement->appendChild($doc->createElement("modifier", "final"));
|
||||
}
|
||||
|
||||
if ($this->flags & Modifiers::READONLY || $this->isDocReadonly) {
|
||||
$fieldsynopsisElement->appendChild(new DOMText("\n "));
|
||||
$fieldsynopsisElement->appendChild($doc->createElement("modifier", "readonly"));
|
||||
|
|
|
@ -55,6 +55,7 @@ namespace {
|
|||
public stdClass|Iterator|null $classUnionProp = null;
|
||||
public Traversable&Countable $classIntersectionProp;
|
||||
public readonly int $readonlyProp;
|
||||
public final int $finalProp;
|
||||
|
||||
public static function is_object(): int {}
|
||||
|
||||
|
|
12
ext/zend_test/test_arginfo.h
generated
12
ext/zend_test/test_arginfo.h
generated
|
@ -1,5 +1,5 @@
|
|||
/* This is a generated file, edit the .stub.php file instead.
|
||||
* Stub hash: a7b5de3e4868f9a4aef78da6b98bbce882e129a9 */
|
||||
* Stub hash: 3082e62e96d5f4383c98638513463c676a7c3a69 */
|
||||
|
||||
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_zend_test_array_return, 0, 0, IS_ARRAY, 0)
|
||||
ZEND_END_ARG_INFO()
|
||||
|
@ -719,6 +719,16 @@ static zend_class_entry *register_class__ZendTestClass(zend_class_entry *class_e
|
|||
#endif
|
||||
zend_string_release(property_readonlyProp_name);
|
||||
|
||||
zval property_finalProp_default_value;
|
||||
ZVAL_UNDEF(&property_finalProp_default_value);
|
||||
zend_string *property_finalProp_name = zend_string_init("finalProp", sizeof("finalProp") - 1, 1);
|
||||
#if (PHP_VERSION_ID >= 80400)
|
||||
zend_declare_typed_property(class_entry, property_finalProp_name, &property_finalProp_default_value, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG));
|
||||
#elif (PHP_VERSION_ID >= 80000)
|
||||
zend_declare_typed_property(class_entry, property_finalProp_name, &property_finalProp_default_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG));
|
||||
#endif
|
||||
zend_string_release(property_finalProp_name);
|
||||
|
||||
|
||||
zend_string *attribute_name_Deprecated_const_ZEND_TEST_DEPRECATED_ATTR_0 = zend_string_init_interned("Deprecated", sizeof("Deprecated") - 1, 1);
|
||||
zend_attribute *attribute_Deprecated_const_ZEND_TEST_DEPRECATED_ATTR_0 = zend_add_class_constant_attribute(class_entry, const_ZEND_TEST_DEPRECATED_ATTR, attribute_name_Deprecated_const_ZEND_TEST_DEPRECATED_ATTR_0, 1);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue