Skip to content

Commit

Permalink
Rename unused exception variables.
Browse files Browse the repository at this point in the history
  • Loading branch information
AndrolGenhald committed Feb 17, 2022
1 parent 6d1b2b0 commit b634873
Show file tree
Hide file tree
Showing 60 changed files with 126 additions and 126 deletions.
4 changes: 2 additions & 2 deletions examples/plugins/FunctionCasingChecker.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public static function afterMethodCallAnalysis(AfterMethodCallAnalysisEvent $eve
// fall through
}
}
} catch (Exception $e) {
} catch (Exception $_) {
// can throw if storage is missing
}
}
Expand Down Expand Up @@ -98,7 +98,7 @@ public static function afterFunctionCallAnalysis(AfterFunctionCallAnalysisEvent
// fall through
}
}
} catch (Exception $e) {
} catch (Exception $_) {
// can throw if storage is missing
}
}
Expand Down
12 changes: 6 additions & 6 deletions src/Psalm/Codebase.php
Original file line number Diff line number Diff line change
Expand Up @@ -946,7 +946,7 @@ public function invalidateInformationForFile(string $file_path): void

try {
$file_storage = $this->file_storage_provider->get($file_path);
} catch (InvalidArgumentException $e) {
} catch (InvalidArgumentException $_) {
return;
}

Expand Down Expand Up @@ -1086,7 +1086,7 @@ public function getSymbolInformation(string $file_path, string $symbol): ?array
'type' => '<?php ' . ($storage->abstract ? 'abstract ' : '') . 'class ' . $storage->name,
'description' => $storage->description,
];
} catch (InvalidArgumentException $e) {
} catch (InvalidArgumentException $_) {
}

