@@ -77,6 +77,7 @@ public static function setupReflector(QueryReflector $reflector, RuntimeConfigur
7777
7878 public function validateQueryString (string $ queryString ): ?Error
7979 {
80+ $ queryString = QuerySimulation::stripComments ($ queryString );
8081 $ queryType = self ::getQueryType ($ queryString );
8182
8283 if (self ::getRuntimeConfiguration ()->isAnalyzingWriteQueries ()) {
@@ -110,6 +111,8 @@ public function validateQueryString(string $queryString): ?Error
110111 */
111112 public function getResultType (string $ queryString , int $ fetchType ): ?Type
112113 {
114+ $ queryString = QuerySimulation::stripComments ($ queryString );
115+
113116 if ('SELECT ' !== self ::getQueryType ($ queryString )) {
114117 return null ;
115118 }
@@ -397,6 +400,7 @@ private function resolveQueryStringExpr(Expr $queryExpr, Scope $scope, bool $res
397400
398401 public static function getQueryType (string $ query ): ?string
399402 {
403+ $ query = QuerySimulation::stripComments ($ query );
400404 $ query = ltrim ($ query );
401405
402406 if (1 === preg_match ('/^\s*\(?\s*(SELECT|SHOW|UPDATE|INSERT|DELETE|REPLACE|CREATE|CALL|OPTIMIZE)/i ' , $ query , $ matches )) {
@@ -546,6 +550,8 @@ public static function getRuntimeConfiguration(): RuntimeConfiguration
546550 */
547551 public function countPlaceholders (string $ queryString ): int
548552 {
553+ $ queryString = QuerySimulation::stripComments ($ queryString );
554+
549555 // match named placeholders first, as the regex involved is more specific/less error prone
550556 $ namedPlaceholders = $ this ->extractNamedPlaceholders ($ queryString );
551557
@@ -573,6 +579,7 @@ public function countPlaceholders(string $queryString): int
573579 */
574580 public function containsNamedPlaceholders (string $ queryString , array $ parameters ): bool
575581 {
582+ $ queryString = QuerySimulation::stripComments ($ queryString );
576583 $ namedPlaceholders = $ this ->extractNamedPlaceholders ($ queryString );
577584
578585 if ([] !== $ namedPlaceholders ) {
@@ -593,6 +600,8 @@ public function containsNamedPlaceholders(string $queryString, array $parameters
593600 */
594601 public function extractNamedPlaceholders (string $ queryString ): array
595602 {
603+ $ queryString = QuerySimulation::stripComments ($ queryString );
604+
596605 if (preg_match_all (self ::REGEX_NAMED_PLACEHOLDER , $ queryString , $ matches ) > 0 ) {
597606 $ candidates = $ matches [0 ];
598607
0 commit comments