1--TEST-- 2ReflectionClass::IsInstantiable() 3--FILE-- 4<?php 5class noCtor { 6} 7 8class publicCtorNew { 9 public function __construct() {} 10} 11 12class protectedCtorNew { 13 protected function __construct() {} 14} 15 16class privateCtorNew { 17 private function __construct() {} 18} 19 20class publicCtorOld { 21 public function publicCtorOld() {} 22} 23 24class protectedCtorOld { 25 protected function protectedCtorOld() {} 26} 27 28class privateCtorOld { 29 private function privateCtorOld() {} 30} 31 32 33$classes = array("noCtor", "publicCtorNew", "protectedCtorNew", "privateCtorNew", 34 "publicCtorOld", "protectedCtorOld", "privateCtorOld"); 35 36foreach($classes as $class ) { 37 $reflectionClass = new ReflectionClass($class); 38 echo "Is $class instantiable? "; 39 var_dump($reflectionClass->IsInstantiable()); 40} 41 42?> 43--EXPECTF-- 44Is noCtor instantiable? bool(true) 45Is publicCtorNew instantiable? bool(true) 46Is protectedCtorNew instantiable? bool(false) 47Is privateCtorNew instantiable? bool(false) 48Is publicCtorOld instantiable? bool(true) 49Is protectedCtorOld instantiable? bool(false) 50Is privateCtorOld instantiable? bool(false) 51