php / php/php-src

ReflectionClass can't detect readonly properties for mysqli

Open
#15,309 8 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Extension: mysqli Feature Status: Needs Triage
Dominant language
C
Stars
40.4k
Forks
8.1k
Avg merge
2d 13h
Merged PRs (30d)
96

Description

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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the ReflectionClass and mysqli::class example from the report on PHP 8.3.8, then trace how mysqli properties are exposed to reflection. Done means the listed properties report readonly: 1, with regression coverage for this behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
c, php
Domain
backend, databases
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.