Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix nikic/php-parser deprecation warnings #655

Merged
merged 1 commit into from
May 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions phpstan.neon.dist
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,3 @@ parameters:
-
message: '#^Instanceof between mysqli_result<array<string, int<-2147483648, 2147483647>\|string\|null>> and mysqli_result will always evaluate to true\.$#'
path: src/DbSchema/SchemaHasherMysql.php

# nikic/php-parser 4.x compat
- '#Call to deprecated method getLine\(\) of class PhpParser\\NodeAbstract.*#'
4 changes: 2 additions & 2 deletions src/Rules/DoctrineKeyValueStyleRule.php
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ public function processNode(Node $callLike, Scope $scope): array
$tableNames = $tableType->getConstantStrings();
if (\count($tableNames) === 0) {
return [
RuleErrorBuilder::message('Argument #0 expects a constant string, got ' . $tableType->describe(VerbosityLevel::precise()))->line($callLike->getLine())->build(),
RuleErrorBuilder::message('Argument #0 expects a constant string, got ' . $tableType->describe(VerbosityLevel::precise()))->line($callLike->getStartLine())->build(),
];
}

Expand Down Expand Up @@ -185,7 +185,7 @@ public function processNode(Node $callLike, Scope $scope): array

$ruleErrors = [];
foreach ($errors as $error) {
$ruleErrors[] = RuleErrorBuilder::message('Query error: ' . $error)->line($callLike->getLine())->build();
$ruleErrors[] = RuleErrorBuilder::message('Query error: ' . $error)->line($callLike->getStartLine())->build();
}
return $ruleErrors;
}
Expand Down
6 changes: 3 additions & 3 deletions src/Rules/PdoStatementExecuteMethodRule.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ private function checkErrors(MethodReflection $methodReflection, MethodCall $met
$parameters = $queryReflection->resolveParameters($parameterTypes) ?? [];
} catch (UnresolvableQueryException $exception) {
return [
RuleErrorBuilder::message($exception->asRuleMessage())->tip($exception::getTip())->line($methodCall->getLine())->build(),
RuleErrorBuilder::message($exception->asRuleMessage())->tip($exception::getTip())->line($methodCall->getStartLine())->build(),
];
}

Expand All @@ -110,13 +110,13 @@ private function checkErrors(MethodReflection $methodReflection, MethodCall $met
}
} catch (UnresolvableQueryException $exception) {
return [
RuleErrorBuilder::message($exception->asRuleMessage())->tip($exception::getTip())->line($methodCall->getLine())->build(),
RuleErrorBuilder::message($exception->asRuleMessage())->tip($exception::getTip())->line($methodCall->getStartLine())->build(),
];
}

$ruleErrors = [];
foreach ($errors as $error) {
$ruleErrors[] = RuleErrorBuilder::message($error)->line($methodCall->getLine())->build();
$ruleErrors[] = RuleErrorBuilder::message($error)->line($methodCall->getStartLine())->build();
}

return $ruleErrors;
Expand Down
8 changes: 4 additions & 4 deletions src/Rules/QueryPlanAnalyzerRule.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ public function processNode(Node $callLike, Scope $scope): array
return $this->analyze($callLike, $scope);
} catch (UnresolvableQueryException $exception) {
return [
RuleErrorBuilder::message($exception->asRuleMessage())->tip($exception::getTip())->line($callLike->getLine())->build(),
RuleErrorBuilder::message($exception->asRuleMessage())->tip($exception::getTip())->line($callLike->getStartLine())->build(),
];
}
}
Expand Down Expand Up @@ -144,7 +144,7 @@ private function analyze(CallLike $callLike, Scope $scope): array
$table
)
)
->line($callLike->getLine())
->line($callLike->getStartLine())
->tip('see Mysql Docs https://dev.mysql.com/doc/refman/8.0/en/select-optimization.html')
->build();
}
Expand All @@ -156,7 +156,7 @@ private function analyze(CallLike $callLike, Scope $scope): array
$table
)
)
->line($callLike->getLine())
->line($callLike->getStartLine())
->tip('see Mysql Docs https://dev.mysql.com/doc/refman/8.0/en/table-scan-avoidance.html')
->build();
}
Expand All @@ -168,7 +168,7 @@ private function analyze(CallLike $callLike, Scope $scope): array
$table
)
)
->line($callLike->getLine())
->line($callLike->getStartLine())
->tip('see Mysql Docs https://dev.mysql.com/doc/refman/8.0/en/select-optimization.html')
->build();
}
Expand Down
8 changes: 4 additions & 4 deletions src/Rules/SyntaxErrorInDibiPreparedStatementMethodRule.php
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ private function checkErrors(CallLike $callLike, Scope $scope, MethodReflection
}

