Skip to content

ReflectionClass can't detect readonly properties for mysqli #15309

@RV7PR

Description

@RV7PR

Description

The following code:

<?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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions