From e40bcc2d29fe3cda032106f49f2259d5541a7f03 Mon Sep 17 00:00:00 2001 From: orklah Date: Sat, 5 Feb 2022 12:27:53 +0100 Subject: [PATCH 1/2] doc about property initialization --- docs/running_psalm/issues/MissingConstructor.md | 12 +++++++++++- .../issues/PropertyNotSetInConstructor.md | 12 +++++++++++- .../issues/RedundantPropertyInitializationCheck.md | 12 +++++++++++- 3 files changed, 33 insertions(+), 3 deletions(-) diff --git a/docs/running_psalm/issues/MissingConstructor.md b/docs/running_psalm/issues/MissingConstructor.md index d14b9cc1b85..297a3e0c47b 100644 --- a/docs/running_psalm/issues/MissingConstructor.md +++ b/docs/running_psalm/issues/MissingConstructor.md @@ -1,6 +1,16 @@ # MissingConstructor -Emitted when non-null properties without default values are defined in a class without a `__construct` method +Unitialized properties are statically hard to analyze. To prevent mistakes, Psalm will enforce that all properties should be initialized. + +It does that through [PropertyNotSetInConstructor](issues/PropertyNotSetInConstructor.md) 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](issues/RedundantPropertyInitializationCheck.md) + +This issue is emitted when non-null properties without default values are defined in a class without a `__construct` method + +If your project rely on having uninitialized properties, it is advised to suppress this issue, as well as [PropertyNotSetInConstructor](issues/PropertyNotSetInConstructor.md) and [RedundantPropertyInitializationCheck](issues/RedundantPropertyInitializationCheck.md). ```php Date: Sun, 6 Feb 2022 00:49:27 +0200 Subject: [PATCH 2/2] Apply suggestions from code review Co-authored-by: AndrolGenhald --- docs/running_psalm/issues/PropertyNotSetInConstructor.md | 4 ++-- .../issues/RedundantPropertyInitializationCheck.md | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/running_psalm/issues/PropertyNotSetInConstructor.md b/docs/running_psalm/issues/PropertyNotSetInConstructor.md index 054b5f513f0..49cab27e4f4 100644 --- a/docs/running_psalm/issues/PropertyNotSetInConstructor.md +++ b/docs/running_psalm/issues/PropertyNotSetInConstructor.md @@ -1,6 +1,6 @@ # PropertyNotSetInConstructor -Unitialized properties are statically hard to analyze. To prevent mistakes, Psalm will enforce that all properties should be initialized. +Unitialized properties are hard to statically analyze. To prevent mistakes, Psalm will enforce that all properties should be initialized. It does that through [MissingConstructor](issues/MissingConstructor.md) and this issue. @@ -10,7 +10,7 @@ Doing that allows it to report missing initializations as well as [RedundantProp This issue is emitted when a non-null property without a default value is declared but not set in the class’s constructor -If your project rely on having uninitialized properties, it is advised to suppress this issue, as well as [MissingConstructor](issues/MissingConstructor.md) and [RedundantPropertyInitializationCheck](issues/RedundantPropertyInitializationCheck.md). +If your project relies on having uninitialized properties, it is advised to suppress this issue, as well as [MissingConstructor](issues/MissingConstructor.md) and [RedundantPropertyInitializationCheck](issues/RedundantPropertyInitializationCheck.md). ```php