xref: /PHP-7.0/ext/pdo_sqlite/tests/bug43831.phpt (revision 3a1f79d5)
1--TEST--
2Bug #43831 ($this gets mangled when extending PDO with persistent connection)
3--SKIPIF--
4<?php if (!extension_loaded('pdo_sqlite')) print 'skip not loaded'; ?>
5--FILE--
6<?php
7
8class Foo extends PDO {
9	function __construct($dsn) {
10		parent::__construct($dsn, null, null, array(PDO::ATTR_PERSISTENT => true));
11	}
12}
13
14class Baz extends PDO {
15	function __construct($dsn) {
16		parent::__construct($dsn, null, null, array(PDO::ATTR_PERSISTENT => true));
17	}
18}
19
20class Bar extends Baz {
21	function quux() {
22		echo get_class($this), "\n";
23		$foo = new Foo("sqlite::memory:");
24		echo get_class($this), "\n";
25	}
26}
27
28$bar = new Bar("sqlite::memory:");
29$bar->quux();
30
31
32class MyPDO extends PDO {}
33
34$bar = new PDO("sqlite::memory:", null, null, array(PDO::ATTR_PERSISTENT => true));
35$baz = new MyPDO("sqlite::memory:", null, null, array(PDO::ATTR_PERSISTENT => true));
36
37var_dump($bar);
38unset($bar);
39var_dump($baz);
40var_dump($bar);
41
42
43?>
44--EXPECTF--
45Bar
46Bar
47object(PDO)#%d (0) {
48}
49object(MyPDO)#%d (0) {
50}
51
52Notice: Undefined variable: bar in %s on line %d
53NULL
54