Skip to content

Commit b418f33

Browse files
committed
Implemented FR #78638 (__PHP_Incomplete_Class should be final)
This should be minor and won't impact anyone
1 parent 3f3c1ad commit b418f33

File tree

3 files changed

+16
-2
lines changed

3 files changed

+16
-2
lines changed

NEWS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ PHP NEWS
8383
. Added SQLite3::setAuthorizer() and respective class constants. (bohwaz)
8484

8585
- Standard:
86+
. Implemented FR #78638 (__PHP_Incomplete_Class should be final). (Laruence)
8687
. Fixed bug #77204 (getimagesize(): Read error! should mention file path).
8788
(peter279k)
8889
. Fixed bug #76859 (stream_get_line skips data if used with data-generating

ext/standard/incomplete_class.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,9 +108,10 @@ static zend_object *php_create_incomplete_object(zend_class_entry *class_type)
108108

109109
PHPAPI zend_class_entry *php_create_incomplete_class(void)
110110
{
111-
zend_class_entry incomplete_class;
111+
zend_class_entry incomplete_class, *incomplete_class_entry;
112112

113113
INIT_CLASS_ENTRY(incomplete_class, INCOMPLETE_CLASS, NULL);
114+
114115
incomplete_class.create_object = php_create_incomplete_object;
115116

116117
memcpy(&php_incomplete_object_handlers, &std_object_handlers, sizeof(zend_object_handlers));
@@ -121,7 +122,10 @@ PHPAPI zend_class_entry *php_create_incomplete_class(void)
121122
php_incomplete_object_handlers.get_property_ptr_ptr = incomplete_class_get_property_ptr_ptr;
122123
php_incomplete_object_handlers.get_method = incomplete_class_get_method;
123124

124-
return zend_register_internal_class(&incomplete_class);
125+
incomplete_class_entry = zend_register_internal_class(&incomplete_class);
126+
incomplete_class_entry->ce_flags |= ZEND_ACC_FINAL;
127+
128+
return incomplete_class_entry;
125129
}
126130
/* }}} */
127131

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
--TEST--
2+
FR: #78638 (__PHP_Incomplete_Class should be final)
3+
--FILE--
4+
<?php
5+
$c = new class('bar') extends __PHP_Incomplete_Class {
6+
};
7+
?>
8+
--EXPECTF--
9+
Fatal error: Class class@anonymous may not inherit from final class (__PHP_Incomplete_Class) in %sbug78638.php on line %d

0 commit comments

Comments
 (0)