staabm / phpstan-dba

PHPStan based SQL static analysis and type inference for the database access layer
https://staabm.github.io/archive.html#phpstan-dba
MIT License
249 stars 17 forks source link

Support nested quotes #651

Closed b-viguier closed 2 months ago

b-viguier commented 2 months ago

Hi 👋 🙂

I encountered an edge case with the Regex currently used to parse placeholders.

payload ->> '$."value-1"' = :value1
OR
payload ->> '$."value-2"' = :value2

ℹī¸ " are needed here to escape the - special character in the field's name

The problem with the current (["\'])([^"\']*\1) regex is that it tries to exclude ' AND " in the middle of a string. If this is a simply quoted string we should exclude only simple quotes.

I found a way to negate a backreference in stackoverflow.

~Unfortunately, I totally failed to run tests locally, so I didn't add corresponding test... but I would love to if you have some helping instructions~ ~[Edit] it seems that locally I got the same errors encountered by the CI, so maybe the issue is not related to my local setup but to master branch...~ [Edit 2 ] tests added 🎉

Thanks for you work 🙏

staabm commented 2 months ago

Just fixed the master build with https://github.com/staabm/phpstan-dba/pull/652

please try again while making sure you are running the tests with doctrine/dbal:^3 like I did in above PR

b-viguier commented 2 months ago

Thanks @staabm ! Tests added 👍 I was confused by cache files, but as far as I understand they are expected to be updated, so I included them (not sure if all cache files are up to date)

staabm commented 2 months ago

Thank you!