Skip to content

Commit 02de2b6

Browse files
committed
Pass a context wherever possible
1 parent 491dd74 commit 02de2b6

19 files changed

+64
-102
lines changed

src/Psalm/Codebase.php

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -741,14 +741,12 @@ public function fileExists(string $file_path): bool
741741
public function classOrInterfaceExists(
742742
string $fq_class_name,
743743
?CodeLocation $code_location = null,
744-
?string $calling_fq_class_name = null,
745-
?string $calling_method_id = null,
744+
?Context $context = null,
746745
): bool {
747746
return $this->classlikes->classOrInterfaceExists(
748747
$fq_class_name,
749748
$code_location,
750-
$calling_fq_class_name,
751-
$calling_method_id,
749+
$context,
752750
);
753751
}
754752

@@ -761,14 +759,12 @@ public function classOrInterfaceExists(
761759
public function classOrInterfaceOrEnumExists(
762760
string $fq_class_name,
763761
?CodeLocation $code_location = null,
764-
?string $calling_fq_class_name = null,
765-
?string $calling_method_id = null,
762+
?Context $context = null,
766763
): bool {
767764
return $this->classlikes->classOrInterfaceOrEnumExists(
768765
$fq_class_name,
769766
$code_location,
770-
$calling_fq_class_name,
771-
$calling_method_id,
767+
$context,
772768
);
773769
}
774770

@@ -787,14 +783,12 @@ public function classExtendsOrImplements(string $fq_class_name, string $possible
787783
public function classExists(
788784
string $fq_class_name,
789785
?CodeLocation $code_location = null,
790-
?string $calling_fq_class_name = null,
791-
?string $calling_method_id = null,
786+
?Context $context = null,
792787
): bool {
793788
return $this->classlikes->classExists(
794789
$fq_class_name,
795790
$code_location,
796-
$calling_fq_class_name,
797-
$calling_method_id,
791+
$context,
798792
);
799793
}
800794

@@ -826,14 +820,12 @@ public function classImplements(string $fq_class_name, string $interface): bool
826820
public function interfaceExists(
827821
string $fq_interface_name,
828822
?CodeLocation $code_location = null,
829-
?string $calling_fq_class_name = null,
830-
?string $calling_method_id = null,
823+
?Context $context = null,
831824
): bool {
832825
return $this->classlikes->interfaceExists(
833826
$fq_interface_name,
834827
$code_location,
835-
$calling_fq_class_name,
836-
$calling_method_id,
828+
$context,
837829
);
838830
}
839831

src/Psalm/Internal/Analyzer/AttributesAnalyzer.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,6 @@ private static function analyzeAttributeConstruction(
140140
$fq_attribute_name,
141141
$attribute_name_location,
142142
null,
143-
null,
144143
$suppressed_issues,
145144
new ClassLikeNameOptions(
146145
false,

src/Psalm/Internal/Analyzer/ClassAnalyzer.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2077,7 +2077,6 @@ private function checkImplementedInterfaces(
20772077
$fq_interface_name,
20782078
$interface_location,
20792079
null,
2080-
null,
20812080
$this->getSuppressedIssues(),
20822081
) === false) {
20832082
return false;
@@ -2371,7 +2370,6 @@ private function checkParentClass(
23712370
$parent_fq_class_name,
23722371
$parent_reference_location,
23732372
null,
2374-
null,
23752373
$storage->suppressed_issues + $this->getSuppressedIssues(),
23762374
) === false) {
23772375
return;

src/Psalm/Internal/Analyzer/ClassLikeAnalyzer.php

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -210,8 +210,7 @@ public static function checkFullyQualifiedClassLikeName(
210210
StatementsSource $statements_source,
211211
string $fq_class_name,
212212
CodeLocation $code_location,
213-
?string $calling_fq_class_name,
214-
?string $calling_method_id,
213+
?Context $context,
215214
array $suppressed_issues,
216215
?ClassLikeNameOptions $options = null,
217216
bool $check_classes = true,
@@ -265,22 +264,19 @@ public static function checkFullyQualifiedClassLikeName(
265264
$class_exists = $codebase->classlikes->classExists(
266265
$fq_class_name,
267266
!$options->inferred ? $code_location : null,
268-
$calling_fq_class_name,
269-
$calling_method_id,
267+
$context,
270268
);
271269

272270
$interface_exists = $codebase->classlikes->interfaceExists(
273271
$fq_class_name,
274272
!$options->inferred ? $code_location : null,
275-
$calling_fq_class_name,
276-
$calling_method_id,
273+
$context,
277274
);
278275

279276
$enum_exists = $codebase->classlikes->enumExists(
280277
$fq_class_name,
281278
!$options->inferred ? $code_location : null,
282-
$calling_fq_class_name,
283-
$calling_method_id,
279+
$context,
284280
);
285281

286282
if (!$class_exists

src/Psalm/Internal/Analyzer/FileAnalyzer.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,6 @@ public function analyze(
232232
$fq_source_classlike,
233233
$location,
234234
null,
235-
null,
236235
$this->suppressed_issues,
237236
new ClassLikeNameOptions(
238237
true,

src/Psalm/Internal/Analyzer/FunctionLikeAnalyzer.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -750,8 +750,7 @@ public function analyze(
750750
$statements_analyzer,
751751
$expected_exception,
752752
$storage->throw_locations[$expected_exception],
753-
$context->self,
754-
$context->calling_method_id,
753+
$context,
755754
$statements_analyzer->getSuppressedIssues(),
756755
new ClassLikeNameOptions(
757756
false,

src/Psalm/Internal/Analyzer/Statements/Block/ForeachAnalyzer.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -610,8 +610,7 @@ public static function checkIteratorType(
610610
$statements_analyzer,
611611
$iterator_atomic_type->value,
612612
new CodeLocation($statements_analyzer->getSource(), $expr),
613-
$context->self,
614-
$context->calling_method_id,
613+
$context,
615614
$statements_analyzer->getSuppressedIssues(),
616615
new ClassLikeNameOptions(true),
617616
) === false) {

src/Psalm/Internal/Analyzer/Statements/Block/TryAnalyzer.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -202,8 +202,7 @@ public static function analyze(
202202
$statements_analyzer,
203203
$fq_catch_class,
204204
new CodeLocation($statements_analyzer->getSource(), $catch_type, $context->include_location),
205-
$context->self,
206-
$context->calling_method_id,
205+
$context,
207206
$statements_analyzer->getSuppressedIssues(),
208207
new ClassLikeNameOptions(true),
209208
);

src/Psalm/Internal/Analyzer/Statements/Expression/AssertionFinder.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2695,7 +2695,6 @@ private static function getGetclassInequalityAssertions(
26952695
$var_type,
26962696
new CodeLocation($source, $whichclass_expr),
26972697
null,
2698-
null,
26992698
$source->getSuppressedIssues(),
27002699
) !== false
27012700
) {
@@ -3399,7 +3398,6 @@ private static function getGetclassEqualityAssertions(
33993398
$var_type,
34003399
new CodeLocation($source, $whichclass_expr),
34013400
null,
3402-
null,
34033401
$source->getSuppressedIssues(),
34043402
new ClassLikeNameOptions(true),
34053403
) === false

src/Psalm/Internal/Analyzer/Statements/Expression/Call/Method/AtomicMethodCallAnalyzer.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -180,8 +180,7 @@ public static function analyze(
180180
$statements_analyzer,
181181
$fq_class_name,
182182
new CodeLocation($source, $stmt->var),
183-
$context->self,
184-
$context->calling_method_id,
183+
$context,
185184
$statements_analyzer->getSuppressedIssues(),
186185
new ClassLikeNameOptions(true, false, true, true, $lhs_type_part->from_docblock),
187186
$context->check_classes,

0 commit comments

Comments
 (0)