xref: /PHP-8.3/ext/pdo/tests/pdo_036.phpt (revision 74859783)
1--TEST--
2Testing PDORow and PDOStatement instances with Reflection
3--EXTENSIONS--
4pdo
5--FILE--
6<?php
7
8$instance = new reflectionclass('pdostatement');
9$x = $instance->newInstance();
10var_dump($x);
11
12// Allow initializing assignment.
13$x->queryString = "SELECT 1";
14var_dump($x);
15// But don't allow reassignment.
16try {
17    $x->queryString = "SELECT 2";
18    var_dump($x);
19} catch (Error $e) {
20    echo $e->getMessage(), "\n";
21}
22
23$instance = new reflectionclass('pdorow');
24$x = $instance->newInstance();
25var_dump($x);
26
27?>
28--EXPECTF--
29object(PDOStatement)#%d (0) {
30  ["queryString"]=>
31  uninitialized(string)
32}
33object(PDOStatement)#2 (1) {
34  ["queryString"]=>
35  string(8) "SELECT 1"
36}
37Property queryString is read only
38
39Fatal error: Uncaught PDOException: You may not create a PDORow manually in %spdo_036.php:%d
40Stack trace:
41#0 %spdo_036.php(%d): ReflectionClass->newInstance()
42#1 {main}
43  thrown in %spdo_036.php on line %d
44