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

false positive on expected placeholder

Open mitelg opened this issue 1 year ago • 2 comments

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:

mitelg avatar Sep 27 '24 15:09 mitelg

which php version and which database access layer are you using?

staabm avatar Oct 03 '24 07:10 staabm

I tested on PHP 8.2 and we are using doctrine/dbal

mitelg avatar Oct 07 '24 09:10 mitelg

I can reproduce the issue. it is caused by the #cart-persister::load line before the query.

what is this thing about?

staabm avatar Oct 28 '24 11:10 staabm

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.

mitelg avatar Oct 28 '24 12:10 mitelg

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

staabm avatar Oct 28 '24 12:10 staabm

ohh found it in mysql grafik

staabm avatar Oct 28 '24 13:10 staabm

thank you!

mitelg avatar Oct 28 '24 19:10 mitelg