File:  [ELWIX - Embedded LightWeight unIX -] / embedaddon / php / Zend / tests / bug53748.phpt
Revision 1.1.1.1 (vendor branch): download - view: text, annotated - select for diffs - revision graph
Tue May 29 12:34:36 2012 UTC (12 years, 10 months ago) by misho
Branches: php, MAIN
CVS tags: v5_4_3elwix, v5_4_29p0, v5_4_29, v5_4_20p0, v5_4_20, v5_4_17p0, v5_4_17, HEAD
php 5.4.3+patches

    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>