"Fossies" - the Fresh Open Source Software Archive

Member "4.6.1/composer/pimple/pimple/ext/pimple/tests/006.phpt" (8 Apr 2021, 1109 Bytes) of package /linux/www/studip-4.6.1.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) PHP source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file.

    1 --TEST--
    2 Test complex class inheritance
    3 --SKIPIF--
    4 <?php if (!extension_loaded("pimple")) print "skip"; ?>
    5 --FILE--
    6 <?php 
    7 class MyPimple extends Pimple\Container
    8 {
    9     public function offsetget($o)
   10     {
   11         var_dump("hit offsetget in " . __CLASS__);
   12         return parent::offsetget($o);
   13     }
   14 }
   15 
   16 class TestPimple extends MyPimple
   17 {
   18     public function __construct($values)
   19     {
   20         array_shift($values);
   21         parent::__construct($values);
   22     }
   23     
   24     public function offsetget($o)
   25     {
   26         var_dump('hit offsetget in ' . __CLASS__);
   27         return parent::offsetget($o);
   28     }
   29     
   30     public function offsetset($o, $v)
   31     {
   32         var_dump('hit offsetset');
   33         return parent::offsetset($o, $v);
   34     }
   35 }
   36 
   37 $defaultValues = array('foo' => 'bar', 88 => 'baz');
   38 
   39 $p = new TestPimple($defaultValues);
   40 $p[42] = 'foo';
   41 var_dump($p[42]);
   42 var_dump($p[0]);
   43 ?>
   44 --EXPECT--
   45 string(13) "hit offsetset"
   46 string(27) "hit offsetget in TestPimple"
   47 string(25) "hit offsetget in MyPimple"
   48 string(3) "foo"
   49 string(27) "hit offsetget in TestPimple"
   50 string(25) "hit offsetget in MyPimple"
   51 string(3) "baz"