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
Initialization of private trait members is not detected by psalm #3897
Labels
Comments
@psalm-github-bot, resolve this: https://psalm.dev/r/d316318ce2 |
I found these snippets: https://psalm.dev/r/d316318ce2<?php
trait a
{
private int $prop;
public function m(int $prop): void {
$this->prop = $prop;
}
}
class b
{
use a;
public function __construct()
{
$this->m(1);
}
}
|
Just like with normal setters they need to be defined |
I found these snippets: https://psalm.dev/r/18680465d4<?php
trait a
{
private int $prop;
public final function m(int $prop): void {
$this->prop = $prop;
}
}
class b
{
use a;
public function __construct()
{
$this->m(1);
}
}
|
The same issue is present if the method is aliased: https://psalm.dev/r/d8caf723b2 |
I found these snippets: https://psalm.dev/r/d8caf723b2<?php
trait a
{
private int $prop;
public final function m(int $prop): void {
$this->prop = $prop;
}
}
class b
{
use a {
m as final pony;
}
public function __construct()
{
$this->pony(1);
}
}
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Psalm cannot detect initialization of typed private trait properties, even when they are in fact indirectly initialized in the class constructor.
https://psalm.dev/r/d316318ce2
The text was updated successfully, but these errors were encountered: