mirror of
https://github.com/php/php-src.git
synced 2024-11-23 18:04:36 +08:00
Merge branch 'PHP-8.3'
* PHP-8.3: Fix bug GH-14456: Attempting to initialize class with private constructor calls destructor
This commit is contained in:
commit
3869a67468
20
Zend/tests/gh14456.phpt
Normal file
20
Zend/tests/gh14456.phpt
Normal file
@ -0,0 +1,20 @@
|
||||
--TEST--
|
||||
GH-14456: Attempting to initialize class with private constructor calls destructor
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
class PrivateUser {
|
||||
private function __construct() {}
|
||||
public function __destruct() {
|
||||
echo 'Destructor for ', __CLASS__, PHP_EOL;
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
new PrivateUser();
|
||||
} catch (Throwable $e) {
|
||||
echo $e::class, ': ', $e->getMessage(), PHP_EOL;
|
||||
}
|
||||
?>
|
||||
--EXPECT--
|
||||
Error: Call to private PrivateUser::__construct() from global scope
|
@ -1682,6 +1682,7 @@ ZEND_API zend_function *zend_std_get_constructor(zend_object *zobj) /* {{{ */
|
||||
if (UNEXPECTED(constructor->op_array.fn_flags & ZEND_ACC_PRIVATE)
|
||||
|| UNEXPECTED(!zend_check_protected(zend_get_function_root_class(constructor), scope))) {
|
||||
zend_bad_constructor_call(constructor, scope);
|
||||
zend_object_store_ctor_failed(zobj);
|
||||
constructor = NULL;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user