if (strpos($symbol, '\\')) {
Expand Down Expand Up @@ -1198,7 +1198,7 @@ public function getSymbolLocation(string $file_path, string $symbol): ?CodeLocat
error_log($e->getMessage());

return null;
} catch (InvalidArgumentException $e) {
} catch (InvalidArgumentException $_) {
return null;
}
}
Expand Down Expand Up @@ -1348,7 +1348,7 @@ public function getSignatureInformation(
$params = $function_storage->params;
$signature_label = $function_storage->cased_name;
$signature_documentation = $function_storage->description;
} catch (Exception $exception) {
} catch (Exception $_) {
if (InternalCallMapHandler::inCallMap($function_symbol)) {
$callables = InternalCallMapHandler::getCallablesFromCallMap($function_symbol);

Expand Down Expand Up @@ -1608,7 +1608,7 @@ public function getCompletionItemsForPartialSymbol(
foreach ($file_storage->classlikes_in_file as $fq_class_name => $_) {
try {
$class_storage = $this->classlike_storage_provider->get($fq_class_name);
} catch (Exception $e) {
} catch (Exception $_) {
continue;
}

Expand Down Expand Up @@ -1683,7 +1683,7 @@ public function getCompletionItemsForPartialSymbol(
try {
$class_storage = $this->classlike_storage_provider->get($fq_class_name);
$description = $class_storage->description;
} catch (Exception $e) {
} catch (Exception $_) {
$description = null;
}

Expand Down
4 changes: 2 additions & 2 deletions src/Psalm/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -1637,7 +1637,7 @@ public function reportIssueInFile(string $issue_type, string $file_path): bool
try {
$file_storage = $codebase->file_storage_provider->get($file_path);
$dependent_files += $file_storage->required_by_file_paths;
} catch (InvalidArgumentException $e) {
} catch (InvalidArgumentException $_) {
// do nothing
}
}
Expand Down Expand Up @@ -2400,7 +2400,7 @@ public function getPHPVersionFromComposerJson(): ?string
if (file_exists($composer_json_path)) {
try {
$composer_json = json_decode(file_get_contents($composer_json_path), true, 512, JSON_THROW_ON_ERROR);
} catch (JsonException $e) {
} catch (JsonException $_) {
$composer_json = null;
}

Expand Down
2 changes: 1 addition & 1 deletion src/Psalm/Internal/Analyzer/AlgebraAnalyzer.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public static function checkForParadox(
): void {
try {
$negated_formula2 = Algebra::negateFormula($formula_2);
} catch (ComplicatedExpressionException $e) {
} catch (ComplicatedExpressionException $_) {
return;
}

Expand Down
10 changes: 5 additions & 5 deletions src/Psalm/Internal/Analyzer/ClassAnalyzer.php
Original file line number Diff line number Diff line change
Expand Up @@ -561,7 +561,7 @@ public function analyze(

try {
$trait_file_analyzer = $project_analyzer->getFileAnalyzerForClassLike($fq_trait_name);
} catch (Exception $e) {
} catch (Exception $_) {
continue;
}

Expand Down Expand Up @@ -909,7 +909,7 @@ public static function addContextProperties(
try {
$docBlock = DocComment::parsePreservingLength($docComment);
$suppressed = $docBlock->tags['psalm-suppress'] ?? [];
} catch (DocblockParseException $e) {
} catch (DocblockParseException $_) {
// do nothing to keep original behavior
}
}
Expand Down Expand Up @@ -2034,7 +2034,7 @@ private function checkImplementedInterfaces(

try {
$interface_storage = $classlike_storage_provider->get($fq_interface_name);
} catch (InvalidArgumentException $e) {
} catch (InvalidArgumentException $_) {
return false;
}

Expand Down Expand Up @@ -2068,7 +2068,7 @@ private function checkImplementedInterfaces(
foreach ($storage->class_implements as $fq_interface_name_lc => $fq_interface_name) {
try {
$interface_storage = $classlike_storage_provider->get($fq_interface_name_lc);
} catch (InvalidArgumentException $e) {
} catch (InvalidArgumentException $_) {
return false;
}

Expand Down Expand Up @@ -2389,7 +2389,7 @@ private function checkParentClass(
$code_location,
$storage->template_type_extends_count[$parent_fq_class_name] ?? 0
);
} catch (InvalidArgumentException $e) {
} catch (InvalidArgumentException $_) {
// do nothing
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/Psalm/Internal/Analyzer/ClassLikeAnalyzer.php
Original file line number Diff line number Diff line change
Expand Up @@ -818,7 +818,7 @@ public static function getClassesForFile(Codebase $codebase, string $file_path):
{
try {
return $codebase->file_storage_provider->get($file_path)->classlikes_in_file;
} catch (InvalidArgumentException $e) {
} catch (InvalidArgumentException $_) {
return [];
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/Psalm/Internal/Analyzer/CommentAnalyzer.php
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ public static function arrayToDocblocks(
$template_type_map,
$type_aliases
);
} catch (TypeParseTreeException $e) {
} catch (TypeParseTreeException $_) {
throw new DocblockParseException($line_parts[0] . ' is not a valid type');
}

Expand Down Expand Up @@ -161,7 +161,7 @@ public static function arrayToDocblocks(
$template_type_map ?: [],
$type_aliases ?: []
);
} catch (TypeParseTreeException $e) {
} catch (TypeParseTreeException $_) {
throw new DocblockParseException(
$line_parts[0] .
' is not a valid type' .
Expand Down
2 changes: 1 addition & 1 deletion src/Psalm/Internal/Analyzer/FileAnalyzer.php
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ public function analyze(

try {
$stmts = $codebase->getStatementsForFile($this->file_path);
} catch (PhpParser\Error $e) {
} catch (PhpParser\Error $_) {
return;
}

Expand Down
2 changes: 1 addition & 1 deletion src/Psalm/Internal/Analyzer/FunctionLikeAnalyzer.php
Original file line number Diff line number Diff line change
Expand Up @@ -1583,7 +1583,7 @@ public function getFunctionLikeStorage(?StatementsAnalyzer $statements_analyzer

try {
return $codebase_methods->getStorage($method_id);
} catch (UnexpectedValueException $e) {
} catch (UnexpectedValueException $_) {
$declaring_method_id = $codebase_methods->getDeclaringMethodId($method_id);

if ($declaring_method_id === null) {
Expand Down
2 changes: 1 addition & 1 deletion src/Psalm/Internal/Analyzer/InterfaceAnalyzer.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public function analyze(): void

try {
$extended_interface_storage = $codebase->classlike_storage_provider->get($extended_interface_name);
} catch (InvalidArgumentException $e) {
} catch (InvalidArgumentException $_) {
continue;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public static function analyze(
$cond_referenced_var_ids = $if_conditional_scope->cond_referenced_var_ids;
$assigned_in_conditional_var_ids = $if_conditional_scope->assigned_in_conditional_var_ids;
$entry_clauses = $if_conditional_scope->entry_clauses;
} catch (ScopeAnalysisException $e) {
} catch (ScopeAnalysisException $_) {
return false;
}

Expand Down Expand Up @@ -194,7 +194,7 @@ function (Clause $c) use ($assigned_in_conditional_var_ids, $elseif_cond_id): Cl
$negated_elseif_types = Algebra::getTruthsFromFormula(
Algebra::negateFormula($elseif_clauses)
);
} catch (ComplicatedExpressionException $e) {
} catch (ComplicatedExpressionException $_) {
$reconcilable_elseif_types = [];
$negated_elseif_types = [];
}
Expand Down Expand Up @@ -432,7 +432,7 @@ function (Clause $c) use ($assigned_in_conditional_var_ids, $elseif_cond_id): Cl
Algebra::negateFormula($elseif_clauses)
)
);
} catch (ComplicatedExpressionException $e) {
} catch (ComplicatedExpressionException $_) {
$if_scope->negated_clauses = [];
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ public static function analyze(
// this is the context for stuff that happens after the `if` block
$post_if_context = $if_conditional_scope->post_if_context;
$assigned_in_conditional_var_ids = $if_conditional_scope->assigned_in_conditional_var_ids;
} catch (ScopeAnalysisException $e) {
} catch (ScopeAnalysisException $_) {
return false;
}

Expand Down Expand Up @@ -204,7 +204,7 @@ function (Clause $c) use ($mixed_var_ids, $cond_object_id): Clause {

try {
$if_scope->negated_clauses = Algebra::negateFormula($if_clauses);
} catch (ComplicatedExpressionException $e) {
} catch (ComplicatedExpressionException $_) {
try {
$if_scope->negated_clauses = FormulaGenerator::getFormula(
$cond_object_id,
Expand All @@ -215,7 +215,7 @@ function (Clause $c) use ($mixed_var_ids, $cond_object_id): Clause {
$codebase,
false
);
} catch (ComplicatedExpressionException $e) {
} catch (ComplicatedExpressionException $_) {
$if_scope->negated_clauses = [];
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -465,7 +465,7 @@ public static function analyze(

try {
$negated_pre_condition_clauses = Algebra::negateFormula(array_merge(...$pre_condition_clauses));
} catch (ComplicatedExpressionException $e) {
} catch (ComplicatedExpressionException $_) {
$negated_pre_condition_clauses = [];
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -439,7 +439,7 @@ public static function analyze(
if ($case_clauses && $case_equality_expr) {
try {
$negated_case_clauses = Algebra::negateFormula($case_clauses);
} catch (ComplicatedExpressionException $e) {
} catch (ComplicatedExpressionException $_) {
$case_equality_expr_id = spl_object_id($case_equality_expr);

try {
Expand All @@ -453,7 +453,7 @@ public static function analyze(
false,
false
);
} catch (ComplicatedExpressionException $e) {
} catch (ComplicatedExpressionException $_) {
$negated_case_clauses = [];
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ public static function analyze(
$statements_analyzer,
$context
);
} catch (UnexpectedValueException $e) {
} catch (UnexpectedValueException $_) {
// do nothing
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,7 @@ private static function analyzeOperand(
)) {
try {
$storage = $codebase->methods->getStorage($to_string_method_id);
} catch (UnexpectedValueException $e) {
} catch (UnexpectedValueException $_) {
continue;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ public static function analyze(
if ($stmt->left instanceof PhpParser\Node\Expr\BinaryOp\BooleanOr) {
$post_leaving_if_context = clone $context;
}
} catch (ScopeAnalysisException $e) {
} catch (ScopeAnalysisException $_) {
return false;
}
} else {
Expand Down Expand Up @@ -151,7 +151,7 @@ public static function analyze(

try {
$negated_left_clauses = Algebra::negateFormula($left_clauses);
} catch (ComplicatedExpressionException $e) {
} catch (ComplicatedExpressionException $_) {
try {
$negated_left_clauses = FormulaGenerator::getFormula(
$left_cond_id,
Expand All @@ -162,7 +162,7 @@ public static function analyze(
$codebase,
false
);
} catch (ComplicatedExpressionException $e) {
} catch (ComplicatedExpressionException $_) {
return false;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -468,7 +468,7 @@ private static function checkForImpureEqualityComparison(
'__tostring'
)
);
} catch (UnexpectedValueException $e) {
} catch (UnexpectedValueException $_) {
continue;
}

Expand Down Expand Up @@ -502,7 +502,7 @@ private static function checkForImpureEqualityComparison(
'__tostring'
)
);
} catch (UnexpectedValueException $e) {
} catch (UnexpectedValueException $_) {
continue;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,7 @@ private static function getHighOrderFuncStorage(

return $codebase->methods->getStorage($method_id);
}
} catch (UnexpectedValueException $e) {
} catch (UnexpectedValueException $_) {
return null;
}

Expand Down Expand Up @@ -605,7 +605,7 @@ private static function handleClosureArg(
$statements_analyzer->getFilePath(),
$closure_id
);
} catch (UnexpectedValueException $e) {
} catch (UnexpectedValueException $_) {
return;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -657,7 +657,7 @@ private static function checkClosureType(

try {
$method_storage = $codebase->methods->getStorage($function_id_part);
} catch (UnexpectedValueException $e) {
} catch (UnexpectedValueException $_) {
// the method may not exist, but we're suppressing that issue
continue;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -562,7 +562,7 @@ private static function handleNamedFunction(
$function_call_info->defined_constants = $function_storage->defined_constants;
$function_call_info->global_variables = $function_storage->global_variables;
}
} catch (UnexpectedValueException $e) {
} catch (UnexpectedValueException $_) {
$function_call_info->function_params = [
new FunctionLikeParameter('args', false, null, null, null, false, false, true)
];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ public static function fetch(
);
}
}
} catch (InvalidArgumentException $e) {
} catch (InvalidArgumentException $_) {
// this can happen when the function was defined in the Config startup script
$stmt_type = Type::getMixed();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ public static function analyze(

try {
$method_storage = $codebase->methods->getStorage($declaring_method_id ?? $method_id);
} catch (UnexpectedValueException $e) {
} catch (UnexpectedValueException $_) {
$method_storage = null;
}

Expand Down

0 comments on commit b634873

Please sign in to comment.