1--TEST-- 2ZE2 A private constructor cannot be called 3--FILE-- 4<?php 5 6class Test 7{ 8 function __construct() 9 { 10 echo __METHOD__ . "()\n"; 11 } 12} 13 14class 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 28Derived::f(); 29 30class TestPriv 31{ 32 private function __construct() 33 { 34 echo __METHOD__ . "()\n"; 35 } 36 37 static function f() 38 { 39 new TestPriv; 40 } 41} 42 43TestPriv::f(); 44 45class 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 59DerivedPriv::f(); 60 61?> 62===DONE=== 63--EXPECTF-- 64Derived::__construct() 65Test::__construct() 66TestPriv::__construct() 67DerivedPriv::__construct() 68 69Fatal error: Cannot call private TestPriv::__construct() in %sctor_visibility.php on line %d 70