mirror of
https://github.com/php/php-src.git
synced 2024-10-02 23:36:16 +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.
35 lines
598 B
PHP
35 lines
598 B
PHP
--TEST--
|
|
Bug #55137 (Legacy constructor not registered for class)
|
|
--FILE--
|
|
<?php
|
|
|
|
// All constructors should be registered as such
|
|
|
|
trait TConstructor {
|
|
public function constructor() {
|
|
echo "ctor executed\n";
|
|
}
|
|
}
|
|
|
|
class NewConstructor {
|
|
use TConstructor {
|
|
constructor as __construct;
|
|
}
|
|
}
|
|
|
|
class LegacyConstructor {
|
|
use TConstructor {
|
|
constructor as LegacyConstructor;
|
|
}
|
|
}
|
|
|
|
echo "New constructor: ";
|
|
$o = new NewConstructor;
|
|
|
|
echo "Legacy constructor: ";
|
|
$o = new LegacyConstructor;
|
|
|
|
--EXPECT--
|
|
New constructor: ctor executed
|
|
Legacy constructor: ctor executed
|