mirror of
https://github.com/php/php-src.git
synced 2026-03-24 00:02:20 +01:00
70 lines
1.3 KiB
PHP
70 lines
1.3 KiB
PHP
--TEST--
|
|
GH-13177 (PHP 8.3.2: final private constructor not allowed when used in trait)
|
|
--SKIPIF--
|
|
<?php
|
|
if (PHP_OS_FAMILY === 'Windows' && version_compare(PHP_VERSION, '8.4', '<')) {
|
|
die("xfail fails on Windows Server 2022 and newer.");
|
|
}
|
|
?>
|
|
--FILE--
|
|
<?php
|
|
|
|
trait Bar {
|
|
final private function __construct() {}
|
|
}
|
|
|
|
final class Foo1 {
|
|
use Bar;
|
|
}
|
|
|
|
final class Foo2 {
|
|
use Bar {
|
|
__construct as final;
|
|
}
|
|
}
|
|
|
|
class Foo3 {
|
|
use Bar {
|
|
__construct as final;
|
|
}
|
|
}
|
|
|
|
trait TraitNonConstructor {
|
|
private final function test() {}
|
|
}
|
|
|
|
class Foo4 {
|
|
use TraitNonConstructor { test as __construct; }
|
|
}
|
|
|
|
for ($i = 1; $i <= 4; $i++) {
|
|
$rc = new ReflectionClass("Foo$i");
|
|
echo $rc->getMethod("__construct"), "\n";
|
|
}
|
|
|
|
class Foo5 extends Foo3 {
|
|
private function __construct() {}
|
|
}
|
|
|
|
?>
|
|
--EXPECTF--
|
|
Warning: Private methods cannot be final as they are never overridden by other classes in %s on line %d
|
|
Method [ <user, ctor> final private method __construct ] {
|
|
@@ %sgh13177.php 4 - 4
|
|
}
|
|
|
|
Method [ <user, ctor> final private method __construct ] {
|
|
@@ %sgh13177.php 4 - 4
|
|
}
|
|
|
|
Method [ <user, ctor> final private method __construct ] {
|
|
@@ %sgh13177.php 4 - 4
|
|
}
|
|
|
|
Method [ <user, ctor> final private method __construct ] {
|
|
@@ %sgh13177.php 24 - 24
|
|
}
|
|
|
|
|
|
Fatal error: Cannot override final method Foo3::__construct() in %s on line %d
|