src/Parsed/Doctrine/ParsedRuleGroup.php
public function copyWithReplacedStringRegex(
        string $pattern,
        string $replace,
        string $appendToEndIfNotFound
    ): AbstractParsedRuleGroup {
        $count = 0;
        $newDql = preg_replace($pattern, $replace, $this->getQueryString(), -1, $count);

        if (0 === $count) {
            $newDql = $this->getQueryString().$appendToEndIfNotFound;
        }

        return new self($newDql, $this->parameters, $this->className);
    }
public function copyWithReplacedStringRegex(
        string $pattern,
        string $replace,
        string $appendToEndIfNotFound
    ): AbstractParsedRuleGroup {
        $count = 0;
        $newDql = preg_replace($pattern, $replace, $this->getQueryString(), -1, $count);

        if (0 === $count) {
            $newDql = $this->getQueryString().$appendToEndIfNotFound;
        }

        return new self($newDql, $this->parameters, $this->className);
    }
For example $parsedRuleGroup->copyWithReplacedString('/SELECT.+object.+FROM/', 'SELECT object FROM', '').

"SELECT object, association FROM App\Entity\Class object LEFT JOIN object.association association ORDER BY object.id" would change to
"SELECT object FROM App\Entity\Class object LEFT JOIN object.association association ORDER BY object.id".

{@inheritdoc}