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-- 44Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; publicCtorOld has a deprecated constructor in %s on line %d 45 46Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; protectedCtorOld has a deprecated constructor in %s on line %d 47 48Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; privateCtorOld has a deprecated constructor in %s on line %d 49Is noCtor instantiable? bool(true) 50Is publicCtorNew instantiable? bool(true) 51Is protectedCtorNew instantiable? bool(false) 52Is privateCtorNew instantiable? bool(false) 53Is publicCtorOld instantiable? bool(true) 54Is protectedCtorOld instantiable? bool(false) 55Is privateCtorOld instantiable? bool(false) 56