mirror of
https://github.com/php/php-src.git
synced 2024-11-27 11:53:33 +08:00
064b464448
RFC: https://wiki.php.net/rfc/constructor_promotion Closes GH-5291.
22 lines
257 B
PHP
22 lines
257 B
PHP
--TEST--
|
|
Constructor promotion can be used inside a trait
|
|
--FILE--
|
|
<?php
|
|
|
|
trait Test {
|
|
public function __construct(public $prop) {}
|
|
}
|
|
|
|
class Test2 {
|
|
use Test;
|
|
}
|
|
|
|
var_dump(new Test2(42));
|
|
|
|
?>
|
|
--EXPECT--
|
|
object(Test2)#1 (1) {
|
|
["prop"]=>
|
|
int(42)
|
|
}
|