xref: /PHP-8.2/Zend/tests/gh14456.phpt (revision cdb7677b)
1--TEST--
2GH-14456: Attempting to initialize class with private constructor calls destructor
3--FILE--
4<?php
5
6class PrivateUser {
7    private function __construct() {}
8    public function __destruct() {
9        echo 'Destructor for ', __CLASS__, PHP_EOL;
10    }
11}
12
13try {
14    new PrivateUser();
15} catch (Throwable $e) {
16    echo $e::class, ': ', $e->getMessage(), PHP_EOL;
17}
18?>
19--EXPECT--
20Error: Call to private PrivateUser::__construct() from global scope
21