-
Notifications
You must be signed in to change notification settings - Fork 663
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
UndefinedThisPropertyFetch despite property_exists() check #4182
Comments
I found these snippets: https://psalm.dev/r/6cfebb5320<?php
abstract class Base
{
public function getId(): mixed
{
if (!property_exists($this, 'id')) {
throw new \Exception("Missing id property.");
}
return $this->id;
}
}
https://psalm.dev/r/58bb4ad896<?php
abstract class Base
{
public function getId(): mixed
{
if (isset($this->id)) {
throw new \Exception("Missing id property.");
}
return $this->id;
}
}
|
Sorry, it should be https://psalm.dev/r/1b76e227ca Weirdly Psalm does NOT emit the |
I found these snippets: https://psalm.dev/r/1b76e227ca<?php
abstract class Base
{
public function getId(): mixed
{
if (!isset($this->id)) {
throw new \Exception("Missing id property.");
}
return $this->id;
}
}
|
duplicate of #2206 |
Reopening for https://psalm.dev/r/58bb4ad896 which is distinct from #2206. |
I found these snippets: https://psalm.dev/r/58bb4ad896<?php
abstract class Base
{
public function getId(): mixed
{
if (isset($this->id)) {
throw new \Exception("Missing id property.");
}
return $this->id;
}
}
|
This should not happen: |
I found these snippets: https://psalm.dev/r/d206ded407<?php
class Stuff
{
}
$value = new Stuff();
if (property_exists($value, 'nonExistingProperty')) {
if ($value->nonExistingProperty === 'someValue') {
return;
}
}
|
This now works: https://psalm.dev/r/58bb4ad896 |
I found these snippets: https://psalm.dev/r/58bb4ad896<?php
abstract class Base
{
public function getId(): mixed
{
if (isset($this->id)) {
throw new \Exception("Missing id property.");
}
return $this->id;
}
}
|
Closing this then. #2206 will track the property_exists issue |
Actually still broken. It should be a |
I found these snippets: https://psalm.dev/r/58bb4ad896<?php
abstract class Base
{
public function getId(): mixed
{
if (isset($this->id)) {
throw new \Exception("Missing id property.");
}
return $this->id;
}
}
|
https://psalm.dev/r/6cfebb5320
Shouldn't the
property_exists()
check have the same effect asisset()
?https://psalm.dev/r/58bb4ad896
The text was updated successfully, but these errors were encountered: