Welcome to mirror list, hosted at ThFree Co, Russian Federation.

006.phpt « tests « pimple « ext « pimple « pimple « vendor « server - github.com/nextcloud/lookup-server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: cfe8a119e63a5a778890b0b21efe871a7f2fa437 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
--TEST--
Test complex class inheritance
--SKIPIF--
<?php if (!extension_loaded("pimple")) print "skip"; ?>
--FILE--
<?php 
class MyPimple extends Pimple\Container
{
    public function offsetget($o)
    {
        var_dump("hit offsetget in " . __CLASS__);
        return parent::offsetget($o);
    }
}

class TestPimple extends MyPimple
{
    public function __construct($values)
    {
        array_shift($values);
        parent::__construct($values);
    }
    
    public function offsetget($o)
    {
        var_dump('hit offsetget in ' . __CLASS__);
        return parent::offsetget($o);
    }
    
    public function offsetset($o, $v)
    {
        var_dump('hit offsetset');
        return parent::offsetset($o, $v);
    }
}

$defaultValues = array('foo' => 'bar', 88 => 'baz');

$p = new TestPimple($defaultValues);
$p[42] = 'foo';
var_dump($p[42]);
var_dump($p[0]);
?>
--EXPECT--
string(13) "hit offsetset"
string(27) "hit offsetget in TestPimple"
string(25) "hit offsetget in MyPimple"
string(3) "foo"
string(27) "hit offsetget in TestPimple"
string(25) "hit offsetget in MyPimple"
string(3) "baz"