Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Private property gets removed despite being used by get_object_vars #8904

Closed
uncaught opened this issue Nov 22, 2024 · 1 comment · Fixed by rectorphp/rector-src#6472
Closed
Labels

Comments

@uncaught
Copy link

uncaught commented Nov 22, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
2 participants