Annotation of embedaddon/php/Zend/tests/bug53748.phpt, revision 1.1.1.1

1.1       misho       1: --TEST--
                      2: Bug #53748 (Using traits lead to a segmentation fault)
                      3: --FILE--
                      4: <?php
                      5: 
                      6: trait Singleton {
                      7:   protected static $instances=array();
                      8:   abstract protected function __construct($config);
                      9:   public static function getInstance($config) {
                     10:     if (!isset(self::$instances[$serialize = serialize($config)])) {
                     11:       self::$instances[$serialize] = new self($config);
                     12:     }
                     13:     return self::$instances[$serialize];
                     14:   }
                     15: }
                     16: 
                     17: class MyHelloWorld {
                     18:   use Singleton;
                     19:   public function __construct($config)
                     20:   {
                     21:     var_dump( $config);
                     22:   }
                     23: }
                     24: 
                     25: 
                     26: $o= myHelloWorld::getInstance(1);
                     27: $o= myHelloWorld::getInstance(1);
                     28: $o= myHelloWorld::getInstance(2);
                     29: $o= myHelloWorld::getInstance(array(1=>2));
                     30: $o= myHelloWorld::getInstance(array(1=>2));
                     31: 
                     32: ?>
                     33: --EXPECTF--
                     34: int(1)
                     35: int(2)
                     36: array(1) {
                     37:   [1]=>
                     38:   int(2)
                     39: }

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