From: Xinchen Hui Date: Tue, 24 Dec 2019 09:09:44 +0000 (+0800) Subject: Implemented FR #78638 (__PHP_Incomplete_Class should be final) X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=b418f335d4a764c5d1d4ae59d6c1d0a0bd2550f4;p=php Implemented FR #78638 (__PHP_Incomplete_Class should be final) This should be minor and won't impact anyone --- diff --git a/NEWS b/NEWS index 1ff886df00..9ab884ee43 100644 --- a/NEWS +++ b/NEWS @@ -83,6 +83,7 @@ PHP NEWS . Added SQLite3::setAuthorizer() and respective class constants. (bohwaz) - Standard: + . Implemented FR #78638 (__PHP_Incomplete_Class should be final). (Laruence) . Fixed bug #77204 (getimagesize(): Read error! should mention file path). (peter279k) . Fixed bug #76859 (stream_get_line skips data if used with data-generating diff --git a/ext/standard/incomplete_class.c b/ext/standard/incomplete_class.c index 5e4c6ca203..c024373e7d 100644 --- a/ext/standard/incomplete_class.c +++ b/ext/standard/incomplete_class.c @@ -108,9 +108,10 @@ static zend_object *php_create_incomplete_object(zend_class_entry *class_type) PHPAPI zend_class_entry *php_create_incomplete_class(void) { - zend_class_entry incomplete_class; + zend_class_entry incomplete_class, *incomplete_class_entry; INIT_CLASS_ENTRY(incomplete_class, INCOMPLETE_CLASS, NULL); + incomplete_class.create_object = php_create_incomplete_object; 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) php_incomplete_object_handlers.get_property_ptr_ptr = incomplete_class_get_property_ptr_ptr; php_incomplete_object_handlers.get_method = incomplete_class_get_method; - return zend_register_internal_class(&incomplete_class); + incomplete_class_entry = zend_register_internal_class(&incomplete_class); + incomplete_class_entry->ce_flags |= ZEND_ACC_FINAL; + + return incomplete_class_entry; } /* }}} */ diff --git a/ext/standard/tests/class_object/bug78638.phpt b/ext/standard/tests/class_object/bug78638.phpt new file mode 100644 index 0000000000..088e7c4c1f --- /dev/null +++ b/ext/standard/tests/class_object/bug78638.phpt @@ -0,0 +1,9 @@ +--TEST-- +FR: #78638 (__PHP_Incomplete_Class should be final) +--FILE-- + +--EXPECTF-- +Fatal error: Class class@anonymous may not inherit from final class (__PHP_Incomplete_Class) in %sbug78638.php on line %d