1--TEST--
2mysqli_fetch_object() - calling constructor on class wo constructor
3--SKIPIF--
4<?php
5require_once('skipif.inc');
6require_once('skipifemb.inc');
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
23        public $a = null;
24        public $b = null;
25
26        public function toString() {
27            var_dump($this);
28        }
29    }
30
31    printf("No exception with PHP:\n");
32    var_dump($obj = new mysqli_fetch_object_test(1, 2));
33
34    printf("\nException with mysqli. Note that at all other places we throws errors but no exceptions unless the error mode has been changed:\n");
35    try {
36        var_dump($obj = mysqli_fetch_object($res, 'mysqli_fetch_object_test', array(1, 2)));
37    } catch (Exception $e) {
38        printf("Exception: %s\n", $e->getMessage());
39    }
40
41    printf("\nFatal error with PHP (but no exception!):\n");
42    var_dump($obj->mysqli_fetch_object_test(1, 2));
43
44    mysqli_close($link);
45    print "done!";
46?>
47--CLEAN--
48<?php
49    require_once("clean_table.inc");
50?>
51--EXPECTF--
52No exception with PHP:
53object(mysqli_fetch_object_test)#%d (%d) {
54  ["a"]=>
55  NULL
56  ["b"]=>
57  NULL
58}
59
60Exception with mysqli. Note that at all other places we throws errors but no exceptions unless the error mode has been changed:
61Exception: Class mysqli_fetch_object_test does not have a constructor hence you cannot use ctor_params
62
63Fatal error with PHP (but no exception!):
64
65Fatal error: Uncaught Error: Call to undefined method mysqli_fetch_object_test::mysqli_fetch_object_test() in %s:%d
66Stack trace:
67#0 {main}
68  thrown in %s on line %d
69