Skip to content

Commit 38e31bf

Browse files
committed
Do not use deprecated getLine()
1 parent b399171 commit 38e31bf

File tree

69 files changed

+172
-172
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

69 files changed

+172
-172
lines changed

src/Analyser/FileAnalyser.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -104,18 +104,18 @@ public function analyseFile(
104104
}
105105

106106
$uniquedAnalysedCodeExceptionMessages[$e->getMessage()] = true;
107-
$fileErrors[] = (new Error($e->getMessage(), $file, $node->getLine(), $e, null, null, $e->getTip()))->withIdentifier('phpstan.internal');
107+
$fileErrors[] = (new Error($e->getMessage(), $file, $node->getStartLine(), $e, null, null, $e->getTip()))->withIdentifier('phpstan.internal');
108108
continue;
109109
} catch (IdentifierNotFound $e) {
110-
$fileErrors[] = (new Error(sprintf('Reflection error: %s not found.', $e->getIdentifier()->getName()), $file, $node->getLine(), $e, null, null, 'Learn more at https://phpstan.org/user-guide/discovering-symbols'))->withIdentifier('phpstan.reflection');
110+
$fileErrors[] = (new Error(sprintf('Reflection error: %s not found.', $e->getIdentifier()->getName()), $file, $node->getStartLine(), $e, null, null, 'Learn more at https://phpstan.org/user-guide/discovering-symbols'))->withIdentifier('phpstan.reflection');
111111
continue;
112112
} catch (UnableToCompileNode | CircularReference $e) {
113-
$fileErrors[] = (new Error(sprintf('Reflection error: %s', $e->getMessage()), $file, $node->getLine(), $e))->withIdentifier('phpstan.reflection');
113+
$fileErrors[] = (new Error(sprintf('Reflection error: %s', $e->getMessage()), $file, $node->getStartLine(), $e))->withIdentifier('phpstan.reflection');
114114
continue;
115115
}
116116

117117
foreach ($ruleErrors as $ruleError) {
118-
$temporaryFileErrors[] = $this->ruleErrorTransformer->transform($ruleError, $scope, $nodeType, $node->getLine());
118+
$temporaryFileErrors[] = $this->ruleErrorTransformer->transform($ruleError, $scope, $nodeType, $node->getStartLine());
119119
}
120120
}
121121

@@ -128,13 +128,13 @@ public function analyseFile(
128128
}
129129

130130
$uniquedAnalysedCodeExceptionMessages[$e->getMessage()] = true;
131-
$fileErrors[] = (new Error($e->getMessage(), $file, $node->getLine(), $e, null, null, $e->getTip()))->withIdentifier('phpstan.internal');
131+
$fileErrors[] = (new Error($e->getMessage(), $file, $node->getStartLine(), $e, null, null, $e->getTip()))->withIdentifier('phpstan.internal');
132132
continue;
133133
} catch (IdentifierNotFound $e) {
134-
$fileErrors[] = (new Error(sprintf('Reflection error: %s not found.', $e->getIdentifier()->getName()), $file, $node->getLine(), $e, null, null, 'Learn more at https://phpstan.org/user-guide/discovering-symbols'))->withIdentifier('phpstan.reflection');
134+
$fileErrors[] = (new Error(sprintf('Reflection error: %s not found.', $e->getIdentifier()->getName()), $file, $node->getStartLine(), $e, null, null, 'Learn more at https://phpstan.org/user-guide/discovering-symbols'))->withIdentifier('phpstan.reflection');
135135
continue;
136136
} catch (UnableToCompileNode | CircularReference $e) {
137-
$fileErrors[] = (new Error(sprintf('Reflection error: %s', $e->getMessage()), $file, $node->getLine(), $e))->withIdentifier('phpstan.reflection');
137+
$fileErrors[] = (new Error(sprintf('Reflection error: %s', $e->getMessage()), $file, $node->getStartLine(), $e))->withIdentifier('phpstan.reflection');
138138
continue;
139139
}
140140

