1
0
mirror of https://github.com/danog/psalm.git synced 2024-12-04 18:48:03 +01:00
psalm/docs/running_psalm/issues/PropertyNotSetInConstructor.md
Bruce Weirdan 8a41d61925
Apply suggestions from code review
Co-authored-by: AndrolGenhald <AndrolGenhald@users.noreply.github.com>
2022-02-06 00:49:27 +02:00

969 B
Raw Blame History

PropertyNotSetInConstructor

Unitialized properties are hard to statically analyze. To prevent mistakes, Psalm will enforce that all properties should be initialized.

It does that through MissingConstructor and this issue.

Psalm will then assume every property in the codebase is initialized.

Doing that allows it to report missing initializations as well as RedundantPropertyInitializationCheck

This issue is emitted when a non-null property without a default value is declared but not set in the classs constructor

If your project relies on having uninitialized properties, it is advised to suppress this issue, as well as MissingConstructor and RedundantPropertyInitializationCheck.

<?php

class A {
    /** @var string */
    public $foo;

    public function __construct() {}
}