[php-src] Issue #15309: ReflectionClass can't detect readonly properties for mysqli
| From: | RV7PR | Date: | Fri, 09 Aug 2024 11:47:19 +0000 |
| Subject: | [php-src] Issue #15309: ReflectionClass can't detect readonly properties for mysqli | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-247468@lists.php.net to get a copy of this message | ||
Issue: https://github.com/php/php-src/issues/15309
Author: RV7PR
### Description
The following code:
```php
<?php
$reflection = new ReflectionClass(mysqli::class);
$props = [];
foreach ($reflection->getProperties() as $property) {
$props[] = $property->getName() . ' | readonly: ' . (int)
$property->isReadOnly();
}
print_r($props);
```
Resulted in this output:
```
Array
(
[0] => affected_rows | readonly: 0
[1] => client_info | readonly: 0
[2] => client_version | readonly: 0
[3] => connect_errno | readonly: 0
[4] => connect_error | readonly: 0
[5] => errno | readonly: 0
[6] => error | readonly: 0
[7] => error_list | readonly: 0
[8] => field_count | readonly: 0
[9] => host_info | readonly: 0
[10] => info | readonly: 0
[11] => insert_id | readonly: 0
[12] => server_info | readonly: 0
[13] => server_version | readonly: 0
[14] => sqlstate | readonly: 0
[15] => protocol_version | readonly: 0
[16] => thread_id | readonly: 0
[17] => warning_count | readonly: 0
)
```
But I expected this output instead:
```
Array
(
[0] => affected_rows | readonly: 1
[1] => client_info | readonly: 1
[2] => client_version | readonly: 1
[3] => connect_errno | readonly: 1
[4] => connect_error | readonly: 1
[5] => errno | readonly: 1
[6] => error | readonly: 1
[7] => error_list | readonly: 1
[8] => field_count | readonly: 1
[9] => host_info | readonly: 1
[10] => info | readonly: 1
[11] => insert_id | readonly: 1
[12] => server_info | readonly: 1
[13] => server_version | readonly: 1
[14] => sqlstate | readonly: 1
[15] => protocol_version | readonly: 1
[16] => thread_id | readonly: 1
[17] => warning_count | readonly: 1
)
```
### PHP Version
PHP 8.3.8
### Operating System
_No response_