1--TEST-- 2ReflectionObject::getConstructor() - basic function test 3--FILE-- 4<?php 5class NewCtor { 6 function __construct() {} 7} 8 9class ExtendsNewCtor extends NewCtor { 10} 11 12class OldCtor { 13 function OldCtor() {} 14} 15 16class ExtendsOldCtor extends OldCtor { 17} 18 19 20class X { 21 function Y() {} 22} 23 24class Y extends X { 25} 26 27class OldAndNewCtor { 28 function OldAndNewCtor() {} 29 function __construct() {} 30} 31 32class NewAndOldCtor { 33 function __construct() {} 34 function NewAndOldCtor() {} 35} 36class B { 37 function B() {} 38} 39 40class C extends B { 41 function C() {} 42} 43 44class D1 extends C { 45 function __construct() {} 46} 47 48class D2 extends C { 49} 50 51$classes = array('NewCtor', 'ExtendsNewCtor', 'OldCtor', 'ExtendsOldCtor', 52 'OldAndNewCtor', 'NewAndOldCtor', 'B', 'C', 'D1', 'D2', 'X', 'Y'); 53 54foreach ($classes as $class) { 55 $rc = new ReflectionObject(new $class); 56 $rm = $rc->getConstructor(); 57 if ($rm != null) { 58 echo "Constructor of $class: " . $rm->getName() . "\n"; 59 } else { 60 echo "No constructor for $class\n"; 61 } 62 63} 64 65?> 66--EXPECTF-- 67Strict Standards: Redefining already defined constructor for class OldAndNewCtor in %s on line %d 68Constructor of NewCtor: __construct 69Constructor of ExtendsNewCtor: __construct 70Constructor of OldCtor: OldCtor 71Constructor of ExtendsOldCtor: OldCtor 72Constructor of OldAndNewCtor: __construct 73Constructor of NewAndOldCtor: __construct 74Constructor of B: B 75Constructor of C: C 76Constructor of D1: __construct 77Constructor of D2: C 78No constructor for X 79No constructor for Y 80