@@ -1,11 +1,11 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -include_once __DIR__ . '/../lib/xmlrpc.inc'; |
|
| 4 | -include_once __DIR__ . '/../lib/xmlrpcs.inc'; |
|
| 3 | +include_once __DIR__.'/../lib/xmlrpc.inc'; |
|
| 4 | +include_once __DIR__.'/../lib/xmlrpcs.inc'; |
|
| 5 | 5 | |
| 6 | -include_once __DIR__ . '/parse_args.php'; |
|
| 6 | +include_once __DIR__.'/parse_args.php'; |
|
| 7 | 7 | |
| 8 | -include_once __DIR__ . '/PolyfillTestCase.php'; |
|
| 8 | +include_once __DIR__.'/PolyfillTestCase.php'; |
|
| 9 | 9 | |
| 10 | 10 | use PHPUnit\Runner\BaseTestRunner; |
| 11 | 11 | |
@@ -73,7 +73,7 @@ discard block |
||
| 73 | 73 | // user declares the type of resp value: we "almost" trust it... but log errors just in case |
| 74 | 74 | if (($this->valtyp == 'xmlrpcvals' && (!is_a($this->val, 'PhpXmlRpc\Value'))) || |
| 75 | 75 | ($this->valtyp == 'xml' && (!is_string($this->val)))) { |
| 76 | - $this->getLogger()->error('XML-RPC: ' . __METHOD__ . ': value passed in does not match type ' . $valType); |
|
| 76 | + $this->getLogger()->error('XML-RPC: '.__METHOD__.': value passed in does not match type '.$valType); |
|
| 77 | 77 | } |
| 78 | 78 | } |
| 79 | 79 | } |
@@ -152,33 +152,33 @@ discard block |
||
| 152 | 152 | public function serialize($charsetEncoding = '') |
| 153 | 153 | { |
| 154 | 154 | if ($charsetEncoding != '') { |
| 155 | - $this->content_type = 'text/xml; charset=' . $charsetEncoding; |
|
| 155 | + $this->content_type = 'text/xml; charset='.$charsetEncoding; |
|
| 156 | 156 | } else { |
| 157 | 157 | $this->content_type = 'text/xml'; |
| 158 | 158 | } |
| 159 | 159 | if (PhpXmlRpc::$xmlrpc_null_apache_encoding) { |
| 160 | - $result = "<methodResponse xmlns:ex=\"" . PhpXmlRpc::$xmlrpc_null_apache_encoding_ns . "\">\n"; |
|
| 160 | + $result = "<methodResponse xmlns:ex=\"".PhpXmlRpc::$xmlrpc_null_apache_encoding_ns."\">\n"; |
|
| 161 | 161 | } else { |
| 162 | 162 | $result = "<methodResponse>\n"; |
| 163 | 163 | } |
| 164 | 164 | if ($this->errno) { |
| 165 | 165 | // Let non-ASCII response messages be tolerated by clients by xml-encoding non ascii chars |
| 166 | - $result .= "<fault>\n" . |
|
| 167 | - "<value>\n<struct><member><name>faultCode</name>\n<value><int>" . $this->errno . |
|
| 168 | - "</int></value>\n</member>\n<member>\n<name>faultString</name>\n<value><string>" . |
|
| 169 | - $this->getCharsetEncoder()->encodeEntities($this->errstr, PhpXmlRpc::$xmlrpc_internalencoding, $charsetEncoding) . |
|
| 166 | + $result .= "<fault>\n". |
|
| 167 | + "<value>\n<struct><member><name>faultCode</name>\n<value><int>".$this->errno. |
|
| 168 | + "</int></value>\n</member>\n<member>\n<name>faultString</name>\n<value><string>". |
|
| 169 | + $this->getCharsetEncoder()->encodeEntities($this->errstr, PhpXmlRpc::$xmlrpc_internalencoding, $charsetEncoding). |
|
| 170 | 170 | "</string></value>\n</member>\n</struct>\n</value>\n</fault>"; |
| 171 | 171 | } else { |
| 172 | 172 | if (is_object($this->val) && is_a($this->val, 'PhpXmlRpc\Value')) { |
| 173 | - $result .= "<params>\n<param>\n" . $this->val->serialize($charsetEncoding) . "</param>\n</params>"; |
|
| 173 | + $result .= "<params>\n<param>\n".$this->val->serialize($charsetEncoding)."</param>\n</params>"; |
|
| 174 | 174 | } else if (is_string($this->val) && $this->valtyp == 'xml') { |
| 175 | - $result .= "<params>\n<param>\n" . |
|
| 176 | - $this->val . |
|
| 175 | + $result .= "<params>\n<param>\n". |
|
| 176 | + $this->val. |
|
| 177 | 177 | "</param>\n</params>"; |
| 178 | 178 | } else if ($this->valtyp == 'phpvals') { |
| 179 | 179 | $encoder = new Encoder(); |
| 180 | 180 | $val = $encoder->encode($this->val); |
| 181 | - $result .= "<params>\n<param>\n" . $val->serialize($charsetEncoding) . "</param>\n</params>"; |
|
| 181 | + $result .= "<params>\n<param>\n".$val->serialize($charsetEncoding)."</param>\n</params>"; |
|
| 182 | 182 | } else { |
| 183 | 183 | throw new StateErrorException('cannot serialize xmlrpc response objects whose content is native php values'); |
| 184 | 184 | } |
@@ -204,7 +204,7 @@ discard block |
||
| 204 | 204 | return $this->httpResponse['raw_data']; |
| 205 | 205 | default: |
| 206 | 206 | $trace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS); |
| 207 | - trigger_error('Undefined property via __get(): ' . $name . ' in ' . $trace[0]['file'] . ' on line ' . $trace[0]['line'], E_USER_WARNING); |
|
| 207 | + trigger_error('Undefined property via __get(): '.$name.' in '.$trace[0]['file'].' on line '.$trace[0]['line'], E_USER_WARNING); |
|
| 208 | 208 | return null; |
| 209 | 209 | } |
| 210 | 210 | } |
@@ -225,7 +225,7 @@ discard block |
||
| 225 | 225 | break; |
| 226 | 226 | default: |
| 227 | 227 | $trace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS); |
| 228 | - trigger_error('Undefined property via __set(): ' . $name . ' in ' . $trace[0]['file'] . ' on line ' . $trace[0]['line'], E_USER_WARNING); |
|
| 228 | + trigger_error('Undefined property via __set(): '.$name.' in '.$trace[0]['file'].' on line '.$trace[0]['line'], E_USER_WARNING); |
|
| 229 | 229 | } |
| 230 | 230 | } |
| 231 | 231 | |
@@ -259,7 +259,7 @@ discard block |
||
| 259 | 259 | break; |
| 260 | 260 | default: |
| 261 | 261 | $trace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS); |
| 262 | - trigger_error('Undefined property via __unset(): ' . $name . ' in ' . $trace[0]['file'] . ' on line ' . $trace[0]['line'], E_USER_WARNING); |
|
| 262 | + trigger_error('Undefined property via __unset(): '.$name.' in '.$trace[0]['file'].' on line '.$trace[0]['line'], E_USER_WARNING); |
|
| 263 | 263 | } |
| 264 | 264 | } |
| 265 | 265 | } |
@@ -76,14 +76,14 @@ discard block |
||
| 76 | 76 | if (count($this->xml_iso88591_Entities['in'])) { |
| 77 | 77 | return; |
| 78 | 78 | } |
| 79 | - for ($i = 0; $i < 32; $i++) { |
|
| 79 | + for ($i = 0; $i<32; $i++) { |
|
| 80 | 80 | $this->xml_iso88591_Entities["in"][] = chr($i); |
| 81 | 81 | $this->xml_iso88591_Entities["out"][] = "&#{$i};"; |
| 82 | 82 | } |
| 83 | 83 | |
| 84 | 84 | /// @todo to be 'print safe', should we encode as well character 127 (DEL) ? |
| 85 | 85 | |
| 86 | - for ($i = 160; $i < 256; $i++) { |
|
| 86 | + for ($i = 160; $i<256; $i++) { |
|
| 87 | 87 | $this->xml_iso88591_Entities["in"][] = chr($i); |
| 88 | 88 | $this->xml_iso88591_Entities["out"][] = "&#{$i};"; |
| 89 | 89 | } |
@@ -111,7 +111,7 @@ discard block |
||
| 111 | 111 | break;*/ |
| 112 | 112 | |
| 113 | 113 | default: |
| 114 | - throw new ValueErrorException('Unsupported table: ' . $tableName); |
|
| 114 | + throw new ValueErrorException('Unsupported table: '.$tableName); |
|
| 115 | 115 | } |
| 116 | 116 | } |
| 117 | 117 | |
@@ -163,7 +163,7 @@ discard block |
||
| 163 | 163 | $srcEncoding = 'UTF-8'; |
| 164 | 164 | } |
| 165 | 165 | |
| 166 | - $conversion = strtoupper($srcEncoding . '_' . $destEncoding); |
|
| 166 | + $conversion = strtoupper($srcEncoding.'_'.$destEncoding); |
|
| 167 | 167 | |
| 168 | 168 | // list ordered with (expected) most common scenarios first |
| 169 | 169 | switch ($conversion) { |
@@ -181,20 +181,20 @@ discard block |
||
| 181 | 181 | // NB: this will choke on invalid UTF-8, going most likely beyond EOF |
| 182 | 182 | $escapedData = ''; |
| 183 | 183 | // be kind to users creating string xml-rpc values out of different php types |
| 184 | - $data = (string)$data; |
|
| 184 | + $data = (string) $data; |
|
| 185 | 185 | $ns = strlen($data); |
| 186 | - for ($nn = 0; $nn < $ns; $nn++) { |
|
| 186 | + for ($nn = 0; $nn<$ns; $nn++) { |
|
| 187 | 187 | $ch = $data[$nn]; |
| 188 | 188 | $ii = ord($ch); |
| 189 | 189 | // 7 bits in 1 byte: 0bbbbbbb (127) |
| 190 | - if ($ii < 32) { |
|
| 190 | + if ($ii<32) { |
|
| 191 | 191 | if ($conversion == 'UTF-8_US-ASCII') { |
| 192 | 192 | $escapedData .= sprintf('&#%d;', $ii); |
| 193 | 193 | } else { |
| 194 | 194 | $escapedData .= $ch; |
| 195 | 195 | } |
| 196 | 196 | } |
| 197 | - else if ($ii < 128) { |
|
| 197 | + else if ($ii<128) { |
|
| 198 | 198 | /// @todo shall we replace this with a (supposedly) faster str_replace? |
| 199 | 199 | /// @todo to be 'print safe', should we encode as well character 127 (DEL) ? |
| 200 | 200 | switch ($ii) { |
@@ -219,25 +219,25 @@ discard block |
||
| 219 | 219 | } // 11 bits in 2 bytes: 110bbbbb 10bbbbbb (2047) |
| 220 | 220 | elseif ($ii >> 5 == 6) { |
| 221 | 221 | $b1 = ($ii & 31); |
| 222 | - $b2 = (ord($data[$nn + 1]) & 63); |
|
| 223 | - $ii = ($b1 * 64) + $b2; |
|
| 222 | + $b2 = (ord($data[$nn+1]) & 63); |
|
| 223 | + $ii = ($b1 * 64)+$b2; |
|
| 224 | 224 | $escapedData .= sprintf('&#%d;', $ii); |
| 225 | 225 | $nn += 1; |
| 226 | 226 | } // 16 bits in 3 bytes: 1110bbbb 10bbbbbb 10bbbbbb |
| 227 | 227 | elseif ($ii >> 4 == 14) { |
| 228 | 228 | $b1 = ($ii & 15); |
| 229 | - $b2 = (ord($data[$nn + 1]) & 63); |
|
| 230 | - $b3 = (ord($data[$nn + 2]) & 63); |
|
| 231 | - $ii = ((($b1 * 64) + $b2) * 64) + $b3; |
|
| 229 | + $b2 = (ord($data[$nn+1]) & 63); |
|
| 230 | + $b3 = (ord($data[$nn+2]) & 63); |
|
| 231 | + $ii = ((($b1 * 64)+$b2) * 64)+$b3; |
|
| 232 | 232 | $escapedData .= sprintf('&#%d;', $ii); |
| 233 | 233 | $nn += 2; |
| 234 | 234 | } // 21 bits in 4 bytes: 11110bbb 10bbbbbb 10bbbbbb 10bbbbbb |
| 235 | 235 | elseif ($ii >> 3 == 30) { |
| 236 | 236 | $b1 = ($ii & 7); |
| 237 | - $b2 = (ord($data[$nn + 1]) & 63); |
|
| 238 | - $b3 = (ord($data[$nn + 2]) & 63); |
|
| 239 | - $b4 = (ord($data[$nn + 3]) & 63); |
|
| 240 | - $ii = ((((($b1 * 64) + $b2) * 64) + $b3) * 64) + $b4; |
|
| 237 | + $b2 = (ord($data[$nn+1]) & 63); |
|
| 238 | + $b3 = (ord($data[$nn+2]) & 63); |
|
| 239 | + $b4 = (ord($data[$nn+3]) & 63); |
|
| 240 | + $ii = ((((($b1 * 64)+$b2) * 64)+$b3) * 64)+$b4; |
|
| 241 | 241 | $escapedData .= sprintf('&#%d;', $ii); |
| 242 | 242 | $nn += 3; |
| 243 | 243 | } |
@@ -290,7 +290,7 @@ discard block |
||
| 290 | 290 | // If src is UTF8, we run htmlspecialchars before converting to the target charset, as |
| 291 | 291 | // htmlspecialchars has limited charset support, but it groks utf8 |
| 292 | 292 | if ($srcEncoding === 'UTF-8') { |
| 293 | - $data = htmlspecialchars($data, defined('ENT_XML1') ? ENT_XML1 | ENT_QUOTES : ENT_QUOTES, 'UTF-8'); |
|
| 293 | + $data = htmlspecialchars($data, defined('ENT_XML1') ? ENT_XML1 | ENT_QUOTES : ENT_QUOTES, 'UTF-8'); |
|
| 294 | 294 | } |
| 295 | 295 | if ($srcEncoding !== $destEncoding) { |
| 296 | 296 | try { |
@@ -302,7 +302,7 @@ discard block |
||
| 302 | 302 | } |
| 303 | 303 | if ($data === false) { |
| 304 | 304 | $escapedData = ''; |
| 305 | - $this->getLogger()->error('XML-RPC: ' . __METHOD__ . ": Converting from $srcEncoding to $destEncoding via mbstring: failed..."); |
|
| 305 | + $this->getLogger()->error('XML-RPC: '.__METHOD__.": Converting from $srcEncoding to $destEncoding via mbstring: failed..."); |
|
| 306 | 306 | } else { |
| 307 | 307 | if ($srcEncoding === 'UTF-8') { |
| 308 | 308 | $escapedData = $data; |
@@ -312,7 +312,7 @@ discard block |
||
| 312 | 312 | } |
| 313 | 313 | } else { |
| 314 | 314 | $escapedData = ''; |
| 315 | - $this->getLogger()->error('XML-RPC: ' . __METHOD__ . ": Converting from $srcEncoding to $destEncoding: not supported..."); |
|
| 315 | + $this->getLogger()->error('XML-RPC: '.__METHOD__.": Converting from $srcEncoding to $destEncoding: not supported..."); |
|
| 316 | 316 | } |
| 317 | 317 | } |
| 318 | 318 | |
@@ -330,7 +330,7 @@ discard block |
||
| 330 | 330 | if (function_exists('mb_list_encodings')) { |
| 331 | 331 | $knownCharsets = array_unique(array_merge($knownCharsets, array_diff(mb_list_encodings(), array( |
| 332 | 332 | 'pass', 'auto', 'wchar', 'BASE64', 'UUENCODE', 'ASCII', 'HTML-ENTITIES', 'Quoted-Printable', |
| 333 | - '7bit','8bit', 'byte2be', 'byte2le', 'byte4be', 'byte4le' |
|
| 333 | + '7bit', '8bit', 'byte2be', 'byte2le', 'byte4be', 'byte4le' |
|
| 334 | 334 | )))); |
| 335 | 335 | } |
| 336 | 336 | return $knownCharsets; |
@@ -384,7 +384,7 @@ discard block |
||
| 384 | 384 | case 'iso88591': |
| 385 | 385 | return $this->xml_iso88591_Entities; |
| 386 | 386 | default: |
| 387 | - throw new ValueErrorException('Unsupported charset: ' . $charset); |
|
| 387 | + throw new ValueErrorException('Unsupported charset: '.$charset); |
|
| 388 | 388 | } |
| 389 | 389 | } |
| 390 | 390 | } |
@@ -174,20 +174,20 @@ discard block |
||
| 174 | 174 | $callable = explode('::', $callable); |
| 175 | 175 | } |
| 176 | 176 | if (is_array($callable)) { |
| 177 | - if (count($callable) < 2 || (!is_string($callable[0]) && !is_object($callable[0]))) { |
|
| 178 | - $this->getLogger()->error('XML-RPC: ' . __METHOD__ . ': syntax for function to be wrapped is wrong'); |
|
| 177 | + if (count($callable)<2 || (!is_string($callable[0]) && !is_object($callable[0]))) { |
|
| 178 | + $this->getLogger()->error('XML-RPC: '.__METHOD__.': syntax for function to be wrapped is wrong'); |
|
| 179 | 179 | return false; |
| 180 | 180 | } |
| 181 | 181 | if (is_string($callable[0])) { |
| 182 | 182 | $plainFuncName = implode('::', $callable); |
| 183 | 183 | } elseif (is_object($callable[0])) { |
| 184 | - $plainFuncName = get_class($callable[0]) . '->' . $callable[1]; |
|
| 184 | + $plainFuncName = get_class($callable[0]).'->'.$callable[1]; |
|
| 185 | 185 | } |
| 186 | 186 | $exists = method_exists($callable[0], $callable[1]); |
| 187 | 187 | } else if ($callable instanceof \Closure) { |
| 188 | 188 | // we do not support creating code which wraps closures, as php does not allow to serialize them |
| 189 | 189 | if (!$buildIt) { |
| 190 | - $this->getLogger()->error('XML-RPC: ' . __METHOD__ . ': a closure can not be wrapped in generated source code'); |
|
| 190 | + $this->getLogger()->error('XML-RPC: '.__METHOD__.': a closure can not be wrapped in generated source code'); |
|
| 191 | 191 | return false; |
| 192 | 192 | } |
| 193 | 193 | |
@@ -199,7 +199,7 @@ discard block |
||
| 199 | 199 | } |
| 200 | 200 | |
| 201 | 201 | if (!$exists) { |
| 202 | - $this->getLogger()->error('XML-RPC: ' . __METHOD__ . ': function to be wrapped is not defined: ' . $plainFuncName); |
|
| 202 | + $this->getLogger()->error('XML-RPC: '.__METHOD__.': function to be wrapped is not defined: '.$plainFuncName); |
|
| 203 | 203 | return false; |
| 204 | 204 | } |
| 205 | 205 | |
@@ -243,23 +243,23 @@ discard block |
||
| 243 | 243 | if (is_array($callable)) { |
| 244 | 244 | $func = new \ReflectionMethod($callable[0], $callable[1]); |
| 245 | 245 | if ($func->isPrivate()) { |
| 246 | - $this->getLogger()->error('XML-RPC: ' . __METHOD__ . ': method to be wrapped is private: ' . $plainFuncName); |
|
| 246 | + $this->getLogger()->error('XML-RPC: '.__METHOD__.': method to be wrapped is private: '.$plainFuncName); |
|
| 247 | 247 | return false; |
| 248 | 248 | } |
| 249 | 249 | if ($func->isProtected()) { |
| 250 | - $this->getLogger()->error('XML-RPC: ' . __METHOD__ . ': method to be wrapped is protected: ' . $plainFuncName); |
|
| 250 | + $this->getLogger()->error('XML-RPC: '.__METHOD__.': method to be wrapped is protected: '.$plainFuncName); |
|
| 251 | 251 | return false; |
| 252 | 252 | } |
| 253 | 253 | if ($func->isConstructor()) { |
| 254 | - $this->getLogger()->error('XML-RPC: ' . __METHOD__ . ': method to be wrapped is the constructor: ' . $plainFuncName); |
|
| 254 | + $this->getLogger()->error('XML-RPC: '.__METHOD__.': method to be wrapped is the constructor: '.$plainFuncName); |
|
| 255 | 255 | return false; |
| 256 | 256 | } |
| 257 | 257 | if ($func->isDestructor()) { |
| 258 | - $this->getLogger()->error('XML-RPC: ' . __METHOD__ . ': method to be wrapped is the destructor: ' . $plainFuncName); |
|
| 258 | + $this->getLogger()->error('XML-RPC: '.__METHOD__.': method to be wrapped is the destructor: '.$plainFuncName); |
|
| 259 | 259 | return false; |
| 260 | 260 | } |
| 261 | 261 | if ($func->isAbstract()) { |
| 262 | - $this->getLogger()->error('XML-RPC: ' . __METHOD__ . ': method to be wrapped is abstract: ' . $plainFuncName); |
|
| 262 | + $this->getLogger()->error('XML-RPC: '.__METHOD__.': method to be wrapped is abstract: '.$plainFuncName); |
|
| 263 | 263 | return false; |
| 264 | 264 | } |
| 265 | 265 | /// @todo add more checks for static vs. nonstatic? |
@@ -269,7 +269,7 @@ discard block |
||
| 269 | 269 | if ($func->isInternal()) { |
| 270 | 270 | /// @todo from PHP 5.1.0 onward, we should be able to use invokeargs instead of getparameters to fully |
| 271 | 271 | /// reflect internal php functions |
| 272 | - $this->getLogger()->error('XML-RPC: ' . __METHOD__ . ': function to be wrapped is internal: ' . $plainFuncName); |
|
| 272 | + $this->getLogger()->error('XML-RPC: '.__METHOD__.': function to be wrapped is internal: '.$plainFuncName); |
|
| 273 | 273 | return false; |
| 274 | 274 | } |
| 275 | 275 | |
@@ -321,7 +321,7 @@ discard block |
||
| 321 | 321 | $i = 0; |
| 322 | 322 | foreach ($func->getParameters() as $paramObj) { |
| 323 | 323 | $params[$i] = array(); |
| 324 | - $params[$i]['name'] = '$' . $paramObj->getName(); |
|
| 324 | + $params[$i]['name'] = '$'.$paramObj->getName(); |
|
| 325 | 325 | $params[$i]['isoptional'] = $paramObj->isOptional(); |
| 326 | 326 | $i++; |
| 327 | 327 | } |
@@ -385,7 +385,7 @@ discard block |
||
| 385 | 385 | // build a signature |
| 386 | 386 | $sig = array($this->php2XmlrpcType($funcDesc['returns'])); |
| 387 | 387 | $pSig = array($funcDesc['returnsDocs']); |
| 388 | - for ($i = 0; $i < count($pars); $i++) { |
|
| 388 | + for ($i = 0; $i<count($pars); $i++) { |
|
| 389 | 389 | $name = strtolower($funcDesc['params'][$i]['name']); |
| 390 | 390 | if (isset($funcDesc['paramDocs'][$name]['type'])) { |
| 391 | 391 | $sig[] = $this->php2XmlrpcType($funcDesc['paramDocs'][$name]['type']); |
@@ -441,7 +441,7 @@ discard block |
||
| 441 | 441 | } |
| 442 | 442 | } |
| 443 | 443 | $numPars = $req->getNumParams(); |
| 444 | - if ($numPars < $minPars || $numPars > $maxPars) { |
|
| 444 | + if ($numPars<$minPars || $numPars>$maxPars) { |
|
| 445 | 445 | return new $responseClass(0, 3, 'Incorrect parameters passed to method'); |
| 446 | 446 | } |
| 447 | 447 | |
@@ -454,7 +454,7 @@ discard block |
||
| 454 | 454 | |
| 455 | 455 | $result = call_user_func_array($callable, $params); |
| 456 | 456 | |
| 457 | - if (! is_a($result, $responseClass)) { |
|
| 457 | + if (!is_a($result, $responseClass)) { |
|
| 458 | 458 | // q: why not do the same for int, float, bool, string? |
| 459 | 459 | if ($funcDesc['returns'] == Value::$xmlrpcDateTime || $funcDesc['returns'] == Value::$xmlrpcBase64) { |
| 460 | 460 | $result = new $valueClass($result, $funcDesc['returns']); |
@@ -493,9 +493,9 @@ discard block |
||
| 493 | 493 | if ($newFuncName == '') { |
| 494 | 494 | if (is_array($callable)) { |
| 495 | 495 | if (is_string($callable[0])) { |
| 496 | - $xmlrpcFuncName = "{$prefix}_" . implode('_', $callable); |
|
| 496 | + $xmlrpcFuncName = "{$prefix}_".implode('_', $callable); |
|
| 497 | 497 | } else { |
| 498 | - $xmlrpcFuncName = "{$prefix}_" . get_class($callable[0]) . '_' . $callable[1]; |
|
| 498 | + $xmlrpcFuncName = "{$prefix}_".get_class($callable[0]).'_'.$callable[1]; |
|
| 499 | 499 | } |
| 500 | 500 | } else { |
| 501 | 501 | if ($callable instanceof \Closure) { |
@@ -527,9 +527,9 @@ discard block |
||
| 527 | 527 | */ |
| 528 | 528 | protected function buildWrapFunctionSource($callable, $newFuncName, $extraOptions, $plainFuncName, $funcDesc) |
| 529 | 529 | { |
| 530 | - $encodeNulls = isset($extraOptions['encode_nulls']) ? (bool)$extraOptions['encode_nulls'] : false; |
|
| 531 | - $encodePhpObjects = isset($extraOptions['encode_php_objs']) ? (bool)$extraOptions['encode_php_objs'] : false; |
|
| 532 | - $decodePhpObjects = isset($extraOptions['decode_php_objs']) ? (bool)$extraOptions['decode_php_objs'] : false; |
|
| 530 | + $encodeNulls = isset($extraOptions['encode_nulls']) ? (bool) $extraOptions['encode_nulls'] : false; |
|
| 531 | + $encodePhpObjects = isset($extraOptions['encode_php_objs']) ? (bool) $extraOptions['encode_php_objs'] : false; |
|
| 532 | + $decodePhpObjects = isset($extraOptions['decode_php_objs']) ? (bool) $extraOptions['decode_php_objs'] : false; |
|
| 533 | 533 | $catchWarnings = isset($extraOptions['suppress_warnings']) && $extraOptions['suppress_warnings'] ? '@' : ''; |
| 534 | 534 | |
| 535 | 535 | $i = 0; |
@@ -564,9 +564,9 @@ discard block |
||
| 564 | 564 | // build body of new function |
| 565 | 565 | |
| 566 | 566 | $innerCode = " \$paramCount = \$req->getNumParams();\n"; |
| 567 | - $innerCode .= " if (\$paramCount < $minPars || \$paramCount > $maxPars) return new " . static::$namespace . "Response(0, " . PhpXmlRpc::$xmlrpcerr['incorrect_params'] . ", '" . PhpXmlRpc::$xmlrpcstr['incorrect_params'] . "');\n"; |
|
| 567 | + $innerCode .= " if (\$paramCount < $minPars || \$paramCount > $maxPars) return new ".static::$namespace."Response(0, ".PhpXmlRpc::$xmlrpcerr['incorrect_params'].", '".PhpXmlRpc::$xmlrpcstr['incorrect_params']."');\n"; |
|
| 568 | 568 | |
| 569 | - $innerCode .= " \$encoder = new " . static::$namespace . "Encoder();\n"; |
|
| 569 | + $innerCode .= " \$encoder = new ".static::$namespace."Encoder();\n"; |
|
| 570 | 570 | if ($decodePhpObjects) { |
| 571 | 571 | $innerCode .= " \$params = \$encoder->decode(\$req, array('decode_php_objs'));\n"; |
| 572 | 572 | } else { |
@@ -579,23 +579,23 @@ discard block |
||
| 579 | 579 | static::holdObject($newFuncName, $callable[0]); |
| 580 | 580 | $class = get_class($callable[0]); |
| 581 | 581 | if ($class[0] !== '\\') { |
| 582 | - $class = '\\' . $class; |
|
| 582 | + $class = '\\'.$class; |
|
| 583 | 583 | } |
| 584 | 584 | $innerCode .= " /// @var $class \$obj\n"; |
| 585 | 585 | $innerCode .= " \$obj = PhpXmlRpc\\Wrapper::getHeldObject('$newFuncName');\n"; |
| 586 | - $realFuncName = '$obj->' . $callable[1]; |
|
| 586 | + $realFuncName = '$obj->'.$callable[1]; |
|
| 587 | 587 | } else { |
| 588 | 588 | $realFuncName = $plainFuncName; |
| 589 | 589 | } |
| 590 | 590 | foreach ($parsVariations as $i => $pars) { |
| 591 | - $innerCode .= " if (\$paramCount == " . count($pars) . ") \$retVal = {$catchWarnings}$realFuncName(" . implode(',', $pars) . ");\n"; |
|
| 592 | - if ($i < (count($parsVariations) - 1)) |
|
| 591 | + $innerCode .= " if (\$paramCount == ".count($pars).") \$retVal = {$catchWarnings}$realFuncName(".implode(',', $pars).");\n"; |
|
| 592 | + if ($i<(count($parsVariations)-1)) |
|
| 593 | 593 | $innerCode .= " else\n"; |
| 594 | 594 | } |
| 595 | - $innerCode .= " if (is_a(\$retVal, '" . static::$namespace . "Response'))\n return \$retVal;\n else\n"; |
|
| 595 | + $innerCode .= " if (is_a(\$retVal, '".static::$namespace."Response'))\n return \$retVal;\n else\n"; |
|
| 596 | 596 | /// q: why not do the same for int, float, bool, string? |
| 597 | 597 | if ($funcDesc['returns'] == Value::$xmlrpcDateTime || $funcDesc['returns'] == Value::$xmlrpcBase64) { |
| 598 | - $innerCode .= " return new " . static::$namespace . "Response(new " . static::$namespace . "Value(\$retVal, '{$funcDesc['returns']}'));"; |
|
| 598 | + $innerCode .= " return new ".static::$namespace."Response(new ".static::$namespace."Value(\$retVal, '{$funcDesc['returns']}'));"; |
|
| 599 | 599 | } else { |
| 600 | 600 | $encodeOptions = array(); |
| 601 | 601 | if ($encodeNulls) { |
@@ -606,18 +606,18 @@ discard block |
||
| 606 | 606 | } |
| 607 | 607 | |
| 608 | 608 | if ($encodeOptions) { |
| 609 | - $innerCode .= " return new " . static::$namespace . "Response(\$encoder->encode(\$retVal, array('" . |
|
| 610 | - implode("', '", $encodeOptions) . "')));"; |
|
| 609 | + $innerCode .= " return new ".static::$namespace."Response(\$encoder->encode(\$retVal, array('". |
|
| 610 | + implode("', '", $encodeOptions)."')));"; |
|
| 611 | 611 | } else { |
| 612 | - $innerCode .= " return new " . static::$namespace . "Response(\$encoder->encode(\$retVal));"; |
|
| 612 | + $innerCode .= " return new ".static::$namespace."Response(\$encoder->encode(\$retVal));"; |
|
| 613 | 613 | } |
| 614 | 614 | } |
| 615 | 615 | // shall we exclude functions returning by ref? |
| 616 | 616 | // if ($func->returnsReference()) |
| 617 | 617 | // return false; |
| 618 | 618 | |
| 619 | - $code = "/**\n * @param \PhpXmlRpc\Request \$req\n * @return \PhpXmlRpc\Response\n * @throws \\Exception\n */\n" . |
|
| 620 | - "function $newFuncName(\$req)\n{\n" . $innerCode . "\n}"; |
|
| 619 | + $code = "/**\n * @param \PhpXmlRpc\Request \$req\n * @return \PhpXmlRpc\Response\n * @throws \\Exception\n */\n". |
|
| 620 | + "function $newFuncName(\$req)\n{\n".$innerCode."\n}"; |
|
| 621 | 621 | |
| 622 | 622 | return $code; |
| 623 | 623 | } |
@@ -671,7 +671,7 @@ discard block |
||
| 671 | 671 | protected function generateMethodNameForClassMethod($className, $classMethod, $extraOptions = array()) |
| 672 | 672 | { |
| 673 | 673 | if (isset($extraOptions['replace_class_name']) && $extraOptions['replace_class_name']) { |
| 674 | - return (isset($extraOptions['prefix']) ? $extraOptions['prefix'] : '') . $classMethod; |
|
| 674 | + return (isset($extraOptions['prefix']) ? $extraOptions['prefix'] : '').$classMethod; |
|
| 675 | 675 | } |
| 676 | 676 | |
| 677 | 677 | if (is_object($className)) { |
@@ -679,7 +679,7 @@ discard block |
||
| 679 | 679 | } else { |
| 680 | 680 | $realClassName = $className; |
| 681 | 681 | } |
| 682 | - return (isset($extraOptions['prefix']) ? $extraOptions['prefix'] : '') . "$realClassName.$classMethod"; |
|
| 682 | + return (isset($extraOptions['prefix']) ? $extraOptions['prefix'] : '')."$realClassName.$classMethod"; |
|
| 683 | 683 | } |
| 684 | 684 | |
| 685 | 685 | /** |
@@ -762,21 +762,21 @@ discard block |
||
| 762 | 762 | */ |
| 763 | 763 | protected function retrieveMethodSignature($client, $methodName, array $extraOptions = array()) |
| 764 | 764 | { |
| 765 | - $reqClass = static::$namespace . 'Request'; |
|
| 766 | - $valClass = static::$namespace . 'Value'; |
|
| 767 | - $decoderClass = static::$namespace . 'Encoder'; |
|
| 765 | + $reqClass = static::$namespace.'Request'; |
|
| 766 | + $valClass = static::$namespace.'Value'; |
|
| 767 | + $decoderClass = static::$namespace.'Encoder'; |
|
| 768 | 768 | |
| 769 | 769 | $debug = isset($extraOptions['debug']) ? ($extraOptions['debug']) : 0; |
| 770 | - $timeout = isset($extraOptions['timeout']) ? (int)$extraOptions['timeout'] : 0; |
|
| 770 | + $timeout = isset($extraOptions['timeout']) ? (int) $extraOptions['timeout'] : 0; |
|
| 771 | 771 | $protocol = isset($extraOptions['protocol']) ? $extraOptions['protocol'] : ''; |
| 772 | - $sigNum = isset($extraOptions['signum']) ? (int)$extraOptions['signum'] : 0; |
|
| 772 | + $sigNum = isset($extraOptions['signum']) ? (int) $extraOptions['signum'] : 0; |
|
| 773 | 773 | |
| 774 | 774 | $req = new $reqClass('system.methodSignature'); |
| 775 | 775 | $req->addparam(new $valClass($methodName)); |
| 776 | 776 | $client->setDebug($debug); |
| 777 | 777 | $response = $client->send($req, $timeout, $protocol); |
| 778 | 778 | if ($response->faultCode()) { |
| 779 | - $this->getLogger()->error('XML-RPC: ' . __METHOD__ . ': could not retrieve method signature from remote server for method ' . $methodName); |
|
| 779 | + $this->getLogger()->error('XML-RPC: '.__METHOD__.': could not retrieve method signature from remote server for method '.$methodName); |
|
| 780 | 780 | return false; |
| 781 | 781 | } |
| 782 | 782 | |
@@ -787,8 +787,8 @@ discard block |
||
| 787 | 787 | $mSig = $decoder->decode($mSig); |
| 788 | 788 | } |
| 789 | 789 | |
| 790 | - if (!is_array($mSig) || count($mSig) <= $sigNum) { |
|
| 791 | - $this->getLogger()->error('XML-RPC: ' . __METHOD__ . ': could not retrieve method signature nr.' . $sigNum . ' from remote server for method ' . $methodName); |
|
| 790 | + if (!is_array($mSig) || count($mSig)<=$sigNum) { |
|
| 791 | + $this->getLogger()->error('XML-RPC: '.__METHOD__.': could not retrieve method signature nr.'.$sigNum.' from remote server for method '.$methodName); |
|
| 792 | 792 | return false; |
| 793 | 793 | } |
| 794 | 794 | |
@@ -803,11 +803,11 @@ discard block |
||
| 803 | 803 | */ |
| 804 | 804 | protected function retrieveMethodHelp($client, $methodName, array $extraOptions = array()) |
| 805 | 805 | { |
| 806 | - $reqClass = static::$namespace . 'Request'; |
|
| 807 | - $valClass = static::$namespace . 'Value'; |
|
| 806 | + $reqClass = static::$namespace.'Request'; |
|
| 807 | + $valClass = static::$namespace.'Value'; |
|
| 808 | 808 | |
| 809 | 809 | $debug = isset($extraOptions['debug']) ? ($extraOptions['debug']) : 0; |
| 810 | - $timeout = isset($extraOptions['timeout']) ? (int)$extraOptions['timeout'] : 0; |
|
| 810 | + $timeout = isset($extraOptions['timeout']) ? (int) $extraOptions['timeout'] : 0; |
|
| 811 | 811 | $protocol = isset($extraOptions['protocol']) ? $extraOptions['protocol'] : ''; |
| 812 | 812 | |
| 813 | 813 | $mDesc = ''; |
@@ -841,11 +841,11 @@ discard block |
||
| 841 | 841 | $clientClone = clone $client; |
| 842 | 842 | $function = function() use($clientClone, $methodName, $extraOptions, $mSig) |
| 843 | 843 | { |
| 844 | - $timeout = isset($extraOptions['timeout']) ? (int)$extraOptions['timeout'] : 0; |
|
| 844 | + $timeout = isset($extraOptions['timeout']) ? (int) $extraOptions['timeout'] : 0; |
|
| 845 | 845 | $protocol = isset($extraOptions['protocol']) ? $extraOptions['protocol'] : ''; |
| 846 | - $encodePhpObjects = isset($extraOptions['encode_php_objs']) ? (bool)$extraOptions['encode_php_objs'] : false; |
|
| 847 | - $decodePhpObjects = isset($extraOptions['decode_php_objs']) ? (bool)$extraOptions['decode_php_objs'] : false; |
|
| 848 | - $encodeNulls = isset($extraOptions['encode_nulls']) ? (bool)$extraOptions['encode_nulls'] : false; |
|
| 846 | + $encodePhpObjects = isset($extraOptions['encode_php_objs']) ? (bool) $extraOptions['encode_php_objs'] : false; |
|
| 847 | + $decodePhpObjects = isset($extraOptions['decode_php_objs']) ? (bool) $extraOptions['decode_php_objs'] : false; |
|
| 848 | + $encodeNulls = isset($extraOptions['encode_nulls']) ? (bool) $extraOptions['encode_nulls'] : false; |
|
| 849 | 849 | $throwFault = false; |
| 850 | 850 | $decodeFault = false; |
| 851 | 851 | $faultResponse = null; |
@@ -856,9 +856,9 @@ discard block |
||
| 856 | 856 | $faultResponse = $extraOptions['return_on_fault']; |
| 857 | 857 | } |
| 858 | 858 | |
| 859 | - $reqClass = static::$namespace . 'Request'; |
|
| 860 | - $encoderClass = static::$namespace . 'Encoder'; |
|
| 861 | - $valueClass = static::$namespace . 'Value'; |
|
| 859 | + $reqClass = static::$namespace.'Request'; |
|
| 860 | + $encoderClass = static::$namespace.'Encoder'; |
|
| 861 | + $valueClass = static::$namespace.'Value'; |
|
| 862 | 862 | |
| 863 | 863 | $encoder = new $encoderClass(); |
| 864 | 864 | $encodeOptions = array(); |
@@ -940,14 +940,14 @@ discard block |
||
| 940 | 940 | * @param string $mDesc |
| 941 | 941 | * @return string[] keys: source, docstring |
| 942 | 942 | */ |
| 943 | - public function buildWrapMethodSource($client, $methodName, array $extraOptions, $newFuncName, $mSig, $mDesc='') |
|
| 943 | + public function buildWrapMethodSource($client, $methodName, array $extraOptions, $newFuncName, $mSig, $mDesc = '') |
|
| 944 | 944 | { |
| 945 | - $timeout = isset($extraOptions['timeout']) ? (int)$extraOptions['timeout'] : 0; |
|
| 945 | + $timeout = isset($extraOptions['timeout']) ? (int) $extraOptions['timeout'] : 0; |
|
| 946 | 946 | $protocol = isset($extraOptions['protocol']) ? $extraOptions['protocol'] : ''; |
| 947 | - $encodePhpObjects = isset($extraOptions['encode_php_objs']) ? (bool)$extraOptions['encode_php_objs'] : false; |
|
| 948 | - $decodePhpObjects = isset($extraOptions['decode_php_objs']) ? (bool)$extraOptions['decode_php_objs'] : false; |
|
| 949 | - $encodeNulls = isset($extraOptions['encode_nulls']) ? (bool)$extraOptions['encode_nulls'] : false; |
|
| 950 | - $clientCopyMode = isset($extraOptions['simple_client_copy']) ? (int)($extraOptions['simple_client_copy']) : 0; |
|
| 947 | + $encodePhpObjects = isset($extraOptions['encode_php_objs']) ? (bool) $extraOptions['encode_php_objs'] : false; |
|
| 948 | + $decodePhpObjects = isset($extraOptions['decode_php_objs']) ? (bool) $extraOptions['decode_php_objs'] : false; |
|
| 949 | + $encodeNulls = isset($extraOptions['encode_nulls']) ? (bool) $extraOptions['encode_nulls'] : false; |
|
| 950 | + $clientCopyMode = isset($extraOptions['simple_client_copy']) ? (int) ($extraOptions['simple_client_copy']) : 0; |
|
| 951 | 951 | $prefix = isset($extraOptions['prefix']) ? $extraOptions['prefix'] : 'xmlrpc'; |
| 952 | 952 | $throwFault = false; |
| 953 | 953 | $decodeFault = false; |
@@ -960,10 +960,10 @@ discard block |
||
| 960 | 960 | } |
| 961 | 961 | |
| 962 | 962 | $code = "function $newFuncName("; |
| 963 | - if ($clientCopyMode < 2) { |
|
| 963 | + if ($clientCopyMode<2) { |
|
| 964 | 964 | // client copy mode 0 or 1 == full / partial client copy in emitted code |
| 965 | 965 | $verbatimClientCopy = !$clientCopyMode; |
| 966 | - $innerCode = ' ' . str_replace("\n", "\n ", $this->buildClientWrapperCode($client, $verbatimClientCopy, $prefix, static::$namespace)); |
|
| 966 | + $innerCode = ' '.str_replace("\n", "\n ", $this->buildClientWrapperCode($client, $verbatimClientCopy, $prefix, static::$namespace)); |
|
| 967 | 967 | $innerCode .= "\$client->setDebug(\$debug);\n"; |
| 968 | 968 | $this_ = ''; |
| 969 | 969 | } else { |
@@ -971,28 +971,28 @@ discard block |
||
| 971 | 971 | $innerCode = ''; |
| 972 | 972 | $this_ = 'this->'; |
| 973 | 973 | } |
| 974 | - $innerCode .= " \$req = new " . static::$namespace . "Request('$methodName');\n"; |
|
| 974 | + $innerCode .= " \$req = new ".static::$namespace."Request('$methodName');\n"; |
|
| 975 | 975 | |
| 976 | 976 | if ($mDesc != '') { |
| 977 | 977 | // take care that PHP comment is not terminated unwillingly by method description |
| 978 | 978 | /// @todo according to the spec, method desc can have html in it. We should run it through strip_tags... |
| 979 | - $mDesc = "/**\n * " . str_replace(array("\n", '*/'), array("\n * ", '* /'), $mDesc) . "\n"; |
|
| 979 | + $mDesc = "/**\n * ".str_replace(array("\n", '*/'), array("\n * ", '* /'), $mDesc)."\n"; |
|
| 980 | 980 | } else { |
| 981 | 981 | $mDesc = "/**\n * Function $newFuncName.\n"; |
| 982 | 982 | } |
| 983 | 983 | |
| 984 | 984 | // param parsing |
| 985 | - $innerCode .= " \$encoder = new " . static::$namespace . "Encoder();\n"; |
|
| 985 | + $innerCode .= " \$encoder = new ".static::$namespace."Encoder();\n"; |
|
| 986 | 986 | $plist = array(); |
| 987 | 987 | $pCount = count($mSig); |
| 988 | - for ($i = 1; $i < $pCount; $i++) { |
|
| 988 | + for ($i = 1; $i<$pCount; $i++) { |
|
| 989 | 989 | $plist[] = "\$p$i"; |
| 990 | 990 | $pType = $mSig[$i]; |
| 991 | 991 | if ($pType == 'i4' || $pType == 'i8' || $pType == 'int' || $pType == 'boolean' || $pType == 'double' || |
| 992 | 992 | $pType == 'string' || $pType == 'dateTime.iso8601' || $pType == 'base64' || $pType == 'null' |
| 993 | 993 | ) { |
| 994 | 994 | // only build directly xml-rpc values when type is known and scalar |
| 995 | - $innerCode .= " \$p$i = new " . static::$namespace . "Value(\$p$i, '$pType');\n"; |
|
| 995 | + $innerCode .= " \$p$i = new ".static::$namespace."Value(\$p$i, '$pType');\n"; |
|
| 996 | 996 | } else { |
| 997 | 997 | if ($encodePhpObjects || $encodeNulls) { |
| 998 | 998 | $encOpts = array(); |
@@ -1003,26 +1003,26 @@ discard block |
||
| 1003 | 1003 | $encOpts[] = 'null_extension'; |
| 1004 | 1004 | } |
| 1005 | 1005 | |
| 1006 | - $innerCode .= " \$p$i = \$encoder->encode(\$p$i, array( '" . implode("', '", $encOpts) . "'));\n"; |
|
| 1006 | + $innerCode .= " \$p$i = \$encoder->encode(\$p$i, array( '".implode("', '", $encOpts)."'));\n"; |
|
| 1007 | 1007 | } else { |
| 1008 | 1008 | $innerCode .= " \$p$i = \$encoder->encode(\$p$i);\n"; |
| 1009 | 1009 | } |
| 1010 | 1010 | } |
| 1011 | 1011 | $innerCode .= " \$req->addparam(\$p$i);\n"; |
| 1012 | - $mDesc .= " * @param " . $this->xmlrpc2PhpType($pType) . " \$p$i\n"; |
|
| 1012 | + $mDesc .= " * @param ".$this->xmlrpc2PhpType($pType)." \$p$i\n"; |
|
| 1013 | 1013 | } |
| 1014 | - if ($clientCopyMode < 2) { |
|
| 1014 | + if ($clientCopyMode<2) { |
|
| 1015 | 1015 | $plist[] = '$debug = 0'; |
| 1016 | 1016 | $mDesc .= " * @param int \$debug when 1 (or 2) will enable debugging of the underlying {$prefix} call (defaults to 0)\n"; |
| 1017 | 1017 | } |
| 1018 | 1018 | $plist = implode(', ', $plist); |
| 1019 | - $mDesc .= ' * @return ' . $this->xmlrpc2PhpType($mSig[0]); |
|
| 1019 | + $mDesc .= ' * @return '.$this->xmlrpc2PhpType($mSig[0]); |
|
| 1020 | 1020 | if ($throwFault) { |
| 1021 | - $mDesc .= "\n * @throws " . (is_string($throwFault) ? $throwFault : '\\PhpXmlRpc\\Exception'); |
|
| 1021 | + $mDesc .= "\n * @throws ".(is_string($throwFault) ? $throwFault : '\\PhpXmlRpc\\Exception'); |
|
| 1022 | 1022 | } else if ($decodeFault) { |
| 1023 | - $mDesc .= '|' . gettype($faultResponse) . " (a " . gettype($faultResponse) . " if call fails)"; |
|
| 1023 | + $mDesc .= '|'.gettype($faultResponse)." (a ".gettype($faultResponse)." if call fails)"; |
|
| 1024 | 1024 | } else { |
| 1025 | - $mDesc .= '|' . static::$namespace . "Response (a " . static::$namespace . "Response obj instance if call fails)"; |
|
| 1025 | + $mDesc .= '|'.static::$namespace."Response (a ".static::$namespace."Response obj instance if call fails)"; |
|
| 1026 | 1026 | } |
| 1027 | 1027 | $mDesc .= "\n */\n"; |
| 1028 | 1028 | |
@@ -1034,9 +1034,9 @@ discard block |
||
| 1034 | 1034 | $respCode = "throw new $throwFault(\$res->faultString(), \$res->faultCode())"; |
| 1035 | 1035 | } else if ($decodeFault) { |
| 1036 | 1036 | if (is_string($faultResponse) && ((strpos($faultResponse, '%faultCode%') !== false) || (strpos($faultResponse, '%faultString%') !== false))) { |
| 1037 | - $respCode = "return str_replace(array('%faultCode%', '%faultString%'), array(\$res->faultCode(), \$res->faultString()), '" . str_replace("'", "''", $faultResponse) . "')"; |
|
| 1037 | + $respCode = "return str_replace(array('%faultCode%', '%faultString%'), array(\$res->faultCode(), \$res->faultString()), '".str_replace("'", "''", $faultResponse)."')"; |
|
| 1038 | 1038 | } else { |
| 1039 | - $respCode = 'return ' . var_export($faultResponse, true); |
|
| 1039 | + $respCode = 'return '.var_export($faultResponse, true); |
|
| 1040 | 1040 | } |
| 1041 | 1041 | } else { |
| 1042 | 1042 | $respCode = 'return $res'; |
@@ -1047,7 +1047,7 @@ discard block |
||
| 1047 | 1047 | $innerCode .= " if (\$res->faultCode()) $respCode; else return \$encoder->decode(\$res->value());"; |
| 1048 | 1048 | } |
| 1049 | 1049 | |
| 1050 | - $code = $code . $plist . ")\n{\n" . $innerCode . "\n}\n"; |
|
| 1050 | + $code = $code.$plist.")\n{\n".$innerCode."\n}\n"; |
|
| 1051 | 1051 | |
| 1052 | 1052 | return array('source' => $code, 'docstring' => $mDesc); |
| 1053 | 1053 | } |
@@ -1074,25 +1074,25 @@ discard block |
||
| 1074 | 1074 | public function wrapXmlrpcServer($client, $extraOptions = array()) |
| 1075 | 1075 | { |
| 1076 | 1076 | $methodFilter = isset($extraOptions['method_filter']) ? $extraOptions['method_filter'] : ''; |
| 1077 | - $timeout = isset($extraOptions['timeout']) ? (int)$extraOptions['timeout'] : 0; |
|
| 1077 | + $timeout = isset($extraOptions['timeout']) ? (int) $extraOptions['timeout'] : 0; |
|
| 1078 | 1078 | $protocol = isset($extraOptions['protocol']) ? $extraOptions['protocol'] : ''; |
| 1079 | 1079 | $newClassName = isset($extraOptions['new_class_name']) ? $extraOptions['new_class_name'] : ''; |
| 1080 | - $encodeNulls = isset($extraOptions['encode_nulls']) ? (bool)$extraOptions['encode_nulls'] : false; |
|
| 1081 | - $encodePhpObjects = isset($extraOptions['encode_php_objs']) ? (bool)$extraOptions['encode_php_objs'] : false; |
|
| 1082 | - $decodePhpObjects = isset($extraOptions['decode_php_objs']) ? (bool)$extraOptions['decode_php_objs'] : false; |
|
| 1080 | + $encodeNulls = isset($extraOptions['encode_nulls']) ? (bool) $extraOptions['encode_nulls'] : false; |
|
| 1081 | + $encodePhpObjects = isset($extraOptions['encode_php_objs']) ? (bool) $extraOptions['encode_php_objs'] : false; |
|
| 1082 | + $decodePhpObjects = isset($extraOptions['decode_php_objs']) ? (bool) $extraOptions['decode_php_objs'] : false; |
|
| 1083 | 1083 | $verbatimClientCopy = isset($extraOptions['simple_client_copy']) ? !($extraOptions['simple_client_copy']) : true; |
| 1084 | - $throwOnFault = isset($extraOptions['throw_on_fault']) ? (bool)$extraOptions['throw_on_fault'] : false; |
|
| 1084 | + $throwOnFault = isset($extraOptions['throw_on_fault']) ? (bool) $extraOptions['throw_on_fault'] : false; |
|
| 1085 | 1085 | $buildIt = isset($extraOptions['return_source']) ? !($extraOptions['return_source']) : true; |
| 1086 | 1086 | $prefix = isset($extraOptions['prefix']) ? $extraOptions['prefix'] : 'xmlrpc'; |
| 1087 | 1087 | |
| 1088 | - $reqClass = static::$namespace . 'Request'; |
|
| 1089 | - $decoderClass = static::$namespace . 'Encoder'; |
|
| 1088 | + $reqClass = static::$namespace.'Request'; |
|
| 1089 | + $decoderClass = static::$namespace.'Encoder'; |
|
| 1090 | 1090 | |
| 1091 | 1091 | // retrieve the list of methods |
| 1092 | 1092 | $req = new $reqClass('system.listMethods'); |
| 1093 | 1093 | $response = $client->send($req, $timeout, $protocol); |
| 1094 | 1094 | if ($response->faultCode()) { |
| 1095 | - $this->getLogger()->error('XML-RPC: ' . __METHOD__ . ': could not retrieve method list from remote server'); |
|
| 1095 | + $this->getLogger()->error('XML-RPC: '.__METHOD__.': could not retrieve method list from remote server'); |
|
| 1096 | 1096 | |
| 1097 | 1097 | return false; |
| 1098 | 1098 | } |
@@ -1103,7 +1103,7 @@ discard block |
||
| 1103 | 1103 | $mList = $decoder->decode($mList); |
| 1104 | 1104 | } |
| 1105 | 1105 | if (!is_array($mList) || !count($mList)) { |
| 1106 | - $this->getLogger()->error('XML-RPC: ' . __METHOD__ . ': could not retrieve meaningful method list from remote server'); |
|
| 1106 | + $this->getLogger()->error('XML-RPC: '.__METHOD__.': could not retrieve meaningful method list from remote server'); |
|
| 1107 | 1107 | |
| 1108 | 1108 | return false; |
| 1109 | 1109 | } |
@@ -1112,8 +1112,8 @@ discard block |
||
| 1112 | 1112 | if ($newClassName != '') { |
| 1113 | 1113 | $xmlrpcClassName = $newClassName; |
| 1114 | 1114 | } else { |
| 1115 | - $xmlrpcClassName = $prefix . '_' . preg_replace(array('/\./', '/[^a-zA-Z0-9_\x7f-\xff]/'), |
|
| 1116 | - array('_', ''), $client->server) . '_client'; |
|
| 1115 | + $xmlrpcClassName = $prefix.'_'.preg_replace(array('/\./', '/[^a-zA-Z0-9_\x7f-\xff]/'), |
|
| 1116 | + array('_', ''), $client->server).'_client'; |
|
| 1117 | 1117 | } |
| 1118 | 1118 | while ($buildIt && class_exists($xmlrpcClassName)) { |
| 1119 | 1119 | $xmlrpcClassName .= 'x'; |
@@ -1122,7 +1122,7 @@ discard block |
||
| 1122 | 1122 | /// @todo add method setDebug() to new class, to enable/disable debugging |
| 1123 | 1123 | $source = "class $xmlrpcClassName\n{\n public \$client;\n\n"; |
| 1124 | 1124 | $source .= " function __construct()\n {\n"; |
| 1125 | - $source .= ' ' . str_replace("\n", "\n ", $this->buildClientWrapperCode($client, $verbatimClientCopy, $prefix, static::$namespace)); |
|
| 1125 | + $source .= ' '.str_replace("\n", "\n ", $this->buildClientWrapperCode($client, $verbatimClientCopy, $prefix, static::$namespace)); |
|
| 1126 | 1126 | $source .= "\$this->client = \$client;\n }\n\n"; |
| 1127 | 1127 | $opts = array( |
| 1128 | 1128 | 'return_source' => true, |
@@ -1145,26 +1145,26 @@ discard block |
||
| 1145 | 1145 | $methodWrap = $this->wrapXmlrpcMethod($client, $mName, $opts); |
| 1146 | 1146 | if ($methodWrap) { |
| 1147 | 1147 | if ($buildIt) { |
| 1148 | - $source .= $methodWrap['source'] . "\n"; |
|
| 1148 | + $source .= $methodWrap['source']."\n"; |
|
| 1149 | 1149 | |
| 1150 | 1150 | } else { |
| 1151 | - $source .= ' ' . str_replace("\n", "\n ", $methodWrap['docstring']); |
|
| 1152 | - $source .= str_replace("\n", "\n ", $methodWrap['source']). "\n"; |
|
| 1151 | + $source .= ' '.str_replace("\n", "\n ", $methodWrap['docstring']); |
|
| 1152 | + $source .= str_replace("\n", "\n ", $methodWrap['source'])."\n"; |
|
| 1153 | 1153 | } |
| 1154 | 1154 | |
| 1155 | 1155 | } else { |
| 1156 | - $this->getLogger()->error('XML-RPC: ' . __METHOD__ . ': will not create class method to wrap remote method ' . $mName); |
|
| 1156 | + $this->getLogger()->error('XML-RPC: '.__METHOD__.': will not create class method to wrap remote method '.$mName); |
|
| 1157 | 1157 | } |
| 1158 | 1158 | } |
| 1159 | 1159 | } |
| 1160 | 1160 | $source .= "}\n"; |
| 1161 | 1161 | if ($buildIt) { |
| 1162 | 1162 | $allOK = 0; |
| 1163 | - eval($source . '$allOK=1;'); |
|
| 1163 | + eval($source.'$allOK=1;'); |
|
| 1164 | 1164 | if ($allOK) { |
| 1165 | 1165 | return $xmlrpcClassName; |
| 1166 | 1166 | } else { |
| 1167 | - $this->getLogger()->error('XML-RPC: ' . __METHOD__ . ': could not create class ' . $xmlrpcClassName . ' to wrap remote server ' . $client->server); |
|
| 1167 | + $this->getLogger()->error('XML-RPC: '.__METHOD__.': could not create class '.$xmlrpcClassName.' to wrap remote server '.$client->server); |
|
| 1168 | 1168 | return false; |
| 1169 | 1169 | } |
| 1170 | 1170 | } else { |
@@ -1183,8 +1183,8 @@ discard block |
||
| 1183 | 1183 | */ |
| 1184 | 1184 | protected function buildClientWrapperCode($client, $verbatimClientCopy, $prefix = 'xmlrpc', $namespace = '\\PhpXmlRpc\\') |
| 1185 | 1185 | { |
| 1186 | - $code = "\$client = new {$namespace}Client('" . str_replace(array("\\", "'"), array("\\\\", "\'"), $client->path) . |
|
| 1187 | - "', '" . str_replace(array("\\", "'"), array("\\\\", "\'"), $client->server) . "', $client->port);\n"; |
|
| 1186 | + $code = "\$client = new {$namespace}Client('".str_replace(array("\\", "'"), array("\\\\", "\'"), $client->path). |
|
| 1187 | + "', '".str_replace(array("\\", "'"), array("\\\\", "\'"), $client->server)."', $client->port);\n"; |
|
| 1188 | 1188 | |
| 1189 | 1189 | // copy all client fields to the client that will be generated runtime |
| 1190 | 1190 | // (this provides for future expansion or subclassing of client obj) |
@@ -57,9 +57,9 @@ discard block |
||
| 57 | 57 | public function xml_header($charsetEncoding = '') |
| 58 | 58 | { |
| 59 | 59 | if ($charsetEncoding != '') { |
| 60 | - return "<?xml version=\"1.0\" encoding=\"$charsetEncoding\" ?" . ">\n<methodCall>\n"; |
|
| 60 | + return "<?xml version=\"1.0\" encoding=\"$charsetEncoding\" ?".">\n<methodCall>\n"; |
|
| 61 | 61 | } else { |
| 62 | - return "<?xml version=\"1.0\"?" . ">\n<methodCall>\n"; |
|
| 62 | + return "<?xml version=\"1.0\"?".">\n<methodCall>\n"; |
|
| 63 | 63 | } |
| 64 | 64 | } |
| 65 | 65 | |
@@ -82,16 +82,16 @@ discard block |
||
| 82 | 82 | public function createPayload($charsetEncoding = '') |
| 83 | 83 | { |
| 84 | 84 | if ($charsetEncoding != '') { |
| 85 | - $this->content_type = 'text/xml; charset=' . $charsetEncoding; |
|
| 85 | + $this->content_type = 'text/xml; charset='.$charsetEncoding; |
|
| 86 | 86 | } else { |
| 87 | 87 | $this->content_type = 'text/xml'; |
| 88 | 88 | } |
| 89 | 89 | $this->payload = $this->xml_header($charsetEncoding); |
| 90 | - $this->payload .= '<methodName>' . $this->getCharsetEncoder()->encodeEntities( |
|
| 91 | - $this->methodname, PhpXmlRpc::$xmlrpc_internalencoding, $charsetEncoding) . "</methodName>\n"; |
|
| 90 | + $this->payload .= '<methodName>'.$this->getCharsetEncoder()->encodeEntities( |
|
| 91 | + $this->methodname, PhpXmlRpc::$xmlrpc_internalencoding, $charsetEncoding)."</methodName>\n"; |
|
| 92 | 92 | $this->payload .= "<params>\n"; |
| 93 | 93 | foreach ($this->params as $p) { |
| 94 | - $this->payload .= "<param>\n" . $p->serialize($charsetEncoding) . |
|
| 94 | + $this->payload .= "<param>\n".$p->serialize($charsetEncoding). |
|
| 95 | 95 | "</param>\n"; |
| 96 | 96 | } |
| 97 | 97 | $this->payload .= "</params>\n"; |
@@ -141,7 +141,7 @@ discard block |
||
| 141 | 141 | |
| 142 | 142 | return true; |
| 143 | 143 | } else { |
| 144 | - $this->getLogger()->error('XML-RPC: ' . __METHOD__ . ': value passed in must be a PhpXmlRpc\Value'); |
|
| 144 | + $this->getLogger()->error('XML-RPC: '.__METHOD__.': value passed in must be a PhpXmlRpc\Value'); |
|
| 145 | 145 | return false; |
| 146 | 146 | } |
| 147 | 147 | } |
@@ -213,14 +213,14 @@ discard block |
||
| 213 | 213 | */ |
| 214 | 214 | public function parseResponse($data = '', $headersProcessed = false, $returnType = XMLParser::RETURN_XMLRPCVALS) |
| 215 | 215 | { |
| 216 | - if ($this->debug > 0) { |
|
| 216 | + if ($this->debug>0) { |
|
| 217 | 217 | $this->getLogger()->debug("---GOT---\n$data\n---END---"); |
| 218 | 218 | } |
| 219 | 219 | |
| 220 | 220 | $this->httpResponse = array('raw_data' => $data, 'headers' => array(), 'cookies' => array()); |
| 221 | 221 | |
| 222 | 222 | if ($data == '') { |
| 223 | - $this->getLogger()->error('XML-RPC: ' . __METHOD__ . ': no response received from server.'); |
|
| 223 | + $this->getLogger()->error('XML-RPC: '.__METHOD__.': no response received from server.'); |
|
| 224 | 224 | return new Response(0, PhpXmlRpc::$xmlrpcerr['no_data'], PhpXmlRpc::$xmlrpcstr['no_data']); |
| 225 | 225 | } |
| 226 | 226 | |
@@ -228,12 +228,12 @@ discard block |
||
| 228 | 228 | if (substr($data, 0, 4) == 'HTTP') { |
| 229 | 229 | $httpParser = new Http(); |
| 230 | 230 | try { |
| 231 | - $httpResponse = $httpParser->parseResponseHeaders($data, $headersProcessed, $this->debug > 0); |
|
| 231 | + $httpResponse = $httpParser->parseResponseHeaders($data, $headersProcessed, $this->debug>0); |
|
| 232 | 232 | } catch (HttpException $e) { |
| 233 | 233 | // failed processing of HTTP response headers |
| 234 | 234 | // save into response obj the full payload received, for debugging |
| 235 | 235 | return new Response(0, $e->getCode(), $e->getMessage(), '', array('raw_data' => $data, 'status_code', $e->statusCode())); |
| 236 | - } catch(\Exception $e) { |
|
| 236 | + } catch (\Exception $e) { |
|
| 237 | 237 | return new Response(0, $e->getCode(), $e->getMessage(), '', array('raw_data' => $data)); |
| 238 | 238 | } |
| 239 | 239 | } else { |
@@ -249,7 +249,7 @@ discard block |
||
| 249 | 249 | // idea from Luca Mariano <[email protected]> originally in PEARified version of the lib |
| 250 | 250 | $pos = strrpos($data, '</methodResponse>'); |
| 251 | 251 | if ($pos !== false) { |
| 252 | - $data = substr($data, 0, $pos + 17); |
|
| 252 | + $data = substr($data, 0, $pos+17); |
|
| 253 | 253 | } |
| 254 | 254 | |
| 255 | 255 | // try to 'guestimate' the character encoding of the received response |
@@ -258,21 +258,21 @@ discard block |
||
| 258 | 258 | $data |
| 259 | 259 | ); |
| 260 | 260 | |
| 261 | - if ($this->debug >= 0) { |
|
| 261 | + if ($this->debug>=0) { |
|
| 262 | 262 | $this->httpResponse = $httpResponse; |
| 263 | 263 | } else { |
| 264 | 264 | $httpResponse = null; |
| 265 | 265 | } |
| 266 | 266 | |
| 267 | - if ($this->debug > 0) { |
|
| 267 | + if ($this->debug>0) { |
|
| 268 | 268 | $start = strpos($data, '<!-- SERVER DEBUG INFO (BASE64 ENCODED):'); |
| 269 | 269 | if ($start) { |
| 270 | 270 | $start += strlen('<!-- SERVER DEBUG INFO (BASE64 ENCODED):'); |
| 271 | 271 | /// @todo what if there is no end tag? |
| 272 | 272 | $end = strpos($data, '-->', $start); |
| 273 | - $comments = substr($data, $start, $end - $start); |
|
| 274 | - $this->getLogger()->debug("---SERVER DEBUG INFO (DECODED) ---\n\t" . |
|
| 275 | - str_replace("\n", "\n\t", base64_decode($comments)) . "\n---END---", array('encoding' => $respEncoding)); |
|
| 273 | + $comments = substr($data, $start, $end-$start); |
|
| 274 | + $this->getLogger()->debug("---SERVER DEBUG INFO (DECODED) ---\n\t". |
|
| 275 | + str_replace("\n", "\n\t", base64_decode($comments))."\n---END---", array('encoding' => $respEncoding)); |
|
| 276 | 276 | } |
| 277 | 277 | } |
| 278 | 278 | |
@@ -294,7 +294,7 @@ discard block |
||
| 294 | 294 | if ($respEncoding == 'ISO-8859-1') { |
| 295 | 295 | $data = utf8_encode($data); |
| 296 | 296 | } else { |
| 297 | - $this->getLogger()->error('XML-RPC: ' . __METHOD__ . ': unsupported charset encoding of received response: ' . $respEncoding); |
|
| 297 | + $this->getLogger()->error('XML-RPC: '.__METHOD__.': unsupported charset encoding of received response: '.$respEncoding); |
|
| 298 | 298 | } |
| 299 | 299 | } |
| 300 | 300 | } |
@@ -320,16 +320,16 @@ discard block |
||
| 320 | 320 | // there could be proxies meddling with the request, or network data corruption... |
| 321 | 321 | |
| 322 | 322 | $r = new Response(0, PhpXmlRpc::$xmlrpcerr['invalid_xml'], |
| 323 | - PhpXmlRpc::$xmlrpcstr['invalid_xml'] . ' ' . $xmlRpcParser->_xh['isf_reason'], '', $httpResponse); |
|
| 323 | + PhpXmlRpc::$xmlrpcstr['invalid_xml'].' '.$xmlRpcParser->_xh['isf_reason'], '', $httpResponse); |
|
| 324 | 324 | |
| 325 | - if ($this->debug > 0) { |
|
| 325 | + if ($this->debug>0) { |
|
| 326 | 326 | $this->getLogger()->debug($xmlRpcParser->_xh['isf_reason']); |
| 327 | 327 | } |
| 328 | 328 | } |
| 329 | 329 | // second error check: xml well-formed but not xml-rpc compliant |
| 330 | 330 | elseif ($xmlRpcParser->_xh['isf'] == 2) { |
| 331 | 331 | $r = new Response(0, PhpXmlRpc::$xmlrpcerr['xml_not_compliant'], |
| 332 | - PhpXmlRpc::$xmlrpcstr['xml_not_compliant'] . ' ' . $xmlRpcParser->_xh['isf_reason'], '', $httpResponse); |
|
| 332 | + PhpXmlRpc::$xmlrpcstr['xml_not_compliant'].' '.$xmlRpcParser->_xh['isf_reason'], '', $httpResponse); |
|
| 333 | 333 | |
| 334 | 334 | /// @todo echo something for the user? check if it was already done by the parser... |
| 335 | 335 | //if ($this->debug > 0) { |
@@ -338,7 +338,7 @@ discard block |
||
| 338 | 338 | } |
| 339 | 339 | // third error check: parsing of the response has somehow gone boink. |
| 340 | 340 | /// @todo shall we omit this check, since we trust the parsing code? |
| 341 | - elseif ($xmlRpcParser->_xh['isf'] > 3 || $returnType == XMLParser::RETURN_XMLRPCVALS && !is_object($xmlRpcParser->_xh['value'])) { |
|
| 341 | + elseif ($xmlRpcParser->_xh['isf']>3 || $returnType == XMLParser::RETURN_XMLRPCVALS && !is_object($xmlRpcParser->_xh['value'])) { |
|
| 342 | 342 | // something odd has happened and it's time to generate a client side error indicating something odd went on |
| 343 | 343 | $r = new Response(0, PhpXmlRpc::$xmlrpcerr['xml_parsing_error'], PhpXmlRpc::$xmlrpcstr['xml_parsing_error'], |
| 344 | 344 | '', $httpResponse |
@@ -346,7 +346,7 @@ discard block |
||
| 346 | 346 | |
| 347 | 347 | /// @todo echo something for the user? |
| 348 | 348 | } else { |
| 349 | - if ($this->debug > 1) { |
|
| 349 | + if ($this->debug>1) { |
|
| 350 | 350 | $this->getLogger()->debug( |
| 351 | 351 | "---PARSED---\n".var_export($xmlRpcParser->_xh['value'], true)."\n---END---" |
| 352 | 352 | ); |
@@ -370,7 +370,7 @@ discard block |
||
| 370 | 370 | if ($errNo == 0) { |
| 371 | 371 | // FAULT returned, errno needs to reflect that |
| 372 | 372 | /// @todo feature creep - add this code to PhpXmlRpc::$xmlrpcerr |
| 373 | - $this->getLogger()->error('XML-RPC: ' . __METHOD__ . ': fault response received with faultCode 0 or null. Converted it to -1'); |
|
| 373 | + $this->getLogger()->error('XML-RPC: '.__METHOD__.': fault response received with faultCode 0 or null. Converted it to -1'); |
|
| 374 | 374 | $errNo = -1; |
| 375 | 375 | } |
| 376 | 376 | |