1--TEST-- 2ReflectionObject::IsInstantiable() - variation - constructors 3--FILE-- 4<?php 5 6class noCtor { 7 public static function reflectionObjectFactory() { 8 return new ReflectionObject(new self); 9 } 10} 11 12class publicCtorNew { 13 public function __construct() {} 14 public static function reflectionObjectFactory() { 15 return new ReflectionObject(new self); 16 } 17} 18 19class protectedCtorNew { 20 protected function __construct() {} 21 public static function reflectionObjectFactory() { 22 return new ReflectionObject(new self); 23 } 24} 25 26class privateCtorNew { 27 private function __construct() {} 28 public static function reflectionObjectFactory() { 29 return new ReflectionObject(new self); 30 } 31} 32 33class publicCtorOld { 34 public function publicCtorOld() {} 35 public static function reflectionObjectFactory() { 36 return new ReflectionObject(new self); 37 } 38} 39 40class protectedCtorOld { 41 protected function protectedCtorOld() {} 42 public static function reflectionObjectFactory() { 43 return new ReflectionObject(new self); 44 } 45} 46 47class privateCtorOld { 48 private function privateCtorOld() {} 49 public static function reflectionObjectFactory() { 50 return new ReflectionObject(new self); 51 } 52} 53 54 55$reflectionObjects = array( 56 noCtor::reflectionObjectFactory(), 57 publicCtorNew::reflectionObjectFactory(), 58 protectedCtorNew::reflectionObjectFactory(), 59 privateCtorNew::reflectionObjectFactory(), 60 publicCtorOld::reflectionObjectFactory(), 61 protectedCtorOld::reflectionObjectFactory(), 62 privateCtorOld::reflectionObjectFactory() 63 ); 64 65foreach($reflectionObjects as $reflectionObject ) { 66 $name = $reflectionObject->getName(); 67 echo "Is $name instantiable? "; 68 var_dump($reflectionObject->IsInstantiable()); 69} 70?> 71--EXPECTF-- 72Deprecated: 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 73 74Deprecated: 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 75 76Deprecated: 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 77Is noCtor instantiable? bool(true) 78Is publicCtorNew instantiable? bool(true) 79Is protectedCtorNew instantiable? bool(false) 80Is privateCtorNew instantiable? bool(false) 81Is publicCtorOld instantiable? bool(true) 82Is protectedCtorOld instantiable? bool(false) 83Is privateCtorOld instantiable? bool(false) 84