1--TEST--
2Pdo\Pgsql::setNoticeCallback catches Postgres "raise notice".
3--SKIPIF--
4<?php
5if (!extension_loaded('pdo') || !extension_loaded('pdo_pgsql')) die('skip not loaded');
6require_once dirname(__FILE__) . '/../../../ext/pdo/tests/pdo_test.inc';
7require_once dirname(__FILE__) . '/config.inc';
8PDOTest::skip();
9?>
10--FILE--
11<?php
12function disp($message) { echo trim($message)."\n"; }
13function attach($db, $prefix = '')
14{
15    global $flavor;
16    switch($flavor)
17    {
18        case 0:
19            $db->setNoticeCallback(function($message) use($prefix) { echo $prefix.trim($message)."\n"; });
20            // https://github.com/php/php-src/pull/4823#pullrequestreview-335623806
21            $eraseCallbackMemoryHere = (object)[1];
22            break;
23        case 1:
24            $closure = function($message) use($prefix) { echo $prefix.'('.get_class($this).')'.trim($message)."\n"; };
25            $db->setNoticeCallback($closure->bindTo(new \stdClass));
26            break;
27    }
28}
29echo "Testing with a simple inline closure:\n";
30$flavor = 0;
31require dirname(__FILE__) . '/issue78621.inc';
32echo "Testing with a postbound closure object:\n";
33++$flavor;
34require dirname(__FILE__) . '/issue78621.inc';
35?>
36--EXPECT--
37Testing with a simple inline closure:
38NOTICE:  I tampered your data, did you know?
39ReNOTICE:  I tampered your data, did you know?
40array(1) {
41  [0]=>
42  array(1) {
43    ["a"]=>
44    string(2) "oh"
45  }
46}
47Done
48Testing with a postbound closure object:
49(stdClass)NOTICE:  I tampered your data, did you know?
50Re(stdClass)NOTICE:  I tampered your data, did you know?
51array(1) {
52  [0]=>
53  array(1) {
54    ["a"]=>
55    string(2) "oh"
56  }
57}
58Done
59