phpstan-dba
phpstan-dba copied to clipboard
false positive on expected placeholder
hey there :wave:
being in the Friday weekend mood, I thought I would give this PHPStan extension another try on Shopware 6.
I will not invest too much time today, but an issue directly hit my eyes :grin:
Following code
$content = $this->connection->fetchAssociative(
'#cart-persister::load
SELECT `cart`.`payload`, `cart`.`rule_ids`, `cart`.`compressed` FROM cart WHERE `token` = :token',
['token' => $token]
);
will result in
Query expects placeholder :load, but it is missing from values given.
Have a nice weekend :tada:
which php version and which database access layer are you using?
I tested on PHP 8.2 and we are using doctrine/dbal
I can reproduce the issue. it is caused by the #cart-persister::load line before the query.
what is this thing about?
it is just a comment and not considered by SQL, but we use it like this as a title of the query. it helps to identify those queries in the Symfony profiler for example. mainly used for debugging.
I didn't found comments with # in the mysql docs.
Is this something db specific? Couldn't you use regular ansi sql comments? I guess it will just work
ohh found it in mysql
thank you!