mirror of
https://github.com/php/php-src.git
synced 2024-10-01 23:06:11 +00:00
e14354af21
# 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.
57 lines
1004 B
PHP
57 lines
1004 B
PHP
--TEST--
|
|
Bug #55137 (Legacy constructor not registered for class)
|
|
--FILE--
|
|
<?php
|
|
|
|
trait TConstructor {
|
|
public function foo() {
|
|
echo "foo executed\n";
|
|
}
|
|
public function bar() {
|
|
echo "bar executed\n";
|
|
}
|
|
}
|
|
|
|
class OverridingIsSilent1 {
|
|
use TConstructor {
|
|
foo as __construct;
|
|
}
|
|
|
|
public function __construct() {
|
|
echo "OverridingIsSilent1 __construct\n";
|
|
}
|
|
}
|
|
|
|
$o = new OverridingIsSilent1;
|
|
|
|
class OverridingIsSilent2 {
|
|
use TConstructor {
|
|
foo as OverridingIsSilent2;
|
|
}
|
|
|
|
public function OverridingIsSilent2() {
|
|
echo "OverridingIsSilent2 OverridingIsSilent2\n";
|
|
}
|
|
}
|
|
|
|
$o = new OverridingIsSilent2;
|
|
|
|
class ReportCollision {
|
|
use TConstructor {
|
|
bar as ReportCollision;
|
|
foo as __construct;
|
|
}
|
|
}
|
|
|
|
|
|
echo "ReportCollision: ";
|
|
$o = new ReportCollision;
|
|
|
|
|
|
--EXPECTF--
|
|
OverridingIsSilent1 __construct
|
|
OverridingIsSilent2 OverridingIsSilent2
|
|
|
|
Fatal error: ReportCollision has colliding constructor definitions coming from traits in %s on line %d
|
|
|