From c1b415403a3e82217c7edfedaafb17c6ee6c9cee Mon Sep 17 00:00:00 2001 From: Vasileios Georgitzikis Date: Fri, 9 Jan 2015 04:38:59 +0200 Subject: [PATCH] Fixed all PSR-1 Method Naming warnings (hopefuly) --- .../Handler/CompilerHandler.php | 24 ++++++------- .../Handler/PostprocessingHandler.php | 2 +- .../Handler/PreprocessingHandler.php | 36 +++++++++---------- .../CompilerBundle/Handler/UtilityHandler.php | 4 +-- 4 files changed, 33 insertions(+), 33 deletions(-) diff --git a/Symfony/src/Codebender/CompilerBundle/Handler/CompilerHandler.php b/Symfony/src/Codebender/CompilerBundle/Handler/CompilerHandler.php index c6615ee..3498fc3 100644 --- a/Symfony/src/Codebender/CompilerBundle/Handler/CompilerHandler.php +++ b/Symfony/src/Codebender/CompilerBundle/Handler/CompilerHandler.php @@ -47,7 +47,7 @@ function main($request, $compiler_config) { error_reporting(E_ALL & ~E_STRICT); - $this->set_values($compiler_config, + $this->setValues($compiler_config, $BINUTILS, $CLANG, $CFLAGS, $CPPFLAGS, $ASFLAGS, $ARFLAGS, $LDFLAGS, $LDFLAGS_TAIL, $CLANG_FLAGS, $OBJCOPY_FLAGS, $SIZE_FLAGS, $OUTPUT, $ARDUINO_CORES_DIR, $EXTERNAL_CORES_DIR, $TEMP_DIR, $ARCHIVE_DIR, $AUTOCC_DIR, $PYTHON, $AUTOCOMPLETER); @@ -59,9 +59,9 @@ function main($request, $compiler_config) if ($tmpVar["success"] === false) return $tmpVar; - $this->set_variables($request, $format, $libraries, $version, $mcu, $f_cpu, $core, $variant, $vid, $pid, $compiler_config); + $this->setVariables($request, $format, $libraries, $version, $mcu, $f_cpu, $core, $variant, $vid, $pid, $compiler_config); - $this->set_avr($version, $ARDUINO_CORES_DIR, $BINUTILS, $CC, $CPP, $AS, $AR, $LD, $OBJCOPY, $SIZE); + $this->setAVR($version, $ARDUINO_CORES_DIR, $BINUTILS, $CC, $CPP, $AS, $AR, $LD, $OBJCOPY, $SIZE); $target_arch = "-mmcu=$mcu -DARDUINO=$version -DF_CPU=$f_cpu -DUSB_VID=$vid -DUSB_PID=$pid"; $clang_target_arch = "-D".MCUHandler::$MCU[$mcu]." -DARDUINO=$version -DF_CPU=$f_cpu"; @@ -438,7 +438,7 @@ function main($request, $compiler_config) private function requestValid(&$request) { - $request = $this->preproc->validate_input($request); + $request = $this->preproc->validateInput($request); if (!$request) return array( "success" => false, @@ -499,7 +499,7 @@ private function extractFiles($request, $temp_dir, &$dir, &$files, $suffix, $lib "step" => 1, "message" => "Failed to create temporary directory."); - $response = $this->utility->extract_files("$dir/$suffix", $request, $lib_extraction); + $response = $this->utility->extractFiles("$dir/$suffix", $request, $lib_extraction); if ($response["success"] === false) return $response; @@ -513,7 +513,7 @@ private function preprocessIno(&$files) foreach ($files["ino"] as $file) { $code = file_get_contents("$file.ino"); - $new_code = $this->preproc->ino_to_cpp($code, "$file.ino"); + $new_code = $this->preproc->convertInoToCpp($code, "$file.ino"); $ret = file_put_contents("$file.cpp", $new_code); if ($code === false || !$new_code || !$ret) @@ -675,7 +675,7 @@ private function doCompile($compiler_config, &$files, $dir, $CC, $CFLAGS, $CPP, $file = escapeshellarg($file); $object_file = escapeshellarg($object_file); - //replace exec() calls with $this->utility->debug_exec() for debugging + //replace exec() calls with $this->utility->execWithDebugging() for debugging if ($ext == "c") { exec("$CC $CFLAGS $core_includes $target_arch $include_directories -c -o $object_file.o $file.$ext 2>&1", $output, $ret_compile); @@ -710,7 +710,7 @@ private function doCompile($compiler_config, &$files, $dir, $CC, $CFLAGS, $CPP, file_put_contents($compiler_config['logFileName'], "$CLANG $CLANG_FLAGS $core_includes $clang_target_arch $include_directories -c -o $object_file.o $file.$ext\n", FILE_APPEND); } - $output = $this->postproc->ansi_to_html(implode("\n", $output)); + $output = $this->postproc->convertANSItoHTML(implode("\n", $output)); $resp = array( "success" => false, @@ -868,7 +868,7 @@ private function convertOutput($dir, $format, $SIZE, $SIZE_FLAGS, $OBJCOPY, $OBJ } - private function set_avr($version, $ARDUINO_CORES_DIR, $BINUTILS, &$CC, &$CPP, &$AS, &$AR, &$LD, &$OBJCOPY, &$SIZE) + private function setAVR($version, $ARDUINO_CORES_DIR, $BINUTILS, &$CC, &$CPP, &$AS, &$AR, &$LD, &$OBJCOPY, &$SIZE) { // External binaries. $binaries = array("cc" => "-gcc", "cpp" => "-g++", "as" => "-gcc", "ar" => "-ar", "ld" => "-gcc", "objcopy" => "-objcopy", "size" => "-size"); @@ -892,7 +892,7 @@ private function set_avr($version, $ARDUINO_CORES_DIR, $BINUTILS, &$CC, &$CPP, & } - private function set_values($compiler_config, + private function setValues($compiler_config, &$BINUTILS, &$CLANG, &$CFLAGS, &$CPPFLAGS, &$ASFLAGS, &$ARFLAGS, &$LDFLAGS, &$LDFLAGS_TAIL, &$CLANG_FLAGS, &$OBJCOPY_FLAGS, &$SIZE_FLAGS, &$OUTPUT, &$ARDUINO_CORES_DIR, &$EXTERNAL_CORES_DIR, &$TEMP_DIR, &$ARCHIVE_DIR, &$AUTOCC_DIR, &$PYTHON, &$AUTOCOMPLETER) @@ -902,7 +902,7 @@ private function set_values($compiler_config, //ones included in the binutils parameter $BINUTILS = $compiler_config["binutils"]; //Clang is used to return the output in case of an error, it's version independent, so its - //value is set by set_values function. + //value is set by setValues function. $LDLIBRARYPATH = "LD_LIBRARY_PATH=".$compiler_config["arduino_cores_dir"]."/clang/v3_5/lib:\$LD_LIBRARY_PATH"; $CLANG = $LDLIBRARYPATH." ".$compiler_config["clang"]; @@ -936,7 +936,7 @@ private function set_values($compiler_config, $EXTERNAL_CORES_DIR = $compiler_config["external_core_files"]; } - private function set_variables($request, &$format, &$libraries, &$version, &$mcu, &$f_cpu, &$core, &$variant, &$vid, &$pid, &$compiler_config) + private function setVariables($request, &$format, &$libraries, &$version, &$mcu, &$f_cpu, &$core, &$variant, &$vid, &$pid, &$compiler_config) { // Extract the request options for easier access. $format = $request["format"]; diff --git a/Symfony/src/Codebender/CompilerBundle/Handler/PostprocessingHandler.php b/Symfony/src/Codebender/CompilerBundle/Handler/PostprocessingHandler.php index 14f3a8b..afbe798 100644 --- a/Symfony/src/Codebender/CompilerBundle/Handler/PostprocessingHandler.php +++ b/Symfony/src/Codebender/CompilerBundle/Handler/PostprocessingHandler.php @@ -27,7 +27,7 @@ class PostprocessingHandler * [, and ends with m. The color code is placed in between. Multiple * color codes can be included, separated by semicolon. */ - function ansi_to_html($text) + function convertANSItoHTML($text) { $FORMAT = array( 0 => NULL, // reset modes to default diff --git a/Symfony/src/Codebender/CompilerBundle/Handler/PreprocessingHandler.php b/Symfony/src/Codebender/CompilerBundle/Handler/PreprocessingHandler.php index f67dc93..1dac789 100644 --- a/Symfony/src/Codebender/CompilerBundle/Handler/PreprocessingHandler.php +++ b/Symfony/src/Codebender/CompilerBundle/Handler/PreprocessingHandler.php @@ -47,7 +47,7 @@ class PreprocessingHandler * \return string A copy of the code with no comments, single- or double- quoted strings * or pre-processor directives */ - function remove_comments_directives_quotes($code) + function removeCommentsDirectivesQuotes($code) { // Use a copy of the code and strip comments, pre-processor directives, single- and double-quoted strings @@ -61,10 +61,10 @@ function remove_comments_directives_quotes($code) } /** - * \param string $code The code returned from remove_comments_directives_quotes function + * \param string $code The code returned from removeCommentsDirectivesQuotes function * \return string The input code having all top level braces collapsed */ - function empty_braces($code) + function emptyBraces($code) { // For every line of the code remove all the contents of top level braces @@ -105,7 +105,7 @@ function empty_braces($code) * \param string $code The code returned from empty_braces function * \return array An array including any prototypes found in the original code */ - function find_existing_prototypes(&$code) + function findExistingPrototypes(&$code) { // In this case, the original code is used. Existing prototypes are matched, stored, and then removed from //the code, so that in the next step the compiler knows which prototypes should really be generated @@ -124,10 +124,10 @@ function find_existing_prototypes(&$code) /** * \param string $code The sketch code provided to the compiler - * \param array $existing_prototypes Array of prototypes returned by find_existing_prototypes function + * \param array $existing_prototypes Array of prototypes returned by findExistingPrototypes function * \return string The string including the function prototypes for the code */ - function generate_prototypes($code, $existing_prototypes) + function generatePrototypes($code, $existing_prototypes) { // This function uses a regular expression to match all function declarations, generate the // respective prototype and store all the prototypes in a string @@ -171,7 +171,7 @@ function generate_prototypes($code, $existing_prototypes) * \param string $code The sketch code * \return int The position where function prototypes should be placed */ - function insertion_position($code) + function insertionPosition($code) { // Use the following regular expression to match whitespaces, single- and multiline comments and preprocessor directives $regex = "/(\s+|(\/\*[^*]*(?:\*(?!\/)[^*]*)*\*\/)|(\/\/.*?$)|(\#(?:\\\\\\n|.)*))/m"; @@ -205,15 +205,15 @@ function insertion_position($code) /** * \param string $code The initial sketch code - * \param $function_prototypes The function prototypes returned by generate_prototypes function + * \param $function_prototypes The function prototypes returned by generatePrototypes function * \param int $position The position to place the prototypes returned by insertion_position function * \return string Valid c++ code */ - function build_code($code, $function_prototypes, $position) + function buildCode($code, $function_prototypes, $position) { // To build the final code, the compiler starts adding every character of the original string, until the position - // found by insertion_position is reached. Then, the function prototypes are added, as well as a preprocessor + // found by insertionPosition is reached. Then, the function prototypes are added, as well as a preprocessor //directive to fix the line numbering. $line = 1; $return_code = ""; @@ -249,19 +249,19 @@ function build_code($code, $function_prototypes, $position) return $return_code; } - function ino_to_cpp($code, $filename = NULL) + function convertInoToCpp($code, $filename = NULL) { // Remove comments, preprocessor directives, single- and double- quotes - $no_comms_code = $this->remove_comments_directives_quotes($code); + $no_comms_code = $this->removeCommentsDirectivesQuotes($code); // Remove any code between all top level braces - $empty_braces_code = $this->empty_braces($no_comms_code); + $empty_braces_code = $this->emptyBraces($no_comms_code); // Find already existing prototypes - $existing_prototypes = $this->find_existing_prototypes($empty_braces_code); + $existing_prototypes = $this->findExistingPrototypes($empty_braces_code); // Generate prototypes that do not already exist - $function_prototypes = $this->generate_prototypes($empty_braces_code, $existing_prototypes); + $function_prototypes = $this->generatePrototypes($empty_braces_code, $existing_prototypes); // Find the right place to insert the function prototypes (after any preprocessor directives, comments, // before any function declaration) - $insertion_position = $this->insertion_position($code); + $insertion_position = $this->insertionPosition($code); $new_code = ""; // Add a preprocessor directive for line numbering. @@ -270,7 +270,7 @@ function ino_to_cpp($code, $filename = NULL) else $new_code .= "#line 1\n"; // Build the new code for the cpp file that will eventually be compiled - $new_code .= $this->build_code($code, $function_prototypes, $insertion_position); + $new_code .= $this->buildCode($code, $function_prototypes, $insertion_position); return $new_code; @@ -283,7 +283,7 @@ function ino_to_cpp($code, $filename = NULL) * \param string $request The JSON-encoded compile request. * \return The value encoded in JSON in appropriate PHP type or NULL. */ - function validate_input($request) + function validateInput($request) { $request = json_decode($request, true); diff --git a/Symfony/src/Codebender/CompilerBundle/Handler/UtilityHandler.php b/Symfony/src/Codebender/CompilerBundle/Handler/UtilityHandler.php index 2ad398f..33ba5ed 100644 --- a/Symfony/src/Codebender/CompilerBundle/Handler/UtilityHandler.php +++ b/Symfony/src/Codebender/CompilerBundle/Handler/UtilityHandler.php @@ -30,7 +30,7 @@ class UtilityHandler * In case of error, the return value is an array that has a key success * and contains the response to be sent back to the user. */ - function extract_files($directory, $request_files, $lib_extraction) + function extractFiles($directory, $request_files, $lib_extraction) { // File extensions used by Arduino projects. They are put in a string, // separated by "|" to be used in regular expressions. They are also @@ -135,7 +135,7 @@ function get_files_by_extension($directory, $extensions) * * \warning It is not possible to redirect the standard error output to a file. */ - function debug_exec($command, /** @noinspection PhpUnusedParameterInspection */ + function execWithDebugging($command, /** @noinspection PhpUnusedParameterInspection */ &$output, /** @noinspection PhpUnusedParameterInspection */ &$retval) {