Skip to content

Commit

Permalink
Merge pull request #7475 from zoonru/methodsignaturemismatch_dupe
Browse files Browse the repository at this point in the history
Invert meaning of dupe_key
  • Loading branch information
orklah committed Apr 2, 2022
2 parents 5baf85e + 25105ff commit cab6f33
Show file tree
Hide file tree
Showing 8 changed files with 14 additions and 15 deletions.
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

0 comments on commit cab6f33

Please sign in to comment.