2020-11-29 17:57:20 +01:00
# RedundantPropertyInitializationCheck
2022-02-05 23:49:27 +01:00
Unitialized properties are hard to statically analyze. To prevent mistakes, Psalm will enforce that all properties should be initialized.
2022-02-05 12:27:53 +01:00
2022-02-17 20:04:25 +01:00
It does that through [PropertyNotSetInConstructor ](./PropertyNotSetInConstructor.md ) and [MissingConstructor ](./MissingConstructor.md ).
2022-02-05 12:27:53 +01:00
Psalm will then assume every property in the codebase is initialized.
Doing that allows it to report missing initializations as well as this issue.
This issue is emitted when checking `isset()` on a non-nullable property. Because every property is assumed to be initialized, this check is redundant
2022-02-17 20:04:25 +01:00
If your project relies on having uninitialized properties, it is advised to suppress this issue, as well as [PropertyNotSetInConstructor ](./PropertyNotSetInConstructor.md ) and [MissingConstructor ](./MissingConstructor.md ).
2020-11-29 17:57:20 +01:00
```php
< ?php
class A {
public string $bar;
public function getBar() : string {
if (isset($this->bar)) {
return $this->bar;
}
return "hello";
}
}
```