Skip to content

ReflectionProperty class and name properties are documented as Read-only, but they can be changed. #24147

Open

Description

@kamil-tekiela

Description

The following code:

<?php

class B {
    public string $x;
}

$prop = new ReflectionProperty('B', 'x');
$prop->class .= 'Z';                 

var_dump($prop->class, $prop->getDeclaringClass()->name);

Resulted in this output:

string(2) "BZ"
string(1) "B"

But I expected this output instead:

string(2) "B"
string(1) "B"

See https://www.php.net/manual/en/class.reflectionproperty.php#reflectionproperty.props

Activity

  1. added a commit that references this issue on Oct 13, 2026
    17e783e
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions