Return to ctor_visibility.phpt CVS log | Up to [ELWIX - Embedded LightWeight unIX -] / embedaddon / php / tests / classes |
1.1 ! misho 1: --TEST-- ! 2: ZE2 A private constructor cannot be called ! 3: --FILE-- ! 4: <?php ! 5: ! 6: class Test ! 7: { ! 8: function __construct() ! 9: { ! 10: echo __METHOD__ . "()\n"; ! 11: } ! 12: } ! 13: ! 14: class Derived extends Test ! 15: { ! 16: function __construct() ! 17: { ! 18: echo __METHOD__ . "()\n"; ! 19: parent::__construct(); ! 20: } ! 21: ! 22: static function f() ! 23: { ! 24: new Derived; ! 25: } ! 26: } ! 27: ! 28: Derived::f(); ! 29: ! 30: class TestPriv ! 31: { ! 32: private function __construct() ! 33: { ! 34: echo __METHOD__ . "()\n"; ! 35: } ! 36: ! 37: static function f() ! 38: { ! 39: new TestPriv; ! 40: } ! 41: } ! 42: ! 43: TestPriv::f(); ! 44: ! 45: class DerivedPriv extends TestPriv ! 46: { ! 47: function __construct() ! 48: { ! 49: echo __METHOD__ . "()\n"; ! 50: parent::__construct(); ! 51: } ! 52: ! 53: static function f() ! 54: { ! 55: new DerivedPriv; ! 56: } ! 57: } ! 58: ! 59: DerivedPriv::f(); ! 60: ! 61: ?> ! 62: ===DONE=== ! 63: --EXPECTF-- ! 64: Derived::__construct() ! 65: Test::__construct() ! 66: TestPriv::__construct() ! 67: DerivedPriv::__construct() ! 68: ! 69: Fatal error: Cannot call private TestPriv::__construct() in %sctor_visibility.php on line %d