app/Report/ReportParserGenerate.php
private function substituteVars($expression, $quote): string
    {
        return preg_replace_callback(
            '/\$(\w+)/',
            function (array $matches) use ($quote): string {
                if (isset($this->vars[$matches[1]]['id'])) {
                    if ($quote) {
                        return "'" . addcslashes($this->vars[$matches[1]]['id'], "'") . "'";
                    }

                    return $this->vars[$matches[1]]['id'];
                }

                Log::addErrorLog(sprintf('Undefined variable $%s in report', $matches[1]));

                return '$' . $matches[1];
            },
            $expression
        );
    }
private function substituteVars($expression, $quote): string
    {
        return preg_replace_callback(
            '/\$(\w+)/',
            function (array $matches) use ($quote): string {
                if (isset($this->vars[$matches[1]]['id'])) {
                    if ($quote) {
                        return "'" . addcslashes($this->vars[$matches[1]]['id'], "'") . "'";
                    }

                    return $this->vars[$matches[1]]['id'];
                }

                Log::addErrorLog(sprintf('Undefined variable $%s in report', $matches[1]));

                return '$' . $matches[1];
            },
            $expression
        );
    }
private function substituteVars ( $ expression , $ quote ) : string { return preg_replace_callback ( '/\$(\w+)/' , function ( array $ matches ) use ( $ quote ) : string { if ( isset ( $ this -> vars [ $ matches [ 1 ] ] [ 'id' ] ) ) { if ( $ quote ) { return "'" . addcslashes ( $ this -> vars [ $ matches [ 1 ] ] [ 'id' ] , "'" ) . "'" ; } return $ this -> vars [ $ matches [ 1 ] ] [ 'id' ] ; } Log :: addErrorLog ( sprintf ( 'Undefined variable $%s in report' , $ matches [ 1 ] ) ) ; return '$' . $ matches [ 1 ] ; } , $ expression ) ; }
Replace variable identifiers with their values.

@param string $expression An expression such as "$foo == 123"
@param bool   $quote      Whether to add quotation marks

@return string
Replace variable identifiers with their values .