File tree Expand file tree Collapse file tree 2 files changed +22
-1
lines changed Expand file tree Collapse file tree 2 files changed +22
-1
lines changed Original file line number Diff line number Diff line change @@ -70,7 +70,10 @@ export class PHPExporter implements FormatExporter {
7070 } else if ( data === null || data === undefined ) {
7171 return ( startIndented ? indent : "" ) + "null" ;
7272 } else if ( typeof data === "string" ) {
73- return ( startIndented ? indent : "" ) + JSON . stringify ( data ) ;
73+ return (
74+ ( startIndented ? indent : "" ) +
75+ JSON . stringify ( data ) . replaceAll ( "${" , "\\${" )
76+ ) ;
7477 } else if ( Array . isArray ( data ) ) {
7578 const elements =
7679 data . length === 0
Original file line number Diff line number Diff line change @@ -394,6 +394,24 @@ $resp1 = $client->search([
394394 ],
395395]);
396396
397+ ` ,
398+ ) ;
399+ } ) ;
400+
401+ it ( "converts a dollar-variable to php" , async ( ) => {
402+ expect (
403+ await convertRequests ( 'POST /my-index/_doc\n{"key":"${value}"}' , "php" , {
404+ complete : false ,
405+ elasticsearchUrl : "https://localhost:9999" ,
406+ } ) ,
407+ ) . toEqual (
408+ `$resp = $client->index([
409+ "index" => "my-index",
410+ "body" => [
411+ "key" => "\\\${value}",
412+ ],
413+ ]);
414+
397415` ,
398416 ) ;
399417 } ) ;
You can’t perform that action at this time.
0 commit comments