From 38a252af0d40d8c7607465615126752ce1b6049e Mon Sep 17 00:00:00 2001 From: Matthew Brown Date: Sun, 25 Apr 2021 15:43:03 -0400 Subject: [PATCH] Revert "Do not consider isset checks on static properties as redundant (#5525)" This reverts commit cd002e6a87bc453e740d4a60e3e3fc6a762f22bc. --- src/Psalm/Internal/Analyzer/ClassAnalyzer.php | 2 -- .../Expression/AssignmentAnalyzer.php | 1 - .../Type/NegatedAssertionReconciler.php | 1 - .../Type/SimpleAssertionReconciler.php | 2 -- src/Psalm/Internal/Type/TypeExpander.php | 1 - src/Psalm/Type/Union.php | 10 ------- tests/TypeReconciliation/IssetTest.php | 28 ------------------- 7 files changed, 45 deletions(-) diff --git a/src/Psalm/Internal/Analyzer/ClassAnalyzer.php b/src/Psalm/Internal/Analyzer/ClassAnalyzer.php index 073cfdafb4e..63985a95d31 100644 --- a/src/Psalm/Internal/Analyzer/ClassAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/ClassAnalyzer.php @@ -802,7 +802,6 @@ public static function addContextProperties( ) { $property_type->initialized = false; $property_type->from_property = true; - $property_type->from_static_property = $property_storage->is_static === true; } } else { $property_type = Type::getMixed(); @@ -810,7 +809,6 @@ public static function addContextProperties( if (!$property_storage->has_default && !$property_storage->is_promoted) { $property_type->initialized = false; $property_type->from_property = true; - $property_type->from_static_property = $property_storage->is_static === true; } } diff --git a/src/Psalm/Internal/Analyzer/Statements/Expression/AssignmentAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/Expression/AssignmentAnalyzer.php index a91030bf7c5..2a03e302b36 100644 --- a/src/Psalm/Internal/Analyzer/Statements/Expression/AssignmentAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/Statements/Expression/AssignmentAnalyzer.php @@ -255,7 +255,6 @@ public static function analyze( if ($assign_value_type) { $assign_value_type = clone $assign_value_type; $assign_value_type->from_property = false; - $assign_value_type->from_static_property = false; $assign_value_type->ignore_isset = false; } else { $assign_value_type = Type::getMixed(); diff --git a/src/Psalm/Internal/Type/NegatedAssertionReconciler.php b/src/Psalm/Internal/Type/NegatedAssertionReconciler.php index 58b439e7079..3ed836023a7 100644 --- a/src/Psalm/Internal/Type/NegatedAssertionReconciler.php +++ b/src/Psalm/Internal/Type/NegatedAssertionReconciler.php @@ -82,7 +82,6 @@ public static function reconcile( && $key && strpos($key, '[') === false && $key !== '$_SESSION' - && !$existing_var_type->from_static_property ) { foreach ($existing_var_type->getAtomicTypes() as $atomic) { if (!$existing_var_type->hasMixed() diff --git a/src/Psalm/Internal/Type/SimpleAssertionReconciler.php b/src/Psalm/Internal/Type/SimpleAssertionReconciler.php index 7bd43f13f99..257371c71e1 100644 --- a/src/Psalm/Internal/Type/SimpleAssertionReconciler.php +++ b/src/Psalm/Internal/Type/SimpleAssertionReconciler.php @@ -434,7 +434,6 @@ private static function reconcileIsset( && (!$did_remove_type || empty($existing_var_type->getAtomicTypes())) && $key && $code_location - && !$existing_var_type->from_static_property ) { self::triggerIssueForImpossible( $existing_var_type, @@ -459,7 +458,6 @@ private static function reconcileIsset( } $existing_var_type->from_property = false; - $existing_var_type->from_static_property = false; $existing_var_type->possibly_undefined = false; $existing_var_type->possibly_undefined_from_try = false; $existing_var_type->ignore_isset = false; diff --git a/src/Psalm/Internal/Type/TypeExpander.php b/src/Psalm/Internal/Type/TypeExpander.php index d2a23e0ce39..b4ad778ec51 100644 --- a/src/Psalm/Internal/Type/TypeExpander.php +++ b/src/Psalm/Internal/Type/TypeExpander.php @@ -78,7 +78,6 @@ public static function expandUnion( $fleshed_out_type->by_ref = $return_type->by_ref; $fleshed_out_type->initialized = $return_type->initialized; $fleshed_out_type->from_property = $return_type->from_property; - $fleshed_out_type->from_static_property = $return_type->from_static_property; $fleshed_out_type->had_template = $return_type->had_template; $fleshed_out_type->parent_nodes = $return_type->parent_nodes; diff --git a/src/Psalm/Type/Union.php b/src/Psalm/Type/Union.php index a4695c3d249..937c2c0cce5 100644 --- a/src/Psalm/Type/Union.php +++ b/src/Psalm/Type/Union.php @@ -56,16 +56,6 @@ class Union implements TypeNode */ public $from_property = false; - /** - * Whether the type originated from *static* property - * - * Unlike non-static properties, static properties have no prescribed place - * like __construct() to be initialized in - * - * @var bool - */ - public $from_static_property = false; - /** * Whether the property that this type has been derived from has been initialized in a constructor * diff --git a/tests/TypeReconciliation/IssetTest.php b/tests/TypeReconciliation/IssetTest.php index 2c7ff5a95cd..85400bc1e48 100644 --- a/tests/TypeReconciliation/IssetTest.php +++ b/tests/TypeReconciliation/IssetTest.php @@ -1006,34 +1006,6 @@ function foo(array $test) : void { echo $test[0]; }' ], - 'issetOnStaticProperty' => [ - ' [ - '