php-src/Zend/tests/traits/bug55554a.phpt
Stefan Marr 7e4b9800f4 Fixed Bug #55554 (Legacy constructors not handled properly) [TRAITS] [DOC]
# 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.
2011-10-09 11:13:27 +00:00

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