@@ -94,20 +94,21 @@ public function __construct($prod, $f, $forceValues)
9494 });
9595 }
9696
97- public function perFieldRequest (MethodDetails $ method ): array
97+ public function perFieldRequest (MethodDetails $ method, array $ reservedNames = [] ): array
9898 {
9999 // Handle test request value generation.
100100 $ perField = static ::filterFirstOneOf ($ method ->allFields )
101- ->map (fn ($ f ) => new class ($ this , $ method , $ f ) {
102- public function __construct ($ prod , $ method , $ f )
101+ ->map (fn ($ f ) => new class ($ this , $ method , $ f, $ reservedNames ) {
102+ public function __construct ($ prod , $ method , $ f, $ reservedNames )
103103 {
104104 // This code is arranged in this way, as a name must not be generated
105105 // if this field ends up not being used.
106106 // Name generation is stateful.
107107 // TODO: Consider refactoring this.
108108 $ this ->field = $ f ;
109109 $ this ->name = ($ f ->useResourceTestValue ? 'formatted_ ' : '' ) . $ prod ->name ($ f ->name );
110- $ this ->var = AST ::var (Helpers::toCamelCase ($ this ->name ));
110+ $ varPrefix = in_array ($ this ->name , $ reservedNames ) ? 'request_ ' : '' ;
111+ $ this ->var = AST ::var (Helpers::toCamelCase ($ varPrefix . $ this ->name ));
111112 $ astAcc = Vector::new ([]);
112113 $ prod ->fieldInit ($ method , $ f , $ this ->var , $ this ->name , null , $ astAcc );
113114 $ this ->initCode = $ astAcc ;
0 commit comments