Closed
Description
Description
The following code:
<?php
final class Foo {
use Bar;
}
trait Bar {
final private function __construct() {}
}
Resulted in this output:
Warning: Private methods cannot be final as they are never overridden by other classes in /in/4sc3H on line 3
But I expected this output instead:
No error
Constructors CAN be private AND final, as opposed to normal methods.
This is a wrong side effect of this fix: #12857
Please make sure that the version with trait usage is also allowed:
<?php
final class Foo {
use Bar {
__construct as final;
}
}
trait Bar {
private function __construct() {}
}
PHP Version
PHP 8.3.2
Operating System
N/A