Annotation of embedaddon/php/ext/spl/tests/fixedarray_002.phpt, revision 1.1.1.1

1.1       misho       1: --TEST--
                      2: SPL: FixedArray: overloading
                      3: --INI--
                      4: allow_call_time_pass_reference=1
                      5: --FILE--
                      6: <?php
                      7: class A extends SplFixedArray {
                      8:     public function count() {
                      9:         return 2;
                     10:     }
                     11: 
                     12:     public function offsetGet($n) {
                     13:         echo "A::offsetGet\n";
                     14:         return parent::offsetGet($n);
                     15:     }
                     16:     public function offsetSet($n, $v) {
                     17:         echo "A::offsetSet\n";
                     18:         return parent::offsetSet($n, $v);
                     19:     }
                     20:     public function offsetUnset($n) {
                     21:         echo "A::offsetUnset\n";
                     22:         return parent::offsetUnset($n);
                     23:     }
                     24:     public function offsetExists($n) {
                     25:         echo "A::offsetExists\n";
                     26:         return parent::offsetExists($n);
                     27:     }
                     28: }
                     29: 
                     30: $a = new A;
                     31: 
                     32: // errors
                     33: try {
                     34:     $a[0] = "value1";
                     35: } catch (RuntimeException $e) {
                     36:     echo "Exception: ".$e->getMessage()."\n";
                     37: }
                     38: try {
                     39:     var_dump($a["asdf"]);
                     40: } catch (RuntimeException $e) {
                     41:     echo "Exception: ".$e->getMessage()."\n";
                     42: }
                     43: try {
                     44:     unset($a[-1]);
                     45: } catch (RuntimeException $e) {
                     46:     echo "Exception: ".$e->getMessage()."\n";
                     47: }
                     48: $a->setSize(10);
                     49: 
                     50: 
                     51: $a[0] = "value0";
                     52: $a[1] = "value1";
                     53: $a[2] = "value2";
                     54: $a[3] = "value3";
                     55: $ref = "value4";
                     56: $ref2 =&$ref;
                     57: $a[4] = $ref;
                     58: $ref = "value5";
                     59: 
                     60: unset($a[1]);
                     61: var_dump(isset($a[1]), isset($a[2]), empty($a[1]), empty($a[2]));
                     62: 
                     63: var_dump($a[0], $a[2], $a[3], $a[4]);
                     64: 
                     65: // countable
                     66: 
                     67: var_dump(count($a), $a->getSize(), count($a) == $a->getSize());
                     68: ?>
                     69: ===DONE===
                     70: --EXPECTF--
                     71: A::offsetSet
                     72: Exception: Index invalid or out of range
                     73: A::offsetGet
                     74: Exception: Index invalid or out of range
                     75: A::offsetUnset
                     76: Exception: Index invalid or out of range
                     77: A::offsetSet
                     78: A::offsetSet
                     79: A::offsetSet
                     80: A::offsetSet
                     81: A::offsetSet
                     82: A::offsetUnset
                     83: A::offsetExists
                     84: A::offsetExists
                     85: A::offsetExists
                     86: A::offsetExists
                     87: bool(false)
                     88: bool(true)
                     89: bool(true)
                     90: bool(false)
                     91: A::offsetGet
                     92: A::offsetGet
                     93: A::offsetGet
                     94: A::offsetGet
                     95: string(6) "value0"
                     96: string(6) "value2"
                     97: string(6) "value3"
                     98: string(6) "value4"
                     99: int(2)
                    100: int(10)
                    101: bool(false)
                    102: ===DONE===

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