@@ -249,7 +249,7 @@ function buildCode($code, $function_prototypes, $position)
249
249
return $ return_code ;
250
250
}
251
251
252
- function convertInoToCpp ($ code , $ filename = NULL )
252
+ function convertInoToCpp ($ code , $ filename = null )
253
253
{
254
254
// Remove comments, preprocessor directives, single- and double- quotes
255
255
$ no_comms_code = $ this ->removeCommentsDirectivesQuotes ($ code );
@@ -263,12 +263,12 @@ function convertInoToCpp($code, $filename = NULL)
263
263
// before any function declaration)
264
264
$ insertion_position = $ this ->insertionPosition ($ code );
265
265
266
- $ new_code = "" ;
266
+ $ new_code = "#line 1 \n " ;
267
267
// Add a preprocessor directive for line numbering.
268
- if ($ filename )
269
- $ new_code .= "#line 1 \"$ filename \"\n" ;
270
- else
271
- $ new_code .= " #line 1 \n" ;
268
+ if ($ filename ) {
269
+ $ new_code .= "#line 1 \"$ filename \"\n" ;
270
+ }
271
+
272
272
// Build the new code for the cpp file that will eventually be compiled
273
273
$ new_code .= $ this ->buildCode ($ code , $ function_prototypes , $ insertion_position );
274
274
@@ -281,15 +281,15 @@ function convertInoToCpp($code, $filename = NULL)
281
281
* \brief Decodes and performs validation checks on input data.
282
282
*
283
283
* \param string $request The JSON-encoded compile request.
284
- * \return The value encoded in JSON in appropriate PHP type or <b>NULL </b>.
284
+ * \return The value encoded in JSON in appropriate PHP type or <b>null </b>.
285
285
*/
286
286
function validateInput ($ request )
287
287
{
288
288
$ request = json_decode ($ request , true );
289
289
290
290
// Request must be successfully decoded.
291
- if ($ request === NULL )
292
- return NULL ;
291
+ if ($ request === null )
292
+ return null ;
293
293
// Request must contain certain entities.
294
294
if (!(array_key_exists ("format " , $ request )
295
295
&& array_key_exists ("version " , $ request )
@@ -302,23 +302,26 @@ function validateInput($request)
302
302
&& array_key_exists ("core " , $ request ["build " ])
303
303
&& is_array ($ request ["files " ]))
304
304
)
305
- return NULL ;
305
+ return null ;
306
306
307
307
// Leonardo-specific flags.
308
308
if (array_key_exists ("variant " , $ request ["build " ]) && $ request ["build " ]["variant " ] == "leonardo " )
309
309
if (!(array_key_exists ("vid " , $ request ["build " ])
310
310
&& array_key_exists ("pid " , $ request ["build " ]))
311
311
)
312
- return NULL ;
312
+ return null ;
313
313
314
314
// Values used as command-line arguments may not contain any special
315
315
// characters. This is a serious security risk.
316
316
$ values = array ("version " , "mcu " , "f_cpu " , "core " , "vid " , "pid " );
317
- if (array_key_exists ("variant " , $ request ["build " ]))
318
- $ values [] = "variant " ;
319
- foreach ($ values as $ i )
320
- if (isset ($ request ["build " ][$ i ]) && escapeshellcmd ($ request ["build " ][$ i ]) != $ request ["build " ][$ i ])
321
- return NULL ;
317
+ if (array_key_exists ("variant " , $ request ["build " ])) {
318
+ $ values [] = "variant " ;
319
+ }
320
+ foreach ($ values as $ i ) {
321
+ if (isset ($ request ["build " ][$ i ]) && escapeshellcmd ($ request ["build " ][$ i ]) != $ request ["build " ][$ i ]) {
322
+ return null ;
323
+ }
324
+ }
322
325
323
326
// Request is valid.
324
327
return $ request ;
0 commit comments