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

PhanTypeModifyImmutableObjectProperty should be emitted for any scope other than readonly property's class definition #4710

Closed
TysonAndre opened this issue Aug 14, 2022 · 0 comments · Fixed by #4711
Assignees
Labels
enhancement This improves the quality of Phan's analysis of a codebase php8.1 Tracks changes to prepare for analyzing php 8.1 code

Comments

@TysonAndre
Copy link
Member

TysonAndre commented Aug 14, 2022

<?php
class X { public readonly int $x; }
// Should emit PhanTypeModifyImmutableObjectProperty. At runtime this throws
// > Error: Cannot initialize readonly property X::$x from scope Y
class Y extends X { public function __construct() { $this->x = 123; } }
$y = new Y();
// Emits PhanAccessReadOnlyProperty, should also emit PhanTypeModifyImmutableObjectProperty
$y->x = 123;
@TysonAndre TysonAndre added enhancement This improves the quality of Phan's analysis of a codebase php8.1 Tracks changes to prepare for analyzing php 8.1 code labels Aug 14, 2022
@TysonAndre TysonAndre self-assigned this Aug 14, 2022
@TysonAndre TysonAndre changed the title PhanAccessReadOnlyProperty should be emitted for any scope other than readonly property's class definition PhanTypeModifyImmutableObjectProperty should be emitted for any scope other than readonly property's class definition Aug 14, 2022
TysonAndre added a commit to TysonAndre/phan that referenced this issue Aug 14, 2022
This should have been emitted for assignments made anywhere outside of
the declaring class's scope

Closes phan#4710
TysonAndre added a commit to TysonAndre/phan that referenced this issue Aug 14, 2022
This should have been emitted for assignments made anywhere outside of
the declaring class's scope

Closes phan#4710
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement This improves the quality of Phan's analysis of a codebase php8.1 Tracks changes to prepare for analyzing php 8.1 code
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant