mirror of
https://github.com/php/php-src.git
synced 2024-10-02 23:36:16 +00:00
7e4b9800f4
# The handling of legacy constructors defined by traits was corrected. # They are now properly registered and used on instantiation. # The situation for conflicting legacy and __construct constructors is # mostly identical. If they are defined in the class, they override conflicts # and do not collide. However, in case different styles are mixed, between # class and trait definition, we assume a programmer's mistake and report # a collision. # # BTW: +1 for all the fixed tests! `make test` is fun again.
33 lines
740 B
PHP
33 lines
740 B
PHP
--TEST--
|
|
Bug #55137 (Legacy constructor not registered for class)
|
|
--FILE--
|
|
<?php
|
|
|
|
// Test mixed constructors from different traits, we are more strict about
|
|
// these cases, since that can lead to un-expected behavior.
|
|
// It is not consistent with the normal constructor handling, but
|
|
// here we have a chance to be more strict for the new traits.
|
|
|
|
trait TNew {
|
|
public function __construct() {
|
|
echo "TNew executed\n";
|
|
}
|
|
}
|
|
|
|
trait TLegacy {
|
|
public function ReportCollision() {
|
|
echo "ReportCollision executed\n";
|
|
}
|
|
}
|
|
|
|
class ReportCollision {
|
|
use TNew, TLegacy;
|
|
}
|
|
|
|
$o = new ReportCollision;
|
|
|
|
--EXPECTF--
|
|
|
|
Fatal error: ReportCollision has colliding constructor definitions coming from traits in %s on line %d
|
|
|