xref: /PHP-5.4/Zend/tests/traits/bug55554b.phpt (revision e14354af)
1--TEST--
2Bug #55137 (Legacy constructor not registered for class)
3--FILE--
4<?php
5
6trait TConstructor {
7    public function foo() {
8        echo "foo executed\n";
9    }
10    public function bar() {
11        echo "bar executed\n";
12    }
13}
14
15class OverridingIsSilent1 {
16    use TConstructor {
17	    foo as __construct;
18	}
19
20	public function __construct() {
21	    echo "OverridingIsSilent1 __construct\n";
22	}
23}
24
25$o = new OverridingIsSilent1;
26
27class OverridingIsSilent2 {
28    use TConstructor {
29	    foo as OverridingIsSilent2;
30	}
31
32	public function OverridingIsSilent2() {
33	    echo "OverridingIsSilent2 OverridingIsSilent2\n";
34	}
35}
36
37$o = new OverridingIsSilent2;
38
39class ReportCollision {
40	use TConstructor {
41	    bar as ReportCollision;
42	    foo as __construct;
43	}
44}
45
46
47echo "ReportCollision: ";
48$o = new ReportCollision;
49
50
51--EXPECTF--
52OverridingIsSilent1 __construct
53OverridingIsSilent2 OverridingIsSilent2
54
55Fatal error: ReportCollision has colliding constructor definitions coming from traits in %s on line %d
56
57