return [
RuleErrorBuilder::message($placeholderExpectation . ', ' . $parameterActual . '.')->line($callLike->getLine())->build(),
RuleErrorBuilder::message($placeholderExpectation . ', ' . $parameterActual . '.')->line($callLike->getStartLine())->build(),
];
}
}
Expand All @@ -194,7 +194,7 @@ private function checkErrors(CallLike $callLike, Scope $scope, MethodReflection
$validity = $queryReflection->validateQueryString($queryParameters[0]);

if (null !== $validity) {
return [RuleErrorBuilder::message($validity->asRuleMessage())->line($callLike->getLine())->build()];
return [RuleErrorBuilder::message($validity->asRuleMessage())->line($callLike->getStartLine())->build()];
}

$result = $queryReflection->getResultType($queryParameters[0], QueryReflector::FETCH_TYPE_BOTH);
Expand All @@ -204,11 +204,11 @@ private function checkErrors(CallLike $callLike, Scope $scope, MethodReflection
$columnsInResult = \count($result->getValueTypes()) / 2;

if ('fetchPairs' === $methodReflection->getName() && 2 !== $columnsInResult) {
return [RuleErrorBuilder::message('fetchPairs requires exactly 2 selected columns, got ' . $columnsInResult . '.')->line($callLike->getLine())->build()];
return [RuleErrorBuilder::message('fetchPairs requires exactly 2 selected columns, got ' . $columnsInResult . '.')->line($callLike->getStartLine())->build()];
}

if ('fetchSingle' === $methodReflection->getName() && 1 !== $columnsInResult) {
return [RuleErrorBuilder::message('fetchSingle requires exactly 1 selected column, got ' . $columnsInResult . '.')->line($callLike->getLine())->build()];
return [RuleErrorBuilder::message('fetchSingle requires exactly 1 selected column, got ' . $columnsInResult . '.')->line($callLike->getStartLine())->build()];
}
}

Expand Down
6 changes: 3 additions & 3 deletions src/Rules/SyntaxErrorInPreparedStatementMethodRule.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ private function checkErrors(CallLike $callLike, Scope $scope): array
$parameters = $queryReflection->resolveParameters($parameterTypes) ?? [];
} catch (UnresolvableQueryException $exception) {
return [
RuleErrorBuilder::message($exception->asRuleMessage())->tip($exception::getTip())->line($callLike->getLine())->build(),
RuleErrorBuilder::message($exception->asRuleMessage())->tip($exception::getTip())->line($callLike->getStartLine())->build(),
];
}
}
Expand Down Expand Up @@ -144,13 +144,13 @@ private function checkErrors(CallLike $callLike, Scope $scope): array

$ruleErrors = [];
foreach ($errors as $error) {
$ruleErrors[] = RuleErrorBuilder::message($error)->line($callLike->getLine())->build();
$ruleErrors[] = RuleErrorBuilder::message($error)->line($callLike->getStartLine())->build();
}

return $ruleErrors;
} catch (UnresolvableQueryException $exception) {
return [
RuleErrorBuilder::message($exception->asRuleMessage())->tip($exception::getTip())->line($callLike->getLine())->build(),
RuleErrorBuilder::message($exception->asRuleMessage())->tip($exception::getTip())->line($callLike->getStartLine())->build(),
];
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/Rules/SyntaxErrorInQueryFunctionRule.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,13 +96,13 @@ public function processNode(Node $node, Scope $scope): array
$queryError = $queryReflection->validateQueryString($queryString);
if (null !== $queryError) {
return [
RuleErrorBuilder::message($queryError->asRuleMessage())->line($node->getLine())->build(),
RuleErrorBuilder::message($queryError->asRuleMessage())->line($node->getStartLine())->build(),
];
}
}
} catch (UnresolvableQueryException $exception) {
return [
RuleErrorBuilder::message($exception->asRuleMessage())->tip($exception::getTip())->line($node->getLine())->build(),
RuleErrorBuilder::message($exception->asRuleMessage())->tip($exception::getTip())->line($node->getStartLine())->build(),
];
}

Expand Down
4 changes: 2 additions & 2 deletions src/Rules/SyntaxErrorInQueryMethodRule.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,13 +91,13 @@ public function processNode(Node $node, Scope $scope): array
$queryError = $queryReflection->validateQueryString($queryString);
if (null !== $queryError) {
return [
RuleErrorBuilder::message($queryError->asRuleMessage())->line($node->getLine())->build(),
RuleErrorBuilder::message($queryError->asRuleMessage())->line($node->getStartLine())->build(),
];
}
}
} catch (UnresolvableQueryException $exception) {
return [
RuleErrorBuilder::message($exception->asRuleMessage())->tip($exception::getTip())->line($node->getLine())->build(),
RuleErrorBuilder::message($exception->asRuleMessage())->tip($exception::getTip())->line($node->getStartLine())->build(),
];
}

Expand Down
Loading