[php-src] Issue #13177: PHP 8.3.2: final private constructor not allowed when used in trait
| From: | ondrejmirtes | Date: | Wed, 17 Jan 2024 12:30:05 +0000 |
| Subject: | [php-src] Issue #13177: PHP 8.3.2: final private constructor not allowed when used in trait | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-246281@lists.php.net to get a copy of this message | ||
Issue: https://github.com/php/php-src/issues/13177
Author: ondrejmirtes
### Description
The following code:
```php
<?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: https://github.com/php/php-src/pull/12857
Please make sure that the version with trait usage is also allowed:
```php
<?php
final class Foo {
use Bar {
__construct as final;
}
}
trait Bar {
private function __construct() {}
}
```
### PHP Version
PHP 8.3.2
### Operating System
N/A