Annotation of embedaddon/php/ext/reflection/tests/ReflectionObject_isInstantiable_variation.phpt, revision 1.1.1.1

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

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>