-
-
Notifications
You must be signed in to change notification settings - Fork 101
Open
Labels
Type: BugAn issue causing unintended or problematic behavior.An issue causing unintended or problematic behavior.
Description
Description
This code works fine:
class Foo
{
private(set) int $bar {
get {
return $this->bar ?? 0;
}
}
}
echo new Foo()->bar; // 0But Mago analyzer fails with:
error[invalid-property-read]: Cannot read private property `$bar` from class `Foo`.
┌─ test.php:12:17
│
5 │ ╭ private(set) int $bar {
6 │ │ get {
7 │ │ return $this->bar ?? 0;
8 │ │ }
9 │ │ }
│ ╰─────' Member is defined as `private` here
·
12 │ echo new Foo()->bar;
│ --^^^ This member is private and cannot be accessed here
│ │
│ Invalid access occurs here, from the global scope
│
= Help: Make the property `$bar` readable (e.g., `public`), or add a public getter method.
error[no-value]: The first value for `echo` cannot produce a value.
┌─ test.php:12:6
│
12 │ echo new Foo()->bar;
│ ---- ^^^^^^^^^^^^^^ This expression has type `never`
│ │
│ `echo` called here
│
= An expression of type `never` cannot complete, often because it throws or exits.
error: found 2 issues: 2 error(s)
Playground Link
https://mago.carthage.software/playground#019b6027-8521-e913-495d-af72594d2a8e
Reproduction
No response
Environment
- Mago: 1.0.3
- OS: Linux
- Installed via: Composer
Metadata
Metadata
Assignees
Labels
Type: BugAn issue causing unintended or problematic behavior.An issue causing unintended or problematic behavior.