Skip to content

Commit a689ada

Browse files
committed
remove __clone method from __PHP_Incomplete_Class, use .clone_obj
1 parent 3d46122 commit a689ada

File tree

6 files changed

+10
-19
lines changed

6 files changed

+10
-19
lines changed

ext/standard/basic_functions.stub.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1488,7 +1488,6 @@
14881488
final class __PHP_Incomplete_Class
14891489
{
14901490
private function __construct() {}
1491-
private function __clone(): void {}
14921491
}
14931492

14941493
class AssertionError extends Error

ext/standard/basic_functions_arginfo.h

Lines changed: 1 addition & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ext/standard/basic_functions_decl.h

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ext/standard/incomplete_class.c

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -104,14 +104,9 @@ static ZEND_COLD zend_function *incomplete_class_get_constructor(zend_object *ob
104104

105105
ZEND_COLD ZEND_METHOD(__PHP_Incomplete_Class, __construct)
106106
{
107-
zend_throw_error(NULL, "Instantiation of class __PHP_Incomplete_Class is not allowed");
108-
}
109-
/* }}} */
107+
ZEND_PARSE_PARAMETERS_NONE();
110108

111-
/* {{{ Private clone preventing cloning */
112-
ZEND_COLD ZEND_METHOD(__PHP_Incomplete_Class, __clone)
113-
{
114-
zend_throw_error(NULL, "Cannot clone __PHP_Incomplete_Class using __clone()");
109+
zend_throw_error(NULL, "Instantiation of class __PHP_Incomplete_Class is not allowed");
115110
}
116111
/* }}} */
117112

@@ -139,6 +134,7 @@ PHPAPI void php_register_incomplete_class_handlers(void)
139134
php_incomplete_object_handlers.write_property = incomplete_class_write_property;
140135
php_incomplete_object_handlers.get_property_ptr_ptr = incomplete_class_get_property_ptr_ptr;
141136
php_incomplete_object_handlers.get_method = incomplete_class_get_method;
137+
php_incomplete_object_handlers.clone_obj = NULL;
142138

143139
php_ce_incomplete_class->create_object = php_create_incomplete_object;
144140
}

ext/standard/tests/serialize/incomplete_class_clone.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ var_dump(clone($o));
1313
string(22) "__PHP_Incomplete_Class"
1414
bool(false)
1515

16-
Fatal error: Uncaught Error: Call to private method __PHP_Incomplete_Class::__clone() from global scope in %s:%d
16+
Fatal error: Uncaught Error: Trying to clone an uncloneable object of class __PHP_Incomplete_Class in %s:%d
1717
Stack trace:
1818
#0 {main}
1919
thrown in %s on line %d

ext/standard/tests/serialize/incomplete_class_constructor.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ var_dump(new __PHP_Incomplete_Class());
88
--EXPECTF--
99
string(22) "__PHP_Incomplete_Class"
1010

11-
Fatal error: Uncaught Error: Call to private __PHP_Incomplete_Class::__construct() from global scope in %s:%d
11+
Fatal error: Uncaught Error: Instantiation of class Closure is not allowed in %s:%d
1212
Stack trace:
1313
#0 {main}
1414
thrown in %s on line %d

0 commit comments

Comments
 (0)