Skip to content

Commit 275dfd8

Browse files
authored
Merge pull request #10610 from theodorejb/context-types
2 parents 3c90054 + 081fe2b commit 275dfd8

File tree

4 files changed

+6
-17
lines changed

4 files changed

+6
-17
lines changed

src/Psalm/Context.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ final class Context
8585
/**
8686
* A set of references that might still be in scope from a scope likely to cause confusion. This applies
8787
* to references set inside a loop or if statement, since it's easy to forget about PHP's weird scope
88-
* rules, and assinging to a reference will change the referenced variable rather than shadowing it.
88+
* rules, and assigning to a reference will change the referenced variable rather than shadowing it.
8989
*
9090
* @var array<string, CodeLocation>
9191
*/
@@ -112,7 +112,7 @@ final class Context
112112
public bool $inside_unset = false;
113113

114114
/**
115-
* Whether or not we're inside an class_exists call, where
115+
* Whether or not we're inside a class_exists call, where
116116
* we don't care about possibly undefined classes
117117
*/
118118
public bool $inside_class_exists = false;
@@ -207,9 +207,9 @@ final class Context
207207
/**
208208
* Stored to prevent re-analysing methods when checking for initialised properties
209209
*
210-
* @var array<string, bool>|null
210+
* @var array<string, bool>
211211
*/
212-
public ?array $initialized_methods = null;
212+
public array $initialized_methods = [];
213213

214214
/**
215215
* @var array<string, Union>

src/Psalm/Internal/Analyzer/Statements/Expression/Call/StaticMethod/ExistingAtomicStaticCallAnalyzer.php

-4
Original file line numberDiff line numberDiff line change
@@ -126,10 +126,6 @@ public static function analyze(
126126
}
127127

128128
if (!isset($context->initialized_methods[(string) $appearing_method_id])) {
129-
if ($context->initialized_methods === null) {
130-
$context->initialized_methods = [];
131-
}
132-
133129
$context->initialized_methods[(string) $appearing_method_id] = true;
134130

135131
$file_analyzer->getMethodMutations($appearing_method_id, $context);

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

-8
Original file line numberDiff line numberDiff line change
@@ -110,10 +110,6 @@ public static function collectSpecialInformation(
110110
return;
111111
}
112112

113-
if ($context->initialized_methods === null) {
114-
$context->initialized_methods = [];
115-
}
116-
117113
$context->initialized_methods[(string) $method_id] = true;
118114
}
119115

@@ -193,10 +189,6 @@ public static function collectSpecialInformation(
193189
return;
194190
}
195191

196-
if ($context->initialized_methods === null) {
197-
$context->initialized_methods = [];
198-
}
199-
200192
$context->initialized_methods[(string) $declaring_method_id] = true;
201193

202194
$method_storage = $codebase->methods->getStorage($declaring_method_id);

tests/Config/ConfigFileTest.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -285,8 +285,9 @@ protected static function compareContentWithTemplateAndTrailingLineEnding(string
285285
$passed = false;
286286

287287
foreach ([PHP_EOL, "\n", "\r", "\r\n"] as $eol) {
288-
if (!$passed && $contents === ($expected_template . $eol)) {
288+
if ($contents === ($expected_template . $eol)) {
289289
$passed = true;
290+
break;
290291
}
291292
}
292293

0 commit comments

Comments
 (0)