phpstan-doctrine icon indicating copy to clipboard operation
phpstan-doctrine copied to clipboard

Enforce literal string for connection execute methods

Open VincentLanglet opened this issue 1 year ago • 0 comments

Friendly ping on this @craigfrancis, I'm never sure when dealing with literal-string.

In the same way that we enforce passing literal string to QueryBuilder methods in https://github.com/phpstan/phpstan-doctrine/blob/1.4.x/stubs/bleedingEdge/ORM/QueryBuilder.stub

I wonder if we shouldn't enforce literal string to for Connection::execute* methods which executes SQL directly.

This would help chaning query like

->executeQuery('SELECT foo where foo.bar = '.$nonLiteralValue);

to

->executeQuery('SELECT foo where foo.bar = :value', ['value' => $nonLiteralValue]);

VincentLanglet avatar Feb 13 '24 14:02 VincentLanglet