@@ -261,7 +261,7 @@ public function analyseFile(
261261
$fileErrors[] = (new Error($e->getMessage(), $file, $e->getStartLine() !== -1 ? $e->getStartLine() : null, $e))->withIdentifier('phpstan.parse');
262262
} catch (ParserErrorsException $e) {
263263
foreach ($e->getErrors() as $error) {
264-
$fileErrors[] = (new Error($error->getMessage(), $e->getParsedFile() ?? $file, $error->getStartLine() !== -1 ? $error->getStartLine() : null, $e))->withIdentifier('phpstan.parse');
264+
$fileErrors[] = (new Error($error->getMessage(), $e->getParsedFile() ?? $file, $error->getLine() !== -1 ? $error->getStartLine() : null, $e))->withIdentifier('phpstan.parse');
265265
}
266266
} catch (AnalysedCodeException $e) {
267267
$fileErrors[] = (new Error($e->getMessage(), $file, null, $e, null, null, $e->getTip()))->withIdentifier('phpstan.internal');

src/Analyser/NodeScopeResolver.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2853,7 +2853,7 @@ static function (Node $node, Scope $scope) use ($nodeCallback): void {
28532853
if ($arm->conds === null) {
28542854
$hasDefaultCond = true;
28552855
$matchArmBody = new MatchExpressionArmBody($matchScope, $arm->body);
2856-
$armNodes[] = new MatchExpressionArm($matchArmBody, [], $arm->getLine());
2856+
$armNodes[] = new MatchExpressionArm($matchArmBody, [], $arm->getStartLine());
28572857
$armResult = $this->processExprNode($arm->body, $matchScope, $nodeCallback, ExpressionContext::createTopLevel());
28582858
$matchScope = $armResult->getScope();
28592859
$hasYield = $hasYield || $armResult->hasYield();
@@ -2870,7 +2870,7 @@ static function (Node $node, Scope $scope) use ($nodeCallback): void {
28702870
$armCondScope = $matchScope;
28712871
$condNodes = [];
28722872
foreach ($arm->conds as $armCond) {
2873-
$condNodes[] = new MatchExpressionArmCondition($armCond, $armCondScope, $armCond->getLine());
2873+
$condNodes[] = new MatchExpressionArmCondition($armCond, $armCondScope, $armCond->getStartLine());
28742874
$armCondResult = $this->processExprNode($armCond, $armCondScope, $nodeCallback, $deepContext);
28752875
$hasYield = $hasYield || $armCondResult->hasYield();
28762876
$throwPoints = array_merge($throwPoints, $armCondResult->getThrowPoints());
@@ -2903,7 +2903,7 @@ static function (Node $node, Scope $scope) use ($nodeCallback): void {
29032903

29042904
$bodyScope = $matchScope->filterByTruthyValue($filteringExpr);
29052905
$matchArmBody = new MatchExpressionArmBody($bodyScope, $arm->body);
2906-
$armNodes[] = new MatchExpressionArm($matchArmBody, $condNodes, $arm->getLine());
2906+
$armNodes[] = new MatchExpressionArm($matchArmBody, $condNodes, $arm->getStartLine());
29072907

29082908
$armResult = $this->processExprNode(
29092909
$arm->body,

src/Broker/AnonymousClassNameHelper.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public function getAnonymousClassName(
3434

3535
return sprintf(
3636
'AnonymousClass%s',
37-
md5(sprintf('%s:%s', $filename, $classNode->getLine())),
37+
md5(sprintf('%s:%s', $filename, $classNode->getStartLine())),
3838
);
3939
}
4040

src/Command/AnalyseApplication.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -156,18 +156,18 @@ private function getCollectedDataErrors(array $collectedData, bool $onlyFiles):
156156
try {
157157
$ruleErrors = $rule->processNode($node, $scope);
158158
} catch (AnalysedCodeException $e) {
159-
$errors[] = (new Error($e->getMessage(), $file, $node->getLine(), $e, null, null, $e->getTip()))->withIdentifier('phpstan.internal');
159+
$errors[] = (new Error($e->getMessage(), $file, $node->getStartLine(), $e, null, null, $e->getTip()))->withIdentifier('phpstan.internal');
160160
continue;
161161
} catch (IdentifierNotFound $e) {
162-
$errors[] = (new Error(sprintf('Reflection error: %s not found.', $e->getIdentifier()->getName()), $file, $node->getLine(), $e, null, null, 'Learn more at https://phpstan.org/user-guide/discovering-symbols'))->withIdentifier('phpstan.reflection');
162+
$errors[] = (new Error(sprintf('Reflection error: %s not found.', $e->getIdentifier()->getName()), $file, $node->getStartLine(), $e, null, null, 'Learn more at https://phpstan.org/user-guide/discovering-symbols'))->withIdentifier('phpstan.reflection');
163163
continue;
164164
} catch (UnableToCompileNode | CircularReference $e) {
165-
$errors[] = (new Error(sprintf('Reflection error: %s', $e->getMessage()), $file, $node->getLine(), $e))->withIdentifier('phpstan.reflection');
165+
$errors[] = (new Error(sprintf('Reflection error: %s', $e->getMessage()), $file, $node->getStartLine(), $e))->withIdentifier('phpstan.reflection');
166166
continue;
167167
}
168168

169169
foreach ($ruleErrors as $ruleError) {
170-
$errors[] = $this->ruleErrorTransformer->transform($ruleError, $scope, $nodeType, $node->getLine());
170+
$errors[] = $this->ruleErrorTransformer->transform($ruleError, $scope, $nodeType, $node->getStartLine());
171171
}
172172
}
173173

src/Command/FixerWorkerCommand.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -321,18 +321,18 @@ private function getCollectedDataErrors(Container $container, array $collectedDa
321321
try {
322322
$ruleErrors = $rule->processNode($node, $scope);
323323
} catch (AnalysedCodeException $e) {
324-
$errors[] = (new Error($e->getMessage(), $file, $node->getLine(), $e, null, null, $e->getTip()))->withIdentifier('phpstan.internal');
324+
$errors[] = (new Error($e->getMessage(), $file, $node->getStartLine(), $e, null, null, $e->getTip()))->withIdentifier('phpstan.internal');
325325
continue;
326326
} catch (IdentifierNotFound $e) {
327-
$errors[] = (new Error(sprintf('Reflection error: %s not found.', $e->getIdentifier()->getName()), $file, $node->getLine(), $e, null, null, 'Learn more at https://phpstan.org/user-guide/discovering-symbols'))->withIdentifier('phpstan.reflection');
327+
$errors[] = (new Error(sprintf('Reflection error: %s not found.', $e->getIdentifier()->getName()), $file, $node->getStartLine(), $e, null, null, 'Learn more at https://phpstan.org/user-guide/discovering-symbols'))->withIdentifier('phpstan.reflection');
328328
continue;
329329
} catch (UnableToCompileNode | CircularReference $e) {
330-
$errors[] = (new Error(sprintf('Reflection error: %s', $e->getMessage()), $file, $node->getLine(), $e))->withIdentifier('phpstan.reflection');
330+
$errors[] = (new Error(sprintf('Reflection error: %s', $e->getMessage()), $file, $node->getStartLine(), $e))->withIdentifier('phpstan.reflection');
331331
continue;
332332
}
333333

334334
foreach ($ruleErrors as $ruleError) {
335-
$errors[] = $ruleErrorTransformer->transform($ruleError, $scope, $nodeType, $node->getLine());
335+
$errors[] = $ruleErrorTransformer->transform($ruleError, $scope, $nodeType, $node->getStartLine());
336336
}
337337
}
338338

src/Node/ClassPropertiesNode.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ public function getUninitializedProperties(
212212
) {
213213
$additionalAssigns[] = [
214214
$propertyName,
215-
$fetch->getLine(),
215+
$fetch->getStartLine(),
216216
$originalProperties[$propertyName],
217217
];
218218
}
@@ -232,7 +232,7 @@ public function getUninitializedProperties(
232232
if (!$hasInitialization->yes()) {
233233
$prematureAccess[] = [
234234
$propertyName,
235-
$fetch->getLine(),
235+
$fetch->getStartLine(),
236236
$originalProperties[$propertyName],
237237
$usageScope->getFile(),
238238
$usageScope->getFileDescription(),

src/Reflection/BetterReflection/BetterReflectionProvider.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ public function getAnonymousClassReflection(Node\Stmt\Class_ $classNode, Scope $
221221
$this->classReflectionExtensionRegistryProvider->getRegistry()->getPropertiesClassReflectionExtensions(),
222222
$this->classReflectionExtensionRegistryProvider->getRegistry()->getMethodsClassReflectionExtensions(),
223223
$this->classReflectionExtensionRegistryProvider->getRegistry()->getAllowedSubTypesClassReflectionExtensions(),
224-
sprintf('class@anonymous/%s:%s', $filename, $classNode->getLine()),
224+
sprintf('class@anonymous/%s:%s', $filename, $classNode->getStartLine()),
225225
new ReflectionClass($reflectionClass),
226226
$scopeFile,
227227
null,

src/Reflection/InitializerExprTypeResolver.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ public function getType(Expr $expr, InitializerExprContext $context): Type
153153
return $this->usePathConstantsAsConstantString ? $stringType : $stringType->generalize(GeneralizePrecision::moreSpecific());
154154
}
155155
if ($expr instanceof Line) {
156-
return new ConstantIntegerType($expr->getLine());
156+
return new ConstantIntegerType($expr->getStartLine());
157157
}
158158
if ($expr instanceof Expr\New_) {
159159
if ($expr->class instanceof Name) {

src/Rules/Arrays/DuplicateKeysInLiteralArraysRule.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public function processNode(Node $node, Scope $scope): array
6060
$printedValues[$value][] = $printedValue;
6161

6262
if (!isset($valueLines[$value])) {
63-
$valueLines[$value] = $item->getLine();
63+
$valueLines[$value] = $item->getStartLine();
6464
}
6565

6666
$previousCount = count($values);

src/Rules/Arrays/IterableInForeachRule.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public function processNode(Node $node, Scope $scope): array
4949
RuleErrorBuilder::message(sprintf(
5050
'Argument of an invalid type %s supplied for foreach, only iterables are supported.',
5151
$type->describe(VerbosityLevel::typeOnly()),
52-
))->identifier('foreach.nonIterable')->line($originalNode->expr->getLine())->build(),
52+
))->identifier('foreach.nonIterable')->line($originalNode->expr->getStartLine())->build(),
5353
];
5454
}
5555

0 commit comments

Comments
 (0)