-
-
Notifications
You must be signed in to change notification settings - Fork 20
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
Argument expects a literal string, got literal-string #560
Comments
thanks for reporting. could you please provide a concrete code sample? |
I have some code that clone a user with all its data.
For the insert, I use a function that add backquote around column and table name. /**
* @param literal-string $tableExpression
* @param array<string, mixed> $data
*/
private function insert(string $tableExpression, array $data): void
{
$backquotedTableExpression = "`$tableExpression`";
$backquotedData = [];
foreach ($data as $key => $value) {
$backquotedData["`$key`"] = $value;
}
$this->dbal->insert($backquotedTableExpression, $backquotedData);
} So my real error message is
But the error stay the same if I remove the backquote and pass
|
What is being checked in the Similarly for the table name, if PHPStan doesn't know the literal value of the string, it can't check that the table exists in the database. If you are wrapping calls to services:
-
class: staabm\PHPStanDba\Rules\DoctrineKeyValueStyleRule
tags: [phpstan.rules.rule]
arguments:
classMethods:
- 'My\Connection::insert#1' (Note: technically this rule checks for a constant string, so maybe the error message should be revised to replace "literal" -> "constant"?) |
ohh I did not see that. we should not talk about |
Table names must be constant strings, not literal strings. As per staabm#560 (comment).
@hemberger the code example mentioned in #560 (comment) should be concluded as not analyzable and we should not error (as long as we are not in debug mode) |
When calling
Connection::insert()
with the table name as aliteral-string
, I got this error messageThe text was updated successfully, but these errors were encountered: