1--TEST--
2mysqli_fetch_object() - calling constructor on class wo constructor
3--EXTENSIONS--
4mysqli
5--SKIPIF--
6<?php
7require_once('skipifconnectfailure.inc');
8?>
9--FILE--
10<?php
11    require_once("connect.inc");
12
13    $tmp    = NULL;
14    $link   = NULL;
15
16    require('table.inc');
17    if (!$res = mysqli_query($link, "SELECT id AS ID, label FROM test AS TEST ORDER BY id LIMIT 5")) {
18        printf("[001] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
19    }
20
21    class mysqli_fetch_object_test {
22        public $ID;
23        public $label;
24        public $a = null;
25        public $b = null;
26
27        public function toString() {
28            var_dump($this);
29        }
30    }
31
32    printf("No exception with PHP:\n");
33    var_dump($obj = new mysqli_fetch_object_test(1, 2));
34
35    printf("\nException with mysqli. Note that at all other places we throws errors but no exceptions unless the error mode has been changed:\n");
36    try {
37        var_dump($obj = mysqli_fetch_object($res, 'mysqli_fetch_object_test', array(1, 2)));
38    } catch (Exception $e) {
39        printf("Exception: %s\n", $e->getMessage());
40    }
41
42    printf("\nFatal error with PHP (but no exception!):\n");
43    var_dump($obj->mysqli_fetch_object_test(1, 2));
44
45    mysqli_close($link);
46    print "done!";
47?>
48--CLEAN--
49<?php
50    require_once("clean_table.inc");
51?>
52--EXPECTF--
53No exception with PHP:
54object(mysqli_fetch_object_test)#%d (%d) {
55  ["ID"]=>
56  NULL
57  ["label"]=>
58  NULL
59  ["a"]=>
60  NULL
61  ["b"]=>
62  NULL
63}
64
65Exception with mysqli. Note that at all other places we throws errors but no exceptions unless the error mode has been changed:
66Exception: mysqli_fetch_object(): Argument #3 ($constructor_args) must be empty when the specified class (mysqli_fetch_object_test) does not have a constructor
67
68Fatal error with PHP (but no exception!):
69
70Fatal error: Uncaught Error: Call to undefined method mysqli_fetch_object_test::mysqli_fetch_object_test() in %s:%d
71Stack trace:
72#0 {main}
73  thrown in %s on line %d
74