From: gggeek Date: Sun, 29 Mar 2015 16:25:52 +0000 (+0100) Subject: One more round of CamelCase X-Git-Tag: 4.0.0-alpha^2~113 X-Git-Url: http://git.onelab.eu/?p=plcapi.git;a=commitdiff_plain;h=b081e4541f5728a5f18d15832f0b72e2e133aad2 One more round of CamelCase --- diff --git a/src/Encoder.php b/src/Encoder.php index f723889..636ef35 100644 --- a/src/Encoder.php +++ b/src/Encoder.php @@ -125,7 +125,7 @@ class Encoder * * @author Dan Libby (dan@libby.com) * - * @param mixed $php_val the value to be converted into an xmlrpc value object + * @param mixed $phpVal the value to be converted into an xmlrpc value object * @param array $options can include 'encode_php_objs', 'auto_dates', 'null_extension' or 'extension_api' * * @return \PhpXmlrpc\Value diff --git a/src/Helper/Charset.php b/src/Helper/Charset.php index cbf00a9..d7670a1 100644 --- a/src/Helper/Charset.php +++ b/src/Helper/Charset.php @@ -82,27 +82,27 @@ class Charset * @todo make usage of iconv() or recode_string() or mb_string() where available * * @param string $data - * @param string $src_encoding - * @param string $dest_encoding + * @param string $srcEncoding + * @param string $destEncoding * * @return string */ - public function encodeEntities($data, $src_encoding = '', $dest_encoding = '') + public function encodeEntities($data, $srcEncoding = '', $destEncoding = '') { - if ($src_encoding == '') { + if ($srcEncoding == '') { // lame, but we know no better... - $src_encoding = PhpXmlRpc::$xmlrpc_internalencoding; + $srcEncoding = PhpXmlRpc::$xmlrpc_internalencoding; } - switch (strtoupper($src_encoding . '_' . $dest_encoding)) { + switch (strtoupper($srcEncoding . '_' . $destEncoding)) { case 'ISO-8859-1_': case 'ISO-8859-1_US-ASCII': - $escaped_data = str_replace(array('&', '"', "'", '<', '>'), array('&', '"', ''', '<', '>'), $data); - $escaped_data = str_replace($this->xml_iso88591_Entities['in'], $this->xml_iso88591_Entities['out'], $escaped_data); + $escapedData = str_replace(array('&', '"', "'", '<', '>'), array('&', '"', ''', '<', '>'), $data); + $escapedData = str_replace($this->xml_iso88591_Entities['in'], $this->xml_iso88591_Entities['out'], $escapedData); break; case 'ISO-8859-1_UTF-8': - $escaped_data = str_replace(array('&', '"', "'", '<', '>'), array('&', '"', ''', '<', '>'), $data); - $escaped_data = utf8_encode($escaped_data); + $escapedData = str_replace(array('&', '"', "'", '<', '>'), array('&', '"', ''', '<', '>'), $data); + $escapedData = utf8_encode($escapedData); break; case 'ISO-8859-1_ISO-8859-1': case 'US-ASCII_US-ASCII': @@ -111,13 +111,13 @@ class Charset case 'US-ASCII_ISO-8859-1': case 'UTF-8_UTF-8': //case 'CP1252_CP1252': - $escaped_data = str_replace(array('&', '"', "'", '<', '>'), array('&', '"', ''', '<', '>'), $data); + $escapedData = str_replace(array('&', '"', "'", '<', '>'), array('&', '"', ''', '<', '>'), $data); break; case 'UTF-8_': case 'UTF-8_US-ASCII': case 'UTF-8_ISO-8859-1': // NB: this will choke on invalid UTF-8, going most likely beyond EOF - $escaped_data = ''; + $escapedData = ''; // be kind to users creating string xmlrpc values out of different php types $data = (string)$data; $ns = strlen($data); @@ -129,22 +129,22 @@ class Charset /// @todo shall we replace this with a (supposedly) faster str_replace? switch ($ii) { case 34: - $escaped_data .= '"'; + $escapedData .= '"'; break; case 38: - $escaped_data .= '&'; + $escapedData .= '&'; break; case 39: - $escaped_data .= '''; + $escapedData .= '''; break; case 60: - $escaped_data .= '<'; + $escapedData .= '<'; break; case 62: - $escaped_data .= '>'; + $escapedData .= '>'; break; default: - $escaped_data .= $ch; + $escapedData .= $ch; } // switch } //2 11 110bbbbb 10bbbbbb (2047) elseif ($ii >> 5 == 6) { @@ -153,7 +153,7 @@ class Charset $b2 = ($ii & 63); $ii = ($b1 * 64) + $b2; $ent = sprintf('&#%d;', $ii); - $escaped_data .= $ent; + $escapedData .= $ent; $nn += 1; } //3 16 1110bbbb 10bbbbbb 10bbbbbb elseif ($ii >> 4 == 14) { @@ -164,7 +164,7 @@ class Charset $b3 = ($ii & 63); $ii = ((($b1 * 64) + $b2) * 64) + $b3; $ent = sprintf('&#%d;', $ii); - $escaped_data .= $ent; + $escapedData .= $ent; $nn += 2; } //4 21 11110bbb 10bbbbbb 10bbbbbb 10bbbbbb elseif ($ii >> 3 == 30) { @@ -177,7 +177,7 @@ class Charset $b4 = ($ii & 63); $ii = ((((($b1 * 64) + $b2) * 64) + $b3) * 64) + $b4; $ent = sprintf('&#%d;', $ii); - $escaped_data .= $ent; + $escapedData .= $ent; $nn += 3; } } @@ -185,28 +185,28 @@ class Charset /* case 'CP1252_': case 'CP1252_US-ASCII': - $escaped_data = str_replace(array('&', '"', "'", '<', '>'), array('&', '"', ''', '<', '>'), $data); - $escaped_data = str_replace($this->xml_iso88591_Entities']['in'], $this->xml_iso88591_Entities['out'], $escaped_data); - $escaped_data = str_replace($this->xml_cp1252_Entities['in'], $this->xml_cp1252_Entities['out'], $escaped_data); + $escapedData = str_replace(array('&', '"', "'", '<', '>'), array('&', '"', ''', '<', '>'), $data); + $escapedData = str_replace($this->xml_iso88591_Entities']['in'], $this->xml_iso88591_Entities['out'], $escapedData); + $escapedData = str_replace($this->xml_cp1252_Entities['in'], $this->xml_cp1252_Entities['out'], $escapedData); break; case 'CP1252_UTF-8': - $escaped_data = str_replace(array('&', '"', "'", '<', '>'), array('&', '"', ''', '<', '>'), $data); + $escapedData = str_replace(array('&', '"', "'", '<', '>'), array('&', '"', ''', '<', '>'), $data); /// @todo we could use real UTF8 chars here instead of xml entities... (note that utf_8 encode all allone will NOT convert them) - $escaped_data = str_replace($this->xml_cp1252_Entities['in'], $this->xml_cp1252_Entities['out'], $escaped_data); - $escaped_data = utf8_encode($escaped_data); + $escapedData = str_replace($this->xml_cp1252_Entities['in'], $this->xml_cp1252_Entities['out'], $escapedData); + $escapedData = utf8_encode($escapedData); break; case 'CP1252_ISO-8859-1': - $escaped_data = str_replace(array('&', '"', "'", '<', '>'), array('&', '"', ''', '<', '>'), $data); + $escapedData = str_replace(array('&', '"', "'", '<', '>'), array('&', '"', ''', '<', '>'), $data); // we might as well replace all funky chars with a '?' here, but we are kind and leave it to the receiving application layer to decide what to do with these weird entities... - $escaped_data = str_replace($this->xml_cp1252_Entities['in'], $this->xml_cp1252_Entities['out'], $escaped_data); + $escapedData = str_replace($this->xml_cp1252_Entities['in'], $this->xml_cp1252_Entities['out'], $escapedData); break; */ default: - $escaped_data = ''; - error_log("Converting from $src_encoding to $dest_encoding: not supported..."); + $escapedData = ''; + error_log("Converting from $srcEncoding to $destEncoding: not supported..."); } - return $escaped_data; + return $escapedData; } /** diff --git a/src/Helper/Http.php b/src/Helper/Http.php index 09be1f3..141cfe4 100644 --- a/src/Helper/Http.php +++ b/src/Helper/Http.php @@ -23,16 +23,16 @@ class Http // read chunk-size, chunk-extension (if any) and crlf // get the position of the linebreak - $chunkend = strpos($buffer, "\r\n") + 2; - $temp = substr($buffer, 0, $chunkend); - $chunk_size = hexdec(trim($temp)); - $chunkstart = $chunkend; - while ($chunk_size > 0) { - $chunkend = strpos($buffer, "\r\n", $chunkstart + $chunk_size); + $chunkEnd = strpos($buffer, "\r\n") + 2; + $temp = substr($buffer, 0, $chunkEnd); + $chunkSize = hexdec(trim($temp)); + $chunkStart = $chunkEnd; + while ($chunkSize > 0) { + $chunkEnd = strpos($buffer, "\r\n", $chunkStart + $chunkSize); // just in case we got a broken connection - if ($chunkend == false) { - $chunk = substr($buffer, $chunkstart); + if ($chunkEnd == false) { + $chunk = substr($buffer, $chunkStart); // append chunk-data to entity-body $new .= $chunk; $length += strlen($chunk); @@ -40,21 +40,21 @@ class Http } // read chunk-data and crlf - $chunk = substr($buffer, $chunkstart, $chunkend - $chunkstart); + $chunk = substr($buffer, $chunkStart, $chunkEnd - $chunkStart); // append chunk-data to entity-body $new .= $chunk; // length := length + chunk-size $length += strlen($chunk); // read chunk-size and crlf - $chunkstart = $chunkend + 2; + $chunkStart = $chunkEnd + 2; - $chunkend = strpos($buffer, "\r\n", $chunkstart) + 2; - if ($chunkend == false) { + $chunkEnd = strpos($buffer, "\r\n", $chunkStart) + 2; + if ($chunkEnd == false) { break; //just in case we got a broken connection } - $temp = substr($buffer, $chunkstart, $chunkend - $chunkstart); - $chunk_size = hexdec(trim($temp)); - $chunkstart = $chunkend; + $temp = substr($buffer, $chunkStart, $chunkEnd - $chunkStart); + $chunkSize = hexdec(trim($temp)); + $chunkStart = $chunkEnd; } return $new; @@ -138,13 +138,13 @@ class Http // take care of multi-line headers and cookies $arr = explode(':', $line, 2); if (count($arr) > 1) { - $header_name = strtolower(trim($arr[0])); + $headerName = strtolower(trim($arr[0])); /// @todo some other headers (the ones that allow a CSV list of values) /// do allow many values to be passed using multiple header lines. - /// We should add content to $xmlrpc->_xh['headers'][$header_name] + /// We should add content to $xmlrpc->_xh['headers'][$headerName] /// instead of replacing it for those... - if ($header_name == 'set-cookie' || $header_name == 'set-cookie2') { - if ($header_name == 'set-cookie2') { + if ($headerName == 'set-cookie' || $headerName == 'set-cookie2') { + if ($headerName == 'set-cookie2') { // version 2 cookies: // there could be many cookies on one line, comma separated $cookies = explode(',', $arr[1]); @@ -154,10 +154,10 @@ class Http foreach ($cookies as $cookie) { // glue together all received cookies, using a comma to separate them // (same as php does with getallheaders()) - if (isset($httpResponse['headers'][$header_name])) { - $httpResponse['headers'][$header_name] .= ', ' . trim($cookie); + if (isset($httpResponse['headers'][$headerName])) { + $httpResponse['headers'][$headerName] .= ', ' . trim($cookie); } else { - $httpResponse['headers'][$header_name] = trim($cookie); + $httpResponse['headers'][$headerName] = trim($cookie); } // parse cookie attributes, in case user wants to correctly honour them // feature creep: only allow rfc-compliant cookie attributes? @@ -180,11 +180,11 @@ class Http } } } else { - $httpResponse['headers'][$header_name] = trim($arr[1]); + $httpResponse['headers'][$headerName] = trim($arr[1]); } - } elseif (isset($header_name)) { + } elseif (isset($headerName)) { /// @todo version1 cookies might span multiple lines, thus breaking the parsing above - $httpResponse['headers'][$header_name] .= ' ' . trim($line); + $httpResponse['headers'][$headerName] .= ' ' . trim($line); } } diff --git a/src/Helper/XMLParser.php b/src/Helper/XMLParser.php index b26cc18..91b686a 100644 --- a/src/Helper/XMLParser.php +++ b/src/Helper/XMLParser.php @@ -61,7 +61,7 @@ class XMLParser /** * xml parser handler function for opening element tags. */ - public function xmlrpc_se($parser, $name, $attrs, $accept_single_vals = false) + public function xmlrpc_se($parser, $name, $attrs, $acceptSingleVals = false) { // if invalid xmlrpc already detected, skip all processing if ($this->_xh['isf'] < 2) { @@ -71,7 +71,7 @@ class XMLParser /// there is only a single top level element in xml anyway if (count($this->_xh['stack']) == 0) { if ($name != 'METHODRESPONSE' && $name != 'METHODCALL' && ( - $name != 'VALUE' && !$accept_single_vals) + $name != 'VALUE' && !$acceptSingleVals) ) { $this->_xh['isf'] = 2; $this->_xh['isf_reason'] = 'missing top level xmlrpc element'; @@ -126,15 +126,15 @@ class XMLParser return; } // create an empty array to hold child values, and push it onto appropriate stack - $cur_val = array(); - $cur_val['values'] = array(); - $cur_val['type'] = $name; + $curVal = array(); + $curVal['values'] = array(); + $curVal['type'] = $name; // check for out-of-band information to rebuild php objs // and in case it is found, save it if (@isset($attrs['PHP_CLASS'])) { - $cur_val['php_class'] = $attrs['PHP_CLASS']; + $curVal['php_class'] = $attrs['PHP_CLASS']; } - $this->_xh['valuestack'][] = $cur_val; + $this->_xh['valuestack'][] = $curVal; $this->_xh['vt'] = 'data'; // be prepared for a data element next break; case 'DATA': @@ -209,14 +209,14 @@ class XMLParser /** * xml parser handler function for close element tags. */ - public function xmlrpc_ee($parser, $name, $rebuild_xmlrpcvals = true) + public function xmlrpc_ee($parser, $name, $rebuildXmlrpcvals = true) { if ($this->_xh['isf'] < 2) { // push this element name from stack // NB: if XML validates, correct opening/closing is guaranteed and - // we do not have to check for $name == $curr_elem. + // we do not have to check for $name == $currElem. // we also checked for proper nesting at start of elements... - $curr_elem = array_pop($this->_xh['stack']); + $currElem = array_pop($this->_xh['stack']); switch ($name) { case 'VALUE': @@ -226,7 +226,7 @@ class XMLParser $this->_xh['vt'] = Value::$xmlrpcString; } - if ($rebuild_xmlrpcvals) { + if ($rebuildXmlrpcvals) { // build the xmlrpc val out of the data received, and substitute it $temp = new Value($this->_xh['value'], $this->_xh['vt']); // in case we got info about underlying php class, save it @@ -342,11 +342,11 @@ class XMLParser case 'STRUCT': case 'ARRAY': // fetch out of stack array of values, and promote it to current value - $curr_val = array_pop($this->_xh['valuestack']); - $this->_xh['value'] = $curr_val['values']; + $currVal = array_pop($this->_xh['valuestack']); + $this->_xh['value'] = $currVal['values']; $this->_xh['vt'] = strtolower($name); - if (isset($curr_val['php_class'])) { - $this->_xh['php_class'] = $curr_val['php_class']; + if (isset($currVal['php_class'])) { + $this->_xh['php_class'] = $currVal['php_class']; } break; case 'PARAM':