Skip to content

Commit 98dcec6

Browse files
committed
Code style changes in PreprocessingHandler
- Added brackets to flow control statements - Replaced upper-case null with lower-case null
1 parent 9af22c7 commit 98dcec6

File tree

1 file changed

+19
-16
lines changed

1 file changed

+19
-16
lines changed

Symfony/src/Codebender/CompilerBundle/Handler/PreprocessingHandler.php

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ function buildCode($code, $function_prototypes, $position)
249249
return $return_code;
250250
}
251251

252-
function convertInoToCpp($code, $filename = NULL)
252+
function convertInoToCpp($code, $filename = null)
253253
{
254254
// Remove comments, preprocessor directives, single- and double- quotes
255255
$no_comms_code = $this->removeCommentsDirectivesQuotes($code);
@@ -263,12 +263,12 @@ function convertInoToCpp($code, $filename = NULL)
263263
// before any function declaration)
264264
$insertion_position = $this->insertionPosition($code);
265265

266-
$new_code = "";
266+
$new_code = "#line 1\n";
267267
// 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+
272272
// Build the new code for the cpp file that will eventually be compiled
273273
$new_code .= $this->buildCode($code, $function_prototypes, $insertion_position);
274274

@@ -281,15 +281,15 @@ function convertInoToCpp($code, $filename = NULL)
281281
* \brief Decodes and performs validation checks on input data.
282282
*
283283
* \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>.
285285
*/
286286
function validateInput($request)
287287
{
288288
$request = json_decode($request, true);
289289

290290
// Request must be successfully decoded.
291-
if ($request === NULL)
292-
return NULL;
291+
if ($request === null)
292+
return null;
293293
// Request must contain certain entities.
294294
if (!(array_key_exists("format", $request)
295295
&& array_key_exists("version", $request)
@@ -302,23 +302,26 @@ function validateInput($request)
302302
&& array_key_exists("core", $request["build"])
303303
&& is_array($request["files"]))
304304
)
305-
return NULL;
305+
return null;
306306

307307
// Leonardo-specific flags.
308308
if (array_key_exists("variant", $request["build"]) && $request["build"]["variant"] == "leonardo")
309309
if (!(array_key_exists("vid", $request["build"])
310310
&& array_key_exists("pid", $request["build"]))
311311
)
312-
return NULL;
312+
return null;
313313

314314
// Values used as command-line arguments may not contain any special
315315
// characters. This is a serious security risk.
316316
$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+
}
322325

323326
// Request is valid.
324327
return $request;

0 commit comments

Comments
 (0)