From f0560728d852901fb91e1c055f08a17d84720376 Mon Sep 17 00:00:00 2001 From: Daniil Gentili Date: Mon, 7 Feb 2022 13:17:12 +0100 Subject: [PATCH 1/3] Invert meaning of dupe_key --- psalm-baseline.xml | 3 ++- src/Psalm/IssueBuffer.php | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/psalm-baseline.xml b/psalm-baseline.xml index b9895b46624..1983f4837a4 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -361,8 +361,9 @@ - + $type[0] + $type[0][0] diff --git a/src/Psalm/IssueBuffer.php b/src/Psalm/IssueBuffer.php index a89f053792b..94f38c4a357 100644 --- a/src/Psalm/IssueBuffer.php +++ b/src/Psalm/IssueBuffer.php @@ -293,7 +293,7 @@ public static function add(CodeIssue $e, bool $is_fixable = false): bool . $trace_var . '-' . $e->getShortLocation() . ':' . $e->code_location->getColumn() - . ' ' . $e->dupe_key; + . ' ' . ($e->dupe_key ?? $e->message); if ($reporting_level === Config::REPORT_INFO) { if ($is_tainted || !self::alreadyEmitted($emitted_key)) { @@ -518,7 +518,7 @@ public static function addIssues(array $issues_data): void . '-' . $issue->file_name . ':' . $issue->line_from . ':' . $issue->column_from - . ' ' . $issue->dupe_key; + . ' ' . ($issue->dupe_key ?? $issue->message); if (!self::alreadyEmitted($emitted_key)) { self::$issues_data[$file_path][] = $issue; From b69e22a33be8520bba9052d0bbabd5e6d525719c Mon Sep 17 00:00:00 2001 From: Daniil Gentili Date: Mon, 14 Mar 2022 11:16:17 +0100 Subject: [PATCH 2/3] Add a few additional dupes --- src/Psalm/Internal/Analyzer/AlgebraAnalyzer.php | 2 +- .../Analyzer/Statements/Expression/AssertionFinder.php | 4 ++-- .../Analyzer/Statements/Expression/BinaryOpAnalyzer.php | 8 ++++---- src/Psalm/Internal/Type/AssertionReconciler.php | 2 +- .../Internal/Type/SimpleNegatedAssertionReconciler.php | 4 ++-- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/Psalm/Internal/Analyzer/AlgebraAnalyzer.php b/src/Psalm/Internal/Analyzer/AlgebraAnalyzer.php index 813513decb4..7521d71f30d 100644 --- a/src/Psalm/Internal/Analyzer/AlgebraAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/AlgebraAnalyzer.php @@ -68,7 +68,7 @@ public static function checkForParadox( new RedundantCondition( $formula_2_clause . ' has already been asserted', new CodeLocation($statements_analyzer, $stmt), - null + 'already asserted ' . $formula_2_clause ), $statements_analyzer->getSuppressedIssues() ); diff --git a/src/Psalm/Internal/Analyzer/Statements/Expression/AssertionFinder.php b/src/Psalm/Internal/Analyzer/Statements/Expression/AssertionFinder.php index 5c3d8ec96ef..f5723f47918 100644 --- a/src/Psalm/Internal/Analyzer/Statements/Expression/AssertionFinder.php +++ b/src/Psalm/Internal/Analyzer/Statements/Expression/AssertionFinder.php @@ -3124,7 +3124,7 @@ private static function getEmptyArrayEqualityAssertions( new DocblockTypeContradiction( $var_type . ' does not contain an empty array', new CodeLocation($source, $conditional), - null + $var_type . ' !== []' ), $source->getSuppressedIssues() ); @@ -3133,7 +3133,7 @@ private static function getEmptyArrayEqualityAssertions( new TypeDoesNotContainType( $var_type . ' does not contain empty array', new CodeLocation($source, $conditional), - null + $var_type . ' !== []' ), $source->getSuppressedIssues() ); diff --git a/src/Psalm/Internal/Analyzer/Statements/Expression/BinaryOpAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/Expression/BinaryOpAnalyzer.php index 5a4108c0127..667583344e9 100644 --- a/src/Psalm/Internal/Analyzer/Statements/Expression/BinaryOpAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/Statements/Expression/BinaryOpAnalyzer.php @@ -292,7 +292,7 @@ public static function analyze( new DocblockTypeContradiction( $atomic_right_type . ' string length is not ' . $string_length, new CodeLocation($statements_analyzer, $stmt), - null + "strlen($atomic_right_type) !== $string_length" ), $statements_analyzer->getSuppressedIssues() ); @@ -301,7 +301,7 @@ public static function analyze( new TypeDoesNotContainType( $atomic_right_type . ' string length is not ' . $string_length, new CodeLocation($statements_analyzer, $stmt), - null + "strlen($atomic_right_type) !== $string_length" ), $statements_analyzer->getSuppressedIssues() ); @@ -312,7 +312,7 @@ public static function analyze( new RedundantConditionGivenDocblockType( $atomic_right_type . ' string length is never ' . $string_length, new CodeLocation($statements_analyzer, $stmt), - null + "strlen($atomic_right_type) !== $string_length" ), $statements_analyzer->getSuppressedIssues() ); @@ -321,7 +321,7 @@ public static function analyze( new RedundantCondition( $atomic_right_type . ' string length is never ' . $string_length, new CodeLocation($statements_analyzer, $stmt), - null + "strlen($atomic_right_type) !== $string_length" ), $statements_analyzer->getSuppressedIssues() ); diff --git a/src/Psalm/Internal/Type/AssertionReconciler.php b/src/Psalm/Internal/Type/AssertionReconciler.php index 7c9c53adccd..4e583f43365 100644 --- a/src/Psalm/Internal/Type/AssertionReconciler.php +++ b/src/Psalm/Internal/Type/AssertionReconciler.php @@ -1526,7 +1526,7 @@ private static function handleIsA( new TypeDoesNotContainType( 'Cannot allow string comparison to object for ' . $key, $code_location, - null + "no string comparison to $key" ), $suppressed_issues ); diff --git a/src/Psalm/Internal/Type/SimpleNegatedAssertionReconciler.php b/src/Psalm/Internal/Type/SimpleNegatedAssertionReconciler.php index 68b45b1f9b9..ff1b3dcdfad 100644 --- a/src/Psalm/Internal/Type/SimpleNegatedAssertionReconciler.php +++ b/src/Psalm/Internal/Type/SimpleNegatedAssertionReconciler.php @@ -125,7 +125,7 @@ public static function reconcile( 'Cannot resolve types for ' . $key . ' with docblock-defined type ' . $existing_var_type . ' and !isset assertion', $code_location, - null + 'cannot resolve !isset '.$existing_var_type. ' ' . $key ), $suppressed_issues ); @@ -135,7 +135,7 @@ public static function reconcile( 'Cannot resolve types for ' . $key . ' with type ' . $existing_var_type . ' and !isset assertion', $code_location, - null + 'cannot resolve !isset '.$existing_var_type. ' ' . $key ), $suppressed_issues ); From 25105ff4c20ce13cdc66663f1d22c06d46b0b9d8 Mon Sep 17 00:00:00 2001 From: Daniil Gentili Date: Fri, 1 Apr 2022 12:47:54 +0200 Subject: [PATCH 3/3] Remove unused suppress --- src/Psalm/Internal/LanguageServer/Server/TextDocument.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/Psalm/Internal/LanguageServer/Server/TextDocument.php b/src/Psalm/Internal/LanguageServer/Server/TextDocument.php index 8b5b92013bf..45bad8145c0 100644 --- a/src/Psalm/Internal/LanguageServer/Server/TextDocument.php +++ b/src/Psalm/Internal/LanguageServer/Server/TextDocument.php @@ -408,8 +408,6 @@ public function codeAction(TextDocumentIdentifier $textDocument, Range $range): * https://github.com/felixfbecker/php-language-server-protocol * See: * https://microsoft.github.io/language-server-protocol/specifications/specification-3-17/#workspaceEdit - * - * @psalm-suppress InvalidArgument */ $edit = new WorkspaceEdit([ $textDocument->uri => [