Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Invert meaning of dupe_key #7475

Merged
merged 3 commits into from Apr 2, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 2 additions & 1 deletion psalm-baseline.xml
Expand Up @@ -361,8 +361,9 @@
</PossiblyUndefinedIntArrayOffset>
</file>
<file src="src/Psalm/Type/Reconciler.php">
<PossiblyUndefinedIntArrayOffset occurrences="1">
<PossiblyUndefinedIntArrayOffset occurrences="2">
<code>$type[0]</code>
<code>$type[0][0]</code>
</PossiblyUndefinedIntArrayOffset>
</file>
<file src="vendor/nikic/php-parser/lib/PhpParser/Node/Expr/ArrowFunction.php">
Expand Down
2 changes: 1 addition & 1 deletion src/Psalm/Internal/Analyzer/AlgebraAnalyzer.php
Expand Up @@ -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()
);
Expand Down
Expand Up @@ -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()
);
Expand All @@ -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()
);
Expand Down
Expand Up @@ -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()
);
Expand All @@ -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()
);
Expand All @@ -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()
);
Expand All @@ -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()
);
Expand Down
2 changes: 0 additions & 2 deletions src/Psalm/Internal/LanguageServer/Server/TextDocument.php
Expand Up @@ -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 => [
Expand Down
2 changes: 1 addition & 1 deletion src/Psalm/Internal/Type/AssertionReconciler.php
Expand Up @@ -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
);
Expand Down
4 changes: 2 additions & 2 deletions src/Psalm/Internal/Type/SimpleNegatedAssertionReconciler.php
Expand Up @@ -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
);
Expand All @@ -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
);
Expand Down
4 changes: 2 additions & 2 deletions src/Psalm/IssueBuffer.php
Expand Up @@ -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)) {
Expand Down Expand Up @@ -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;
Expand Down