Skip to content

Private property gets removed despite being used by get_object_vars #8904

Description

@uncaught

Bug Report

Subject Details
Rector version v1.2.10

Rector removes seemingly unused properties, but which are used by get_object_vars.

Minimal PHP Code Causing Issue

class Foo implements \JsonSerializable {
  public function __construct(private readonly string $foo) {
  }

  public function jsonSerialize(): array {
    return get_object_vars($this);
  }
}

Expected Behaviour

Rector should not remove property $foo here.


I would think that whenever there is a get_object_vars($this) in a class, rector should not remove any non-static properties or see them as used.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Fields

    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