Annotation of embedaddon/php/tests/classes/constants_basic_004.phpt, revision 1.1.1.1

1.1       misho       1: --TEST--
                      2: Test properties with array default values using class constants as keys and values. 
                      3: --FILE--
                      4: <?php
                      5:   class X
                      6:   {
                      7:       // Static and instance array using class constants
                      8:       public static $sa_x = array(B::KEY => B::VALUE);
                      9:       public $a_x = array(B::KEY => B::VALUE);
                     10:   }
                     11:   
                     12:   class B
                     13:   {
                     14:       const KEY = "key";
                     15:       const VALUE = "value";
                     16:       
                     17:       // Static and instance array using class constants with self
                     18:       public static $sa_b = array(self::KEY => self::VALUE);
                     19:       public $a_b = array(self::KEY => self::VALUE);
                     20:   }
                     21:   
                     22:   class C extends B
                     23:   {
                     24:       // Static and instance array using class constants with parent 
                     25:       public static $sa_c_parent = array(parent::KEY => parent::VALUE);
                     26:       public $a_c_parent = array(parent::KEY => parent::VALUE);
                     27:       
                     28:       // Static and instance array using class constants with self (constants should be inherited)
                     29:       public static $sa_c_self = array(self::KEY => self::VALUE);
                     30:       public $a_c_self = array(self::KEY => self::VALUE);
                     31:       
                     32:       // Should also include inherited properties from B.
                     33:   }
                     34:   
                     35:   echo "\nStatic properties:\n";
                     36:   var_dump(X::$sa_x, B::$sa_b, C::$sa_b, C::$sa_c_parent, C::$sa_c_self);
                     37:   
                     38:   echo "\nInstance properties:\n";
                     39:   $x = new x;
                     40:   $b = new B;
                     41:   $c = new C;
                     42:   var_dump($x, $b, $c);
                     43: ?>
                     44: --EXPECTF--
                     45: 
                     46: Static properties:
                     47: array(1) {
                     48:   ["key"]=>
                     49:   string(5) "value"
                     50: }
                     51: array(1) {
                     52:   ["key"]=>
                     53:   string(5) "value"
                     54: }
                     55: array(1) {
                     56:   ["key"]=>
                     57:   string(5) "value"
                     58: }
                     59: array(1) {
                     60:   ["key"]=>
                     61:   string(5) "value"
                     62: }
                     63: array(1) {
                     64:   ["key"]=>
                     65:   string(5) "value"
                     66: }
                     67: 
                     68: Instance properties:
                     69: object(X)#%d (1) {
                     70:   ["a_x"]=>
                     71:   array(1) {
                     72:     ["key"]=>
                     73:     string(5) "value"
                     74:   }
                     75: }
                     76: object(B)#%d (1) {
                     77:   ["a_b"]=>
                     78:   array(1) {
                     79:     ["key"]=>
                     80:     string(5) "value"
                     81:   }
                     82: }
                     83: object(C)#%d (3) {
                     84:   ["a_c_parent"]=>
                     85:   array(1) {
                     86:     ["key"]=>
                     87:     string(5) "value"
                     88:   }
                     89:   ["a_c_self"]=>
                     90:   array(1) {
                     91:     ["key"]=>
                     92:     string(5) "value"
                     93:   }
                     94:   ["a_b"]=>
                     95:   array(1) {
                     96:     ["key"]=>
                     97:     string(5) "value"
                     98:   }
                     99: }

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