@@ -1,5 +1,5 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -require_once __DIR__ . "/client/_prepend.php"; |
|
| 2 | +require_once __DIR__."/client/_prepend.php"; |
|
| 3 | 3 | |
| 4 | 4 | output('<html lang="en"> |
| 5 | 5 | <head><title>phpxmlrpc</title></head> |
@@ -10,25 +10,25 @@ discard block |
||
| 10 | 10 | output("<p>Please note that in most cases you are better off using `new PhpXmlRpc\Encoder()->encode()` to create nested Value objects</p>\n"); |
| 11 | 11 | |
| 12 | 12 | $v = new PhpXmlRpc\Value(1234, 'int'); |
| 13 | -output("Int: <PRE>" . htmlentities($v->serialize()) . "</PRE>"); |
|
| 13 | +output("Int: <PRE>".htmlentities($v->serialize())."</PRE>"); |
|
| 14 | 14 | |
| 15 | 15 | $v = new PhpXmlRpc\Value('Are the following characters escaped? < & >'); |
| 16 | -output("String <PRE>" . htmlentities($v->serialize()) . "</PRE>"); |
|
| 16 | +output("String <PRE>".htmlentities($v->serialize())."</PRE>"); |
|
| 17 | 17 | |
| 18 | 18 | $v = new PhpXmlRpc\Value(true, 'boolean'); |
| 19 | -output("Boolean: <PRE>" . htmlentities($v->serialize()) . "</PRE>"); |
|
| 19 | +output("Boolean: <PRE>".htmlentities($v->serialize())."</PRE>"); |
|
| 20 | 20 | |
| 21 | 21 | $v = new PhpXmlRpc\Value(1234.5678, 'double'); |
| 22 | -output("Double: <PRE>" . htmlentities($v->serialize()) . "</PRE>"); |
|
| 22 | +output("Double: <PRE>".htmlentities($v->serialize())."</PRE>"); |
|
| 23 | 23 | |
| 24 | 24 | $v = new PhpXmlRpc\Value(time(), 'dateTime.iso8601'); |
| 25 | -output("Datetime (from timestamp): <PRE>" . htmlentities($v->serialize()) . "</PRE>"); |
|
| 25 | +output("Datetime (from timestamp): <PRE>".htmlentities($v->serialize())."</PRE>"); |
|
| 26 | 26 | $v = new PhpXmlRpc\Value(new DateTime(), 'dateTime.iso8601'); |
| 27 | -output("Datetime (from php DateTime): <PRE>" . htmlentities($v->serialize()) . "</PRE>"); |
|
| 27 | +output("Datetime (from php DateTime): <PRE>".htmlentities($v->serialize())."</PRE>"); |
|
| 28 | 28 | |
| 29 | 29 | $v = new PhpXmlRpc\Value('hello world', 'base64'); |
| 30 | -output("Base64: <PRE>" . htmlentities($v->serialize()) . "</PRE>"); |
|
| 31 | -output("(value of base64 string is: '" . $v->scalarval() . "')<BR><BR>"); |
|
| 30 | +output("Base64: <PRE>".htmlentities($v->serialize())."</PRE>"); |
|
| 31 | +output("(value of base64 string is: '".$v->scalarval()."')<BR><BR>"); |
|
| 32 | 32 | |
| 33 | 33 | $v = new PhpXmlRpc\Value( |
| 34 | 34 | array( |
@@ -41,7 +41,7 @@ discard block |
||
| 41 | 41 | ), |
| 42 | 42 | "array" |
| 43 | 43 | ); |
| 44 | -output("Array: <PRE>" . htmlentities($v->serialize()) . "</PRE>"); |
|
| 44 | +output("Array: <PRE>".htmlentities($v->serialize())."</PRE>"); |
|
| 45 | 45 | |
| 46 | 46 | $v = new PhpXmlRpc\Value( |
| 47 | 47 | array( |
@@ -61,10 +61,10 @@ discard block |
||
| 61 | 61 | ), |
| 62 | 62 | "struct" |
| 63 | 63 | ); |
| 64 | -output("Struct: <PRE>" . htmlentities($v->serialize()) . "</PRE>"); |
|
| 64 | +output("Struct: <PRE>".htmlentities($v->serialize())."</PRE>"); |
|
| 65 | 65 | |
| 66 | 66 | $w = new PhpXmlRpc\Value(array($v), 'array'); |
| 67 | -output("Array containing a struct: <PRE>" . htmlentities($w->serialize()) . "</PRE>"); |
|
| 67 | +output("Array containing a struct: <PRE>".htmlentities($w->serialize())."</PRE>"); |
|
| 68 | 68 | |
| 69 | 69 | class MyClass |
| 70 | 70 | { |
@@ -76,49 +76,49 @@ discard block |
||
| 76 | 76 | // the public property is the only one which will be serialized. As such, it has to be of type Value |
| 77 | 77 | $myObject->public = new \PhpXmlRpc\Value('a public property, wrapped'); |
| 78 | 78 | $w = new PhpXmlRpc\Value($myObject, 'struct'); |
| 79 | -output("Struct encoding a php object: <PRE>" . htmlentities($w->serialize()) . "</PRE>"); |
|
| 79 | +output("Struct encoding a php object: <PRE>".htmlentities($w->serialize())."</PRE>"); |
|
| 80 | 80 | |
| 81 | 81 | output("<h3>Testing value serialization - xml-rpc extensions</h3>\n"); |
| 82 | 82 | $v = new PhpXmlRpc\Value(1234, 'i8'); |
| 83 | -output("I8: <PRE>" . htmlentities($v->serialize()) . "</PRE>"); |
|
| 83 | +output("I8: <PRE>".htmlentities($v->serialize())."</PRE>"); |
|
| 84 | 84 | $v = new PhpXmlRpc\Value(null, 'null'); |
| 85 | -output("Null: <PRE>" . htmlentities($v->serialize()) . "</PRE>"); |
|
| 85 | +output("Null: <PRE>".htmlentities($v->serialize())."</PRE>"); |
|
| 86 | 86 | \PhpXmlRpc\PhpXmlRpc::$xmlrpc_null_apache_encoding = true; |
| 87 | -output("Null, alternative: <PRE>" . htmlentities($v->serialize()) . "</PRE>"); |
|
| 87 | +output("Null, alternative: <PRE>".htmlentities($v->serialize())."</PRE>"); |
|
| 88 | 88 | |
| 89 | 89 | output("<h3>Testing value serialization - character encoding</h3>\n"); |
| 90 | 90 | // The greek word 'kosme' |
| 91 | 91 | $v = new PhpXmlRpc\Value('κόσμε'); |
| 92 | -output("Greek (default encoding): <PRE>" . htmlentities($v->serialize()) . "</PRE>"); |
|
| 93 | -output("Greek (utf8 encoding): <PRE>" . htmlentities($v->serialize('UTF-8')) . "</PRE>"); |
|
| 92 | +output("Greek (default encoding): <PRE>".htmlentities($v->serialize())."</PRE>"); |
|
| 93 | +output("Greek (utf8 encoding): <PRE>".htmlentities($v->serialize('UTF-8'))."</PRE>"); |
|
| 94 | 94 | if (function_exists('mb_convert_encoding')) { |
| 95 | - output("Greek (ISO-8859-7 encoding): <PRE>" . htmlentities($v->serialize('ISO-8859-7')) . "</PRE>"); |
|
| 95 | + output("Greek (ISO-8859-7 encoding): <PRE>".htmlentities($v->serialize('ISO-8859-7'))."</PRE>"); |
|
| 96 | 96 | } |
| 97 | 97 | |
| 98 | 98 | output("<h3>Testing request serialization</h3>\n"); |
| 99 | 99 | $req = new PhpXmlRpc\Request('examples.getStateName'); |
| 100 | 100 | $req->method('examples.getStateName'); |
| 101 | 101 | $req->addParam(new PhpXmlRpc\Value(42, 'int')); |
| 102 | -output("<PRE>" . htmlentities($req->serialize()) . "</PRE>"); |
|
| 102 | +output("<PRE>".htmlentities($req->serialize())."</PRE>"); |
|
| 103 | 103 | |
| 104 | 104 | output("<h3>Testing response serialization</h3>\n"); |
| 105 | 105 | $resp = new PhpXmlRpc\Response(new PhpXmlRpc\Value('The meaning of life')); |
| 106 | -output("<PRE>" . htmlentities($resp->serialize()) . "</PRE>"); |
|
| 106 | +output("<PRE>".htmlentities($resp->serialize())."</PRE>"); |
|
| 107 | 107 | |
| 108 | 108 | output("<h3>Testing ISO date formatting</h3><pre>\n"); |
| 109 | 109 | $t = time(); |
| 110 | 110 | $date = PhpXmlRpc\Helper\Date::iso8601Encode($t); |
| 111 | 111 | output("Now is $t --> $date\n"); |
| 112 | -output("Or in UTC, that is " . PhpXmlRpc\Helper\Date::iso8601Encode($t, 1) . "\n"); |
|
| 112 | +output("Or in UTC, that is ".PhpXmlRpc\Helper\Date::iso8601Encode($t, 1)."\n"); |
|
| 113 | 113 | $tb = PhpXmlRpc\Helper\Date::iso8601Decode($date); |
| 114 | 114 | output("That is to say $date --> $tb\n"); |
| 115 | -output("Which comes out at " . PhpXmlRpc\Helper\Date::iso8601Encode($tb) . "\n"); |
|
| 116 | -output("Which was the time in UTC at " . PhpXmlRpc\Helper\Date::iso8601Encode($tb, 1) . "\n"); |
|
| 115 | +output("Which comes out at ".PhpXmlRpc\Helper\Date::iso8601Encode($tb)."\n"); |
|
| 116 | +output("Which was the time in UTC at ".PhpXmlRpc\Helper\Date::iso8601Encode($tb, 1)."\n"); |
|
| 117 | 117 | output("</pre>\n"); |
| 118 | 118 | |
| 119 | 119 | output("<h3>Testing reduced-precision formatting for doubles</h3><pre>\n"); |
| 120 | 120 | $v = new PhpXmlRpc\Value(1234.56789, 'double'); |
| 121 | 121 | \PhpXmlRpc\PhpXmlRpc::$xmlpc_double_precision = 2; |
| 122 | -output("Double, limited precision: <PRE>" . htmlentities($v->serialize()) . "</PRE>"); |
|
| 122 | +output("Double, limited precision: <PRE>".htmlentities($v->serialize())."</PRE>"); |
|
| 123 | 123 | |
| 124 | 124 | output('</body></html>'); |
@@ -26,11 +26,11 @@ discard block |
||
| 26 | 26 | */ |
| 27 | 27 | function plain_findstate($stateNo) |
| 28 | 28 | { |
| 29 | - if (isset(exampleMethods::$stateNames[$stateNo - 1])) { |
|
| 30 | - return exampleMethods::$stateNames[$stateNo - 1]; |
|
| 29 | + if (isset(exampleMethods::$stateNames[$stateNo-1])) { |
|
| 30 | + return exampleMethods::$stateNames[$stateNo-1]; |
|
| 31 | 31 | } else { |
| 32 | 32 | // not, there so complain |
| 33 | - throw new Exception("I don't have a state for the index '" . $stateNo . "'", PhpXmlRpc\PhpXmlRpc::$xmlrpcerruser); |
|
| 33 | + throw new Exception("I don't have a state for the index '".$stateNo."'", PhpXmlRpc\PhpXmlRpc::$xmlrpcerruser); |
|
| 34 | 34 | } |
| 35 | 35 | } |
| 36 | 36 | |
@@ -69,7 +69,7 @@ discard block |
||
| 69 | 69 | if ($req->getNumParams()) { |
| 70 | 70 | $p1 = $req->getParam(0); |
| 71 | 71 | if ($p1->kindOf() === 'scalar') { |
| 72 | - $errNum = (int)$p1->scalarval(); |
|
| 72 | + $errNum = (int) $p1->scalarval(); |
|
| 73 | 73 | } |
| 74 | 74 | } |
| 75 | 75 | throw new Exception("it's just a test", $errNum); |
@@ -141,13 +141,13 @@ discard block |
||
| 141 | 141 | |
| 142 | 142 | $findstate10_sig = array( |
| 143 | 143 | /// @todo add a demo and test with closure usage |
| 144 | - "function" => function ($req) { return exampleMethods::findState($req); }, |
|
| 144 | + "function" => function($req) { return exampleMethods::findState($req); }, |
|
| 145 | 145 | "signature" => array(array(Value::$xmlrpcString, Value::$xmlrpcInt)), |
| 146 | - "docstring" => 'When passed an integer between 1 and 51 returns the name of a US state, where the integer is the ' . |
|
| 146 | + "docstring" => 'When passed an integer between 1 and 51 returns the name of a US state, where the integer is the '. |
|
| 147 | 147 | 'index of that state name in an alphabetic order.', |
| 148 | 148 | ); |
| 149 | 149 | |
| 150 | -$findstate11_sig = $wrapper->wrapPhpFunction(function ($stateNo) { return plain_findstate($stateNo); }); |
|
| 150 | +$findstate11_sig = $wrapper->wrapPhpFunction(function($stateNo) { return plain_findstate($stateNo); }); |
|
| 151 | 151 | |
| 152 | 152 | /// @todo do we really need a new instance ? |
| 153 | 153 | $c = new handlersContainer(); |
@@ -156,7 +156,7 @@ discard block |
||
| 156 | 156 | |
| 157 | 157 | $namespaceSignatures = $wrapper->wrapPhpClass($c, array('prefix' => 'namespacetest.', 'replace_class_name' => true, 'method_filter' => '/^findState$/', 'method_type' => 'static')); |
| 158 | 158 | |
| 159 | -$returnObj_sig = $wrapper->wrapPhpFunction(array($c, 'returnObject'), '', array('encode_php_objs' => true)); |
|
| 159 | +$returnObj_sig = $wrapper->wrapPhpFunction(array($c, 'returnObject'), '', array('encode_php_objs' => true)); |
|
| 160 | 160 | |
| 161 | 161 | return array_merge( |
| 162 | 162 | array( |
@@ -24,7 +24,7 @@ discard block |
||
| 24 | 24 | } |
| 25 | 25 | } |
| 26 | 26 | |
| 27 | -require_once __DIR__ . "/_prepend.php"; |
|
| 27 | +require_once __DIR__."/_prepend.php"; |
|
| 28 | 28 | |
| 29 | 29 | use PhpXmlRpc\PhpXmlRpc; |
| 30 | 30 | use PhpXmlRpc\Server; |
@@ -83,7 +83,7 @@ discard block |
||
| 83 | 83 | } elseif ($_GET['FORCE_AUTH'] == 'Digest') { |
| 84 | 84 | if (empty($_SERVER['PHP_AUTH_DIGEST'])) { |
| 85 | 85 | header('HTTP/1.1 401 Unauthorized'); |
| 86 | - header('WWW-Authenticate: Digest realm="Phpxmlrpc Digest Realm",qop="auth",nonce="' . uniqid() . '",opaque="' . md5('Phpxmlrpc Digest Realm') . '"'); |
|
| 86 | + header('WWW-Authenticate: Digest realm="Phpxmlrpc Digest Realm",qop="auth",nonce="'.uniqid().'",opaque="'.md5('Phpxmlrpc Digest Realm').'"'); |
|
| 87 | 87 | die('Text visible if user hits Cancel button'); |
| 88 | 88 | } |
| 89 | 89 | } |
@@ -91,7 +91,7 @@ discard block |
||
| 91 | 91 | if (isset($_GET['FORCE_REDIRECT'])) { |
| 92 | 92 | header('HTTP/1.0 302 Found'); |
| 93 | 93 | unset($_GET['FORCE_REDIRECT']); |
| 94 | - header('Location: ' . $_SERVER['REQUEST_URI'] . (count($_GET) ? '?' . http_build_query($_GET) : '')); |
|
| 94 | + header('Location: '.$_SERVER['REQUEST_URI'].(count($_GET) ? '?'.http_build_query($_GET) : '')); |
|
| 95 | 95 | die(); |
| 96 | 96 | } |
| 97 | 97 | } |
@@ -8,7 +8,7 @@ discard block |
||
| 8 | 8 | } |
| 9 | 9 | |
| 10 | 10 | // Use the custom class autoloader. These two lines are not needed when the phpxmlrpc library is installed using Composer |
| 11 | -include_once __DIR__ . '/../../src/Autoloader.php'; |
|
| 11 | +include_once __DIR__.'/../../src/Autoloader.php'; |
|
| 12 | 12 | PhpXmlRpc\Autoloader::register(); |
| 13 | 13 | |
| 14 | 14 | // Let unit tests run against localhost, 'plain' demos against a known public server |
@@ -22,5 +22,5 @@ discard block |
||
| 22 | 22 | function output($text) |
| 23 | 23 | { |
| 24 | 24 | /// @todo we should only strip html tags, and let through all xml tags |
| 25 | - echo PHP_SAPI == 'cli' ? strip_tags(str_replace(array('<br/>','<br>'), "\n", $text)) : $text; |
|
| 25 | + echo PHP_SAPI == 'cli' ? strip_tags(str_replace(array('<br/>', '<br>'), "\n", $text)) : $text; |
|
| 26 | 26 | } |
@@ -1,5 +1,5 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -require_once __DIR__ . "/_prepend.php"; |
|
| 2 | +require_once __DIR__."/_prepend.php"; |
|
| 3 | 3 | |
| 4 | 4 | /** |
| 5 | 5 | * Demoing how to inject a custom logger for use by the library |
@@ -22,13 +22,13 @@ discard block |
||
| 22 | 22 | // logger API |
| 23 | 23 | public function debug($message, $context = array()) |
| 24 | 24 | { |
| 25 | - $this->debugBuffer .= $message . "\n"; |
|
| 25 | + $this->debugBuffer .= $message."\n"; |
|
| 26 | 26 | } |
| 27 | 27 | |
| 28 | 28 | // logger API |
| 29 | 29 | public function error($message, $context = array()) |
| 30 | 30 | { |
| 31 | - $this->errorBuffer .= $message . "\n"; |
|
| 31 | + $this->errorBuffer .= $message."\n"; |
|
| 32 | 32 | } |
| 33 | 33 | |
| 34 | 34 | public function getDebug() |
@@ -59,8 +59,8 @@ discard block |
||
| 59 | 59 | |
| 60 | 60 | $input = array( |
| 61 | 61 | array('name' => 'Dave', 'age' => 24), |
| 62 | - array('name' => 'Edd', 'age' => 45), |
|
| 63 | - array('name' => 'Joe', 'age' => 37), |
|
| 62 | + array('name' => 'Edd', 'age' => 45), |
|
| 63 | + array('name' => 'Joe', 'age' => 37), |
|
| 64 | 64 | array('name' => 'Fred', 'age' => 27), |
| 65 | 65 | ); |
| 66 | 66 | |
@@ -79,5 +79,5 @@ discard block |
||
| 79 | 79 | $response = $client->send($request); |
| 80 | 80 | output("Response received.<br>"); |
| 81 | 81 | |
| 82 | -output("The client error info is:<pre>\n" . $logger->getError() . "\n</pre>"); |
|
| 83 | -output("The client debug info is:<pre>\n" . $logger->getDebug() . "\n</pre>"); |
|
| 82 | +output("The client error info is:<pre>\n".$logger->getError()."\n</pre>"); |
|
| 83 | +output("The client debug info is:<pre>\n".$logger->getDebug()."\n</pre>"); |
|
@@ -93,7 +93,7 @@ discard block |
||
| 93 | 93 | $this->me['struct'] = $val; |
| 94 | 94 | break; |
| 95 | 95 | default: |
| 96 | - $this->getLogger()->error("XML-RPC: " . __METHOD__ . ": not a known type ($type)"); |
|
| 96 | + $this->getLogger()->error("XML-RPC: ".__METHOD__.": not a known type ($type)"); |
|
| 97 | 97 | } |
| 98 | 98 | } |
| 99 | 99 | } |
@@ -117,7 +117,7 @@ discard block |
||
| 117 | 117 | } |
| 118 | 118 | |
| 119 | 119 | if ($typeOf !== 1) { |
| 120 | - $this->getLogger()->error("XML-RPC: " . __METHOD__ . ": not a scalar type ($type)"); |
|
| 120 | + $this->getLogger()->error("XML-RPC: ".__METHOD__.": not a scalar type ($type)"); |
|
| 121 | 121 | return 0; |
| 122 | 122 | } |
| 123 | 123 | |
@@ -134,10 +134,10 @@ discard block |
||
| 134 | 134 | |
| 135 | 135 | switch ($this->mytype) { |
| 136 | 136 | case 1: |
| 137 | - $this->getLogger()->error('XML-RPC: ' . __METHOD__ . ': scalar xmlrpc value can have only one value'); |
|
| 137 | + $this->getLogger()->error('XML-RPC: '.__METHOD__.': scalar xmlrpc value can have only one value'); |
|
| 138 | 138 | return 0; |
| 139 | 139 | case 3: |
| 140 | - $this->getLogger()->error('XML-RPC: ' . __METHOD__ . ': cannot add anonymous scalar to struct xmlrpc value'); |
|
| 140 | + $this->getLogger()->error('XML-RPC: '.__METHOD__.': cannot add anonymous scalar to struct xmlrpc value'); |
|
| 141 | 141 | return 0; |
| 142 | 142 | case 2: |
| 143 | 143 | // we're adding a scalar value to an array here |
@@ -179,7 +179,7 @@ discard block |
||
| 179 | 179 | |
| 180 | 180 | return 1; |
| 181 | 181 | } else { |
| 182 | - $this->getLogger()->error('XML-RPC: ' . __METHOD__ . ': already initialized as a [' . $this->kindOf() . ']'); |
|
| 182 | + $this->getLogger()->error('XML-RPC: '.__METHOD__.': already initialized as a ['.$this->kindOf().']'); |
|
| 183 | 183 | return 0; |
| 184 | 184 | } |
| 185 | 185 | } |
@@ -209,7 +209,7 @@ discard block |
||
| 209 | 209 | |
| 210 | 210 | return 1; |
| 211 | 211 | } else { |
| 212 | - $this->getLogger()->error('XML-RPC: ' . __METHOD__ . ': already initialized as a [' . $this->kindOf() . ']'); |
|
| 212 | + $this->getLogger()->error('XML-RPC: '.__METHOD__.': already initialized as a ['.$this->kindOf().']'); |
|
| 213 | 213 | return 0; |
| 214 | 214 | } |
| 215 | 215 | } |
@@ -251,19 +251,19 @@ discard block |
||
| 251 | 251 | case 1: |
| 252 | 252 | switch ($typ) { |
| 253 | 253 | case static::$xmlrpcBase64: |
| 254 | - $rs .= "<{$typ}>" . base64_encode($val) . "</{$typ}>"; |
|
| 254 | + $rs .= "<{$typ}>".base64_encode($val)."</{$typ}>"; |
|
| 255 | 255 | break; |
| 256 | 256 | case static::$xmlrpcBoolean: |
| 257 | - $rs .= "<{$typ}>" . ($val ? '1' : '0') . "</{$typ}>"; |
|
| 257 | + $rs .= "<{$typ}>".($val ? '1' : '0')."</{$typ}>"; |
|
| 258 | 258 | break; |
| 259 | 259 | case static::$xmlrpcString: |
| 260 | 260 | // Do NOT use htmlentities, since it will produce named html entities, which are invalid xml |
| 261 | - $rs .= "<{$typ}>" . $this->getCharsetEncoder()->encodeEntities($val, PhpXmlRpc::$xmlrpc_internalencoding, $charsetEncoding) . "</{$typ}>"; |
|
| 261 | + $rs .= "<{$typ}>".$this->getCharsetEncoder()->encodeEntities($val, PhpXmlRpc::$xmlrpc_internalencoding, $charsetEncoding)."</{$typ}>"; |
|
| 262 | 262 | break; |
| 263 | 263 | case static::$xmlrpcInt: |
| 264 | 264 | case static::$xmlrpcI4: |
| 265 | 265 | case static::$xmlrpcI8: |
| 266 | - $rs .= "<{$typ}>" . (int)$val . "</{$typ}>"; |
|
| 266 | + $rs .= "<{$typ}>".(int) $val."</{$typ}>"; |
|
| 267 | 267 | break; |
| 268 | 268 | case static::$xmlrpcDouble: |
| 269 | 269 | // avoid using standard conversion of float to string because it is locale-dependent, |
@@ -271,16 +271,16 @@ discard block |
||
| 271 | 271 | // sprintf('%F') could be most likely ok, but it fails e.g. on 2e-14. |
| 272 | 272 | // The code below tries its best at keeping max precision while avoiding exp notation, |
| 273 | 273 | // but there is of course no limit in the number of decimal places to be used... |
| 274 | - $rs .= "<{$typ}>" . preg_replace('/\\.?0+$/', '', number_format((double)$val, PhpXmlRpc::$xmlpc_double_precision, '.', '')) . "</{$typ}>"; |
|
| 274 | + $rs .= "<{$typ}>".preg_replace('/\\.?0+$/', '', number_format((double) $val, PhpXmlRpc::$xmlpc_double_precision, '.', ''))."</{$typ}>"; |
|
| 275 | 275 | break; |
| 276 | 276 | case static::$xmlrpcDateTime: |
| 277 | 277 | if (is_string($val)) { |
| 278 | 278 | $rs .= "<{$typ}>{$val}</{$typ}>"; |
| 279 | 279 | // DateTimeInterface is not present in php 5.4... |
| 280 | 280 | } elseif (is_a($val, 'DateTimeInterface') || is_a($val, 'DateTime')) { |
| 281 | - $rs .= "<{$typ}>" . $val->format('Ymd\TH:i:s') . "</{$typ}>"; |
|
| 281 | + $rs .= "<{$typ}>".$val->format('Ymd\TH:i:s')."</{$typ}>"; |
|
| 282 | 282 | } elseif (is_int($val)) { |
| 283 | - $rs .= "<{$typ}>" . date('Ymd\TH:i:s', $val) . "</{$typ}>"; |
|
| 283 | + $rs .= "<{$typ}>".date('Ymd\TH:i:s', $val)."</{$typ}>"; |
|
| 284 | 284 | } else { |
| 285 | 285 | // not really a good idea here: but what should we output anyway? left for backward compat... |
| 286 | 286 | $rs .= "<{$typ}>{$val}</{$typ}>"; |
@@ -302,14 +302,14 @@ discard block |
||
| 302 | 302 | case 3: |
| 303 | 303 | // struct |
| 304 | 304 | if ($this->_php_class) { |
| 305 | - $rs .= '<struct php_class="' . $this->_php_class . "\">\n"; |
|
| 305 | + $rs .= '<struct php_class="'.$this->_php_class."\">\n"; |
|
| 306 | 306 | } else { |
| 307 | 307 | $rs .= "<struct>\n"; |
| 308 | 308 | } |
| 309 | 309 | $charsetEncoder = $this->getCharsetEncoder(); |
| 310 | 310 | /** @var Value $val2 */ |
| 311 | 311 | foreach ($val as $key2 => $val2) { |
| 312 | - $rs .= '<member><name>' . $charsetEncoder->encodeEntities($key2, PhpXmlRpc::$xmlrpc_internalencoding, $charsetEncoding) . "</name>\n"; |
|
| 312 | + $rs .= '<member><name>'.$charsetEncoder->encodeEntities($key2, PhpXmlRpc::$xmlrpc_internalencoding, $charsetEncoding)."</name>\n"; |
|
| 313 | 313 | //$rs.=$this->serializeval($val2); |
| 314 | 314 | $rs .= $val2->serialize($charsetEncoding); |
| 315 | 315 | $rs .= "</member>\n"; |
@@ -344,7 +344,7 @@ discard block |
||
| 344 | 344 | $val = reset($this->me); |
| 345 | 345 | $typ = key($this->me); |
| 346 | 346 | |
| 347 | - return '<value>' . $this->serializedata($typ, $val, $charsetEncoding) . "</value>\n"; |
|
| 347 | + return '<value>'.$this->serializedata($typ, $val, $charsetEncoding)."</value>\n"; |
|
| 348 | 348 | } |
| 349 | 349 | |
| 350 | 350 | /** |
@@ -293,10 +293,10 @@ discard block |
||
| 293 | 293 | $server = $parts['host']; |
| 294 | 294 | $path = isset($parts['path']) ? $parts['path'] : ''; |
| 295 | 295 | if (isset($parts['query'])) { |
| 296 | - $path .= '?' . $parts['query']; |
|
| 296 | + $path .= '?'.$parts['query']; |
|
| 297 | 297 | } |
| 298 | 298 | if (isset($parts['fragment'])) { |
| 299 | - $path .= '#' . $parts['fragment']; |
|
| 299 | + $path .= '#'.$parts['fragment']; |
|
| 300 | 300 | } |
| 301 | 301 | if (isset($parts['port'])) { |
| 302 | 302 | $port = $parts['port']; |
@@ -312,7 +312,7 @@ discard block |
||
| 312 | 312 | } |
| 313 | 313 | } |
| 314 | 314 | if ($path == '' || $path[0] != '/') { |
| 315 | - $this->path = '/' . $path; |
|
| 315 | + $this->path = '/'.$path; |
|
| 316 | 316 | } else { |
| 317 | 317 | $this->path = $path; |
| 318 | 318 | } |
@@ -344,7 +344,7 @@ discard block |
||
| 344 | 344 | //$this->accepted_charset_encodings = $ch->knownCharsets(); |
| 345 | 345 | |
| 346 | 346 | // initialize user_agent string |
| 347 | - $this->user_agent = PhpXmlRpc::$xmlrpcName . ' ' . PhpXmlRpc::$xmlrpcVersion; |
|
| 347 | + $this->user_agent = PhpXmlRpc::$xmlrpcName.' '.PhpXmlRpc::$xmlrpcVersion; |
|
| 348 | 348 | } |
| 349 | 349 | |
| 350 | 350 | /** |
@@ -638,12 +638,12 @@ discard block |
||
| 638 | 638 | */ |
| 639 | 639 | public function getUrl() |
| 640 | 640 | { |
| 641 | - $url = $this->method . '://' . $this->server; |
|
| 641 | + $url = $this->method.'://'.$this->server; |
|
| 642 | 642 | if (($this->port = 80 && in_array($this->method, array('http', 'http10', 'http11', 'h2c'))) && |
| 643 | 643 | ($this->port = 443 && in_array($this->method, array('https', 'h2')))) { |
| 644 | - return $url . $this->path; |
|
| 644 | + return $url.$this->path; |
|
| 645 | 645 | } else { |
| 646 | - return $url . ':' . $this->port . $this->path; |
|
| 646 | + return $url.':'.$this->port.$this->path; |
|
| 647 | 647 | } |
| 648 | 648 | } |
| 649 | 649 | |
@@ -784,7 +784,7 @@ discard block |
||
| 784 | 784 | */ |
| 785 | 785 | protected function sendPayloadHTTP10($req, $server, $port, $timeout = 0, $username = '', $password = '', |
| 786 | 786 | $authType = 1, $proxyHost = '', $proxyPort = 0, $proxyUsername = '', $proxyPassword = '', $proxyAuthType = 1, |
| 787 | - $method='http') |
|
| 787 | + $method = 'http') |
|
| 788 | 788 | { |
| 789 | 789 | //trigger_error('Method ' . __METHOD__ . ' is deprecated', E_USER_DEPRECATED); |
| 790 | 790 | |
@@ -817,7 +817,7 @@ discard block |
||
| 817 | 817 | * @param int $sslVersion |
| 818 | 818 | * @return Response |
| 819 | 819 | */ |
| 820 | - protected function sendPayloadHTTPS($req, $server, $port, $timeout = 0, $username = '', $password = '', |
|
| 820 | + protected function sendPayloadHTTPS($req, $server, $port, $timeout = 0, $username = '', $password = '', |
|
| 821 | 821 | $authType = 1, $cert = '', $certPass = '', $caCert = '', $caCertDir = '', $proxyHost = '', $proxyPort = 0, |
| 822 | 822 | $proxyUsername = '', $proxyPassword = '', $proxyAuthType = 1, $keepAlive = false, $key = '', $keyPass = '', |
| 823 | 823 | $sslVersion = 0) |
@@ -856,7 +856,7 @@ discard block |
||
| 856 | 856 | */ |
| 857 | 857 | protected function sendPayloadSocket($req, $server, $port, $timeout = 0, $username = '', $password = '', |
| 858 | 858 | $authType = 1, $cert = '', $certPass = '', $caCert = '', $caCertDir = '', $proxyHost = '', $proxyPort = 0, |
| 859 | - $proxyUsername = '', $proxyPassword = '', $proxyAuthType = 1, $method='http', $key = '', $keyPass = '', |
|
| 859 | + $proxyUsername = '', $proxyPassword = '', $proxyAuthType = 1, $method = 'http', $key = '', $keyPass = '', |
|
| 860 | 860 | $sslVersion = 0) |
| 861 | 861 | { |
| 862 | 862 | /// @todo log a warning if passed an unsupported method |
@@ -893,16 +893,16 @@ discard block |
||
| 893 | 893 | // thanks to Grant Rauscher <[email protected]> for this |
| 894 | 894 | $credentials = ''; |
| 895 | 895 | if ($username != '') { |
| 896 | - $credentials = 'Authorization: Basic ' . base64_encode($username . ':' . $password) . "\r\n"; |
|
| 896 | + $credentials = 'Authorization: Basic '.base64_encode($username.':'.$password)."\r\n"; |
|
| 897 | 897 | if ($authType != 1) { |
| 898 | 898 | /// @todo make this a proper error, i.e. return a failure |
| 899 | - $this->getLogger()->error('XML-RPC: ' . __METHOD__ . ': warning. Only Basic auth is supported with HTTP 1.0'); |
|
| 899 | + $this->getLogger()->error('XML-RPC: '.__METHOD__.': warning. Only Basic auth is supported with HTTP 1.0'); |
|
| 900 | 900 | } |
| 901 | 901 | } |
| 902 | 902 | |
| 903 | 903 | $acceptedEncoding = ''; |
| 904 | 904 | if (is_array($this->accepted_compression) && count($this->accepted_compression)) { |
| 905 | - $acceptedEncoding = 'Accept-Encoding: ' . implode(', ', $this->accepted_compression) . "\r\n"; |
|
| 905 | + $acceptedEncoding = 'Accept-Encoding: '.implode(', ', $this->accepted_compression)."\r\n"; |
|
| 906 | 906 | } |
| 907 | 907 | |
| 908 | 908 | $proxyCredentials = ''; |
@@ -914,13 +914,13 @@ discard block |
||
| 914 | 914 | $connectPort = $proxyPort; |
| 915 | 915 | $transport = 'tcp'; |
| 916 | 916 | /// @todo check: should we not use https in some cases? |
| 917 | - $uri = 'http://' . $server . ':' . $port . $this->path; |
|
| 917 | + $uri = 'http://'.$server.':'.$port.$this->path; |
|
| 918 | 918 | if ($proxyUsername != '') { |
| 919 | 919 | if ($proxyAuthType != 1) { |
| 920 | 920 | /// @todo make this a proper error, i.e. return a failure |
| 921 | - $this->getLogger()->error('XML-RPC: ' . __METHOD__ . ': warning. Only Basic auth to proxy is supported with HTTP 1.0'); |
|
| 921 | + $this->getLogger()->error('XML-RPC: '.__METHOD__.': warning. Only Basic auth to proxy is supported with HTTP 1.0'); |
|
| 922 | 922 | } |
| 923 | - $proxyCredentials = 'Proxy-Authorization: Basic ' . base64_encode($proxyUsername . ':' . $proxyPassword) . "\r\n"; |
|
| 923 | + $proxyCredentials = 'Proxy-Authorization: Basic '.base64_encode($proxyUsername.':'.$proxyPassword)."\r\n"; |
|
| 924 | 924 | } |
| 925 | 925 | } else { |
| 926 | 926 | $connectServer = $server; |
@@ -935,45 +935,45 @@ discard block |
||
| 935 | 935 | $version = ''; |
| 936 | 936 | foreach ($this->cookies as $name => $cookie) { |
| 937 | 937 | if ($cookie['version']) { |
| 938 | - $version = ' $Version="' . $cookie['version'] . '";'; |
|
| 939 | - $cookieHeader .= ' ' . $name . '="' . $cookie['value'] . '";'; |
|
| 938 | + $version = ' $Version="'.$cookie['version'].'";'; |
|
| 939 | + $cookieHeader .= ' '.$name.'="'.$cookie['value'].'";'; |
|
| 940 | 940 | if ($cookie['path']) { |
| 941 | - $cookieHeader .= ' $Path="' . $cookie['path'] . '";'; |
|
| 941 | + $cookieHeader .= ' $Path="'.$cookie['path'].'";'; |
|
| 942 | 942 | } |
| 943 | 943 | if ($cookie['domain']) { |
| 944 | - $cookieHeader .= ' $Domain="' . $cookie['domain'] . '";'; |
|
| 944 | + $cookieHeader .= ' $Domain="'.$cookie['domain'].'";'; |
|
| 945 | 945 | } |
| 946 | 946 | if ($cookie['port']) { |
| 947 | - $cookieHeader .= ' $Port="' . $cookie['port'] . '";'; |
|
| 947 | + $cookieHeader .= ' $Port="'.$cookie['port'].'";'; |
|
| 948 | 948 | } |
| 949 | 949 | } else { |
| 950 | - $cookieHeader .= ' ' . $name . '=' . $cookie['value'] . ";"; |
|
| 950 | + $cookieHeader .= ' '.$name.'='.$cookie['value'].";"; |
|
| 951 | 951 | } |
| 952 | 952 | } |
| 953 | - $cookieHeader = 'Cookie:' . $version . substr($cookieHeader, 0, -1) . "\r\n"; |
|
| 953 | + $cookieHeader = 'Cookie:'.$version.substr($cookieHeader, 0, -1)."\r\n"; |
|
| 954 | 954 | } |
| 955 | 955 | |
| 956 | 956 | // omit port if default |
| 957 | 957 | if (($port == 80 && in_array($method, array('http', 'http10'))) || ($port == 443 && $method == 'https')) { |
| 958 | - $port = ''; |
|
| 958 | + $port = ''; |
|
| 959 | 959 | } else { |
| 960 | - $port = ':' . $port; |
|
| 960 | + $port = ':'.$port; |
|
| 961 | 961 | } |
| 962 | 962 | |
| 963 | - $op = 'POST ' . $uri . " HTTP/1.0\r\n" . |
|
| 964 | - 'User-Agent: ' . $this->user_agent . "\r\n" . |
|
| 965 | - 'Host: ' . $server . $port . "\r\n" . |
|
| 966 | - $credentials . |
|
| 967 | - $proxyCredentials . |
|
| 968 | - $acceptedEncoding . |
|
| 969 | - $encodingHdr . |
|
| 970 | - 'Accept-Charset: ' . implode(',', $this->accepted_charset_encodings) . "\r\n" . |
|
| 971 | - $cookieHeader . |
|
| 972 | - 'Content-Type: ' . $req->content_type . "\r\nContent-Length: " . |
|
| 973 | - strlen($payload) . "\r\n\r\n" . |
|
| 963 | + $op = 'POST '.$uri." HTTP/1.0\r\n". |
|
| 964 | + 'User-Agent: '.$this->user_agent."\r\n". |
|
| 965 | + 'Host: '.$server.$port."\r\n". |
|
| 966 | + $credentials. |
|
| 967 | + $proxyCredentials. |
|
| 968 | + $acceptedEncoding. |
|
| 969 | + $encodingHdr. |
|
| 970 | + 'Accept-Charset: '.implode(',', $this->accepted_charset_encodings)."\r\n". |
|
| 971 | + $cookieHeader. |
|
| 972 | + 'Content-Type: '.$req->content_type."\r\nContent-Length: ". |
|
| 973 | + strlen($payload)."\r\n\r\n". |
|
| 974 | 974 | $payload; |
| 975 | 975 | |
| 976 | - if ($this->debug > 1) { |
|
| 976 | + if ($this->debug>1) { |
|
| 977 | 977 | $this->getLogger()->debug("---SENDING---\n$op\n---END---"); |
| 978 | 978 | } |
| 979 | 979 | |
@@ -1000,7 +1000,7 @@ discard block |
||
| 1000 | 1000 | |
| 1001 | 1001 | $context = stream_context_create($contextOptions); |
| 1002 | 1002 | |
| 1003 | - if ($timeout <= 0) { |
|
| 1003 | + if ($timeout<=0) { |
|
| 1004 | 1004 | $connectTimeout = ini_get('default_socket_timeout'); |
| 1005 | 1005 | } else { |
| 1006 | 1006 | $connectTimeout = $timeout; |
@@ -1012,7 +1012,7 @@ discard block |
||
| 1012 | 1012 | $fp = @stream_socket_client("$transport://$connectServer:$connectPort", $this->errno, $this->errstr, $connectTimeout, |
| 1013 | 1013 | STREAM_CLIENT_CONNECT, $context); |
| 1014 | 1014 | if ($fp) { |
| 1015 | - if ($timeout > 0) { |
|
| 1015 | + if ($timeout>0) { |
|
| 1016 | 1016 | stream_set_timeout($fp, $timeout, 0); |
| 1017 | 1017 | } |
| 1018 | 1018 | } else { |
@@ -1021,8 +1021,8 @@ discard block |
||
| 1021 | 1021 | $this->errstr = $err['message']; |
| 1022 | 1022 | } |
| 1023 | 1023 | |
| 1024 | - $this->errstr = 'Connect error: ' . $this->errstr; |
|
| 1025 | - $r = new static::$responseClass(0, PhpXmlRpc::$xmlrpcerr['http_error'], $this->errstr . ' (' . $this->errno . ')'); |
|
| 1024 | + $this->errstr = 'Connect error: '.$this->errstr; |
|
| 1025 | + $r = new static::$responseClass(0, PhpXmlRpc::$xmlrpcerr['http_error'], $this->errstr.' ('.$this->errno.')'); |
|
| 1026 | 1026 | |
| 1027 | 1027 | return $r; |
| 1028 | 1028 | } |
@@ -1110,18 +1110,18 @@ discard block |
||
| 1110 | 1110 | $keyPass, $sslVersion); |
| 1111 | 1111 | |
| 1112 | 1112 | if (!$curl) { |
| 1113 | - return new static::$responseClass(0, PhpXmlRpc::$xmlrpcerr['curl_fail'], PhpXmlRpc::$xmlrpcstr['curl_fail'] . ': error during curl initialization. Check php error log for details'); |
|
| 1113 | + return new static::$responseClass(0, PhpXmlRpc::$xmlrpcerr['curl_fail'], PhpXmlRpc::$xmlrpcstr['curl_fail'].': error during curl initialization. Check php error log for details'); |
|
| 1114 | 1114 | } |
| 1115 | 1115 | |
| 1116 | 1116 | $result = curl_exec($curl); |
| 1117 | 1117 | |
| 1118 | - if ($this->debug > 1) { |
|
| 1118 | + if ($this->debug>1) { |
|
| 1119 | 1119 | $message = "---CURL INFO---\n"; |
| 1120 | 1120 | foreach (curl_getinfo($curl) as $name => $val) { |
| 1121 | 1121 | if (is_array($val)) { |
| 1122 | 1122 | $val = implode("\n", $val); |
| 1123 | 1123 | } |
| 1124 | - $message .= $name . ': ' . $val . "\n"; |
|
| 1124 | + $message .= $name.': '.$val."\n"; |
|
| 1125 | 1125 | } |
| 1126 | 1126 | $message .= '---END---'; |
| 1127 | 1127 | $this->getLogger()->debug($message); |
@@ -1131,7 +1131,7 @@ discard block |
||
| 1131 | 1131 | /// @todo we should use a better check here - what if we get back '' or '0'? |
| 1132 | 1132 | |
| 1133 | 1133 | $this->errstr = 'no response'; |
| 1134 | - $resp = new static::$responseClass(0, PhpXmlRpc::$xmlrpcerr['curl_fail'], PhpXmlRpc::$xmlrpcstr['curl_fail'] . ': ' . curl_error($curl)); |
|
| 1134 | + $resp = new static::$responseClass(0, PhpXmlRpc::$xmlrpcerr['curl_fail'], PhpXmlRpc::$xmlrpcstr['curl_fail'].': '.curl_error($curl)); |
|
| 1135 | 1135 | curl_close($curl); |
| 1136 | 1136 | if ($keepAlive) { |
| 1137 | 1137 | $this->xmlrpc_curl_handle = null; |
@@ -1201,12 +1201,12 @@ discard block |
||
| 1201 | 1201 | // http, https |
| 1202 | 1202 | $protocol = $method; |
| 1203 | 1203 | if (strpos($protocol, ':') !== false) { |
| 1204 | - $this->getLogger()->error('XML-RPC: ' . __METHOD__ . ": warning - attempted hacking attempt?. The curl protocol requested for the call is: '$protocol'"); |
|
| 1204 | + $this->getLogger()->error('XML-RPC: '.__METHOD__.": warning - attempted hacking attempt?. The curl protocol requested for the call is: '$protocol'"); |
|
| 1205 | 1205 | return false; |
| 1206 | 1206 | } |
| 1207 | 1207 | } |
| 1208 | 1208 | } |
| 1209 | - $curl = curl_init($protocol . '://' . $server . ':' . $port . $this->path); |
|
| 1209 | + $curl = curl_init($protocol.'://'.$server.':'.$port.$this->path); |
|
| 1210 | 1210 | if (!$curl) { |
| 1211 | 1211 | return false; |
| 1212 | 1212 | } |
@@ -1220,7 +1220,7 @@ discard block |
||
| 1220 | 1220 | // results into variable |
| 1221 | 1221 | curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); |
| 1222 | 1222 | |
| 1223 | - if ($this->debug > 1) { |
|
| 1223 | + if ($this->debug>1) { |
|
| 1224 | 1224 | curl_setopt($curl, CURLOPT_VERBOSE, true); |
| 1225 | 1225 | /// @todo redirect curlopt_stderr to some stream which can be piped to the logger |
| 1226 | 1226 | } |
@@ -1245,7 +1245,7 @@ discard block |
||
| 1245 | 1245 | } |
| 1246 | 1246 | } |
| 1247 | 1247 | // extra headers |
| 1248 | - $headers = array('Content-Type: ' . $req->content_type, 'Accept-Charset: ' . implode(',', $this->accepted_charset_encodings)); |
|
| 1248 | + $headers = array('Content-Type: '.$req->content_type, 'Accept-Charset: '.implode(',', $this->accepted_charset_encodings)); |
|
| 1249 | 1249 | // if no keepalive is wanted, let the server know it in advance |
| 1250 | 1250 | if (!$keepAlive) { |
| 1251 | 1251 | $headers[] = 'Connection: close'; |
@@ -1262,7 +1262,7 @@ discard block |
||
| 1262 | 1262 | curl_setopt($curl, CURLOPT_HTTPHEADER, $headers); |
| 1263 | 1263 | // timeout is borked |
| 1264 | 1264 | if ($timeout) { |
| 1265 | - curl_setopt($curl, CURLOPT_TIMEOUT, $timeout == 1 ? 1 : $timeout - 1); |
|
| 1265 | + curl_setopt($curl, CURLOPT_TIMEOUT, $timeout == 1 ? 1 : $timeout-1); |
|
| 1266 | 1266 | } |
| 1267 | 1267 | |
| 1268 | 1268 | switch ($method) { |
@@ -1277,7 +1277,7 @@ discard block |
||
| 1277 | 1277 | curl_setopt($curl, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_2_PRIOR_KNOWLEDGE); |
| 1278 | 1278 | } else { |
| 1279 | 1279 | /// @todo make this a proper error, i.e. return a failure |
| 1280 | - $this->getLogger()->error('XML-RPC: ' . __METHOD__ . ': warning. HTTP2 is not supported by the current PHP/curl install'); |
|
| 1280 | + $this->getLogger()->error('XML-RPC: '.__METHOD__.': warning. HTTP2 is not supported by the current PHP/curl install'); |
|
| 1281 | 1281 | } |
| 1282 | 1282 | break; |
| 1283 | 1283 | case 'h2': |
@@ -1286,12 +1286,12 @@ discard block |
||
| 1286 | 1286 | } |
| 1287 | 1287 | |
| 1288 | 1288 | if ($username && $password) { |
| 1289 | - curl_setopt($curl, CURLOPT_USERPWD, $username . ':' . $password); |
|
| 1289 | + curl_setopt($curl, CURLOPT_USERPWD, $username.':'.$password); |
|
| 1290 | 1290 | if (defined('CURLOPT_HTTPAUTH')) { |
| 1291 | 1291 | curl_setopt($curl, CURLOPT_HTTPAUTH, $authType); |
| 1292 | 1292 | } elseif ($authType != 1) { |
| 1293 | 1293 | /// @todo make this a proper error, i.e. return a failure |
| 1294 | - $this->getLogger()->error('XML-RPC: ' . __METHOD__ . ': warning. Only Basic auth is supported by the current PHP/curl install'); |
|
| 1294 | + $this->getLogger()->error('XML-RPC: '.__METHOD__.': warning. Only Basic auth is supported by the current PHP/curl install'); |
|
| 1295 | 1295 | } |
| 1296 | 1296 | } |
| 1297 | 1297 | |
@@ -1334,14 +1334,14 @@ discard block |
||
| 1334 | 1334 | if ($proxyPort == 0) { |
| 1335 | 1335 | $proxyPort = 8080; // NB: even for HTTPS, local connection is on port 8080 |
| 1336 | 1336 | } |
| 1337 | - curl_setopt($curl, CURLOPT_PROXY, $proxyHost . ':' . $proxyPort); |
|
| 1337 | + curl_setopt($curl, CURLOPT_PROXY, $proxyHost.':'.$proxyPort); |
|
| 1338 | 1338 | if ($proxyUsername) { |
| 1339 | - curl_setopt($curl, CURLOPT_PROXYUSERPWD, $proxyUsername . ':' . $proxyPassword); |
|
| 1339 | + curl_setopt($curl, CURLOPT_PROXYUSERPWD, $proxyUsername.':'.$proxyPassword); |
|
| 1340 | 1340 | if (defined('CURLOPT_PROXYAUTH')) { |
| 1341 | 1341 | curl_setopt($curl, CURLOPT_PROXYAUTH, $proxyAuthType); |
| 1342 | 1342 | } elseif ($proxyAuthType != 1) { |
| 1343 | 1343 | /// @todo make this a proper error, i.e. return a failure |
| 1344 | - $this->getLogger()->error('XML-RPC: ' . __METHOD__ . ': warning. Only Basic auth to proxy is supported by the current PHP/curl install'); |
|
| 1344 | + $this->getLogger()->error('XML-RPC: '.__METHOD__.': warning. Only Basic auth to proxy is supported by the current PHP/curl install'); |
|
| 1345 | 1345 | } |
| 1346 | 1346 | } |
| 1347 | 1347 | } |
@@ -1351,7 +1351,7 @@ discard block |
||
| 1351 | 1351 | if (count($this->cookies)) { |
| 1352 | 1352 | $cookieHeader = ''; |
| 1353 | 1353 | foreach ($this->cookies as $name => $cookie) { |
| 1354 | - $cookieHeader .= $name . '=' . $cookie['value'] . '; '; |
|
| 1354 | + $cookieHeader .= $name.'='.$cookie['value'].'; '; |
|
| 1355 | 1355 | } |
| 1356 | 1356 | curl_setopt($curl, CURLOPT_COOKIE, substr($cookieHeader, 0, -2)); |
| 1357 | 1357 | } |
@@ -1360,7 +1360,7 @@ discard block |
||
| 1360 | 1360 | curl_setopt($curl, $opt, $val); |
| 1361 | 1361 | } |
| 1362 | 1362 | |
| 1363 | - if ($this->debug > 1) { |
|
| 1363 | + if ($this->debug>1) { |
|
| 1364 | 1364 | $this->getLogger()->debug("---SENDING---\n$payload\n---END---"); |
| 1365 | 1365 | } |
| 1366 | 1366 | |
@@ -1451,7 +1451,7 @@ discard block |
||
| 1451 | 1451 | $call['methodName'] = new Value($req->method(), 'string'); |
| 1452 | 1452 | $numParams = $req->getNumParams(); |
| 1453 | 1453 | $params = array(); |
| 1454 | - for ($i = 0; $i < $numParams; $i++) { |
|
| 1454 | + for ($i = 0; $i<$numParams; $i++) { |
|
| 1455 | 1455 | $params[$i] = $req->getParam($i); |
| 1456 | 1456 | } |
| 1457 | 1457 | $call['params'] = new Value($params, 'array'); |
@@ -1473,7 +1473,7 @@ discard block |
||
| 1473 | 1473 | $response = array(); |
| 1474 | 1474 | |
| 1475 | 1475 | if ($this->return_type == 'xml') { |
| 1476 | - for ($i = 0; $i < count($reqs); $i++) { |
|
| 1476 | + for ($i = 0; $i<count($reqs); $i++) { |
|
| 1477 | 1477 | $response[] = new Response($rets, 0, '', 'xml', $result->httpResponse()); |
| 1478 | 1478 | } |
| 1479 | 1479 | |
@@ -1481,21 +1481,21 @@ discard block |
||
| 1481 | 1481 | if (!is_array($rets)) { |
| 1482 | 1482 | // bad return type from system.multicall |
| 1483 | 1483 | return new Response(0, PhpXmlRpc::$xmlrpcerr['multicall_error'], |
| 1484 | - PhpXmlRpc::$xmlrpcstr['multicall_error'] . ': not an array', 'phpvals', $result->httpResponse()); |
|
| 1484 | + PhpXmlRpc::$xmlrpcstr['multicall_error'].': not an array', 'phpvals', $result->httpResponse()); |
|
| 1485 | 1485 | } |
| 1486 | 1486 | $numRets = count($rets); |
| 1487 | 1487 | if ($numRets != count($reqs)) { |
| 1488 | 1488 | // wrong number of return values. |
| 1489 | 1489 | return new Response(0, PhpXmlRpc::$xmlrpcerr['multicall_error'], |
| 1490 | - PhpXmlRpc::$xmlrpcstr['multicall_error'] . ': incorrect number of responses', 'phpvals', |
|
| 1490 | + PhpXmlRpc::$xmlrpcstr['multicall_error'].': incorrect number of responses', 'phpvals', |
|
| 1491 | 1491 | $result->httpResponse()); |
| 1492 | 1492 | } |
| 1493 | 1493 | |
| 1494 | - for ($i = 0; $i < $numRets; $i++) { |
|
| 1494 | + for ($i = 0; $i<$numRets; $i++) { |
|
| 1495 | 1495 | $val = $rets[$i]; |
| 1496 | 1496 | if (!is_array($val)) { |
| 1497 | 1497 | return new Response(0, PhpXmlRpc::$xmlrpcerr['multicall_error'], |
| 1498 | - PhpXmlRpc::$xmlrpcstr['multicall_error'] . ": response element $i is not an array or struct", |
|
| 1498 | + PhpXmlRpc::$xmlrpcstr['multicall_error'].": response element $i is not an array or struct", |
|
| 1499 | 1499 | 'phpvals', $result->httpResponse()); |
| 1500 | 1500 | } |
| 1501 | 1501 | switch (count($val)) { |
@@ -1503,7 +1503,7 @@ discard block |
||
| 1503 | 1503 | if (!isset($val[0])) { |
| 1504 | 1504 | // Bad value |
| 1505 | 1505 | return new Response(0, PhpXmlRpc::$xmlrpcerr['multicall_error'], |
| 1506 | - PhpXmlRpc::$xmlrpcstr['multicall_error'] . ": response element $i has no value", |
|
| 1506 | + PhpXmlRpc::$xmlrpcstr['multicall_error'].": response element $i has no value", |
|
| 1507 | 1507 | 'phpvals', $result->httpResponse()); |
| 1508 | 1508 | } |
| 1509 | 1509 | // Normal return value |
@@ -1515,20 +1515,20 @@ discard block |
||
| 1515 | 1515 | if (!is_int($code)) { |
| 1516 | 1516 | /// @todo should we check that it is != 0? |
| 1517 | 1517 | return new Response(0, PhpXmlRpc::$xmlrpcerr['multicall_error'], |
| 1518 | - PhpXmlRpc::$xmlrpcstr['multicall_error'] . ": response element $i has invalid or no faultCode", |
|
| 1518 | + PhpXmlRpc::$xmlrpcstr['multicall_error'].": response element $i has invalid or no faultCode", |
|
| 1519 | 1519 | 'phpvals', $result->httpResponse()); |
| 1520 | 1520 | } |
| 1521 | 1521 | $str = @$val['faultString']; |
| 1522 | 1522 | if (!is_string($str)) { |
| 1523 | 1523 | return new Response(0, PhpXmlRpc::$xmlrpcerr['multicall_error'], |
| 1524 | - PhpXmlRpc::$xmlrpcstr['multicall_error'] . ": response element $i has invalid or no FaultString", |
|
| 1524 | + PhpXmlRpc::$xmlrpcstr['multicall_error'].": response element $i has invalid or no FaultString", |
|
| 1525 | 1525 | 'phpvals', $result->httpResponse()); |
| 1526 | 1526 | } |
| 1527 | 1527 | $response[$i] = new Response(0, $code, $str, 'phpvals', $result->httpResponse()); |
| 1528 | 1528 | break; |
| 1529 | 1529 | default: |
| 1530 | 1530 | return new Response(0, PhpXmlRpc::$xmlrpcerr['multicall_error'], |
| 1531 | - PhpXmlRpc::$xmlrpcstr['multicall_error'] . ": response element $i has too many items", |
|
| 1531 | + PhpXmlRpc::$xmlrpcstr['multicall_error'].": response element $i has too many items", |
|
| 1532 | 1532 | 'phpvals', $result->httpResponse()); |
| 1533 | 1533 | } |
| 1534 | 1534 | } |
@@ -1537,14 +1537,14 @@ discard block |
||
| 1537 | 1537 | // return type == 'xmlrpcvals' |
| 1538 | 1538 | if ($rets->kindOf() != 'array') { |
| 1539 | 1539 | return new Response(0, PhpXmlRpc::$xmlrpcerr['multicall_error'], |
| 1540 | - PhpXmlRpc::$xmlrpcstr['multicall_error'] . ": response element $i is not an array", 'xmlrpcvals', |
|
| 1540 | + PhpXmlRpc::$xmlrpcstr['multicall_error'].": response element $i is not an array", 'xmlrpcvals', |
|
| 1541 | 1541 | $result->httpResponse()); |
| 1542 | 1542 | } |
| 1543 | 1543 | $numRets = $rets->count(); |
| 1544 | 1544 | if ($numRets != count($reqs)) { |
| 1545 | 1545 | // wrong number of return values. |
| 1546 | 1546 | return new Response(0, PhpXmlRpc::$xmlrpcerr['multicall_error'], |
| 1547 | - PhpXmlRpc::$xmlrpcstr['multicall_error'] . ': incorrect number of responses', 'xmlrpcvals', |
|
| 1547 | + PhpXmlRpc::$xmlrpcstr['multicall_error'].': incorrect number of responses', 'xmlrpcvals', |
|
| 1548 | 1548 | $result->httpResponse()); |
| 1549 | 1549 | } |
| 1550 | 1550 | |
@@ -1553,7 +1553,7 @@ discard block |
||
| 1553 | 1553 | case 'array': |
| 1554 | 1554 | if ($val->count() != 1) { |
| 1555 | 1555 | return new Response(0, PhpXmlRpc::$xmlrpcerr['multicall_error'], |
| 1556 | - PhpXmlRpc::$xmlrpcstr['multicall_error'] . ": response element $i has too many items", |
|
| 1556 | + PhpXmlRpc::$xmlrpcstr['multicall_error'].": response element $i has too many items", |
|
| 1557 | 1557 | 'phpvals', $result->httpResponse()); |
| 1558 | 1558 | } |
| 1559 | 1559 | // Normal return value |
@@ -1562,28 +1562,28 @@ discard block |
||
| 1562 | 1562 | case 'struct': |
| 1563 | 1563 | if ($val->count() != 2) { |
| 1564 | 1564 | return new Response(0, PhpXmlRpc::$xmlrpcerr['multicall_error'], |
| 1565 | - PhpXmlRpc::$xmlrpcstr['multicall_error'] . ": response element $i has too many items", |
|
| 1565 | + PhpXmlRpc::$xmlrpcstr['multicall_error'].": response element $i has too many items", |
|
| 1566 | 1566 | 'phpvals', $result->httpResponse()); |
| 1567 | 1567 | } |
| 1568 | 1568 | /** @var Value $code */ |
| 1569 | 1569 | $code = $val['faultCode']; |
| 1570 | 1570 | if ($code->kindOf() != 'scalar' || $code->scalartyp() != 'int') { |
| 1571 | 1571 | return new Response(0, PhpXmlRpc::$xmlrpcerr['multicall_error'], |
| 1572 | - PhpXmlRpc::$xmlrpcstr['multicall_error'] . ": response element $i has invalid or no faultCode", |
|
| 1572 | + PhpXmlRpc::$xmlrpcstr['multicall_error'].": response element $i has invalid or no faultCode", |
|
| 1573 | 1573 | 'xmlrpcvals', $result->httpResponse()); |
| 1574 | 1574 | } |
| 1575 | 1575 | /** @var Value $str */ |
| 1576 | 1576 | $str = $val['faultString']; |
| 1577 | 1577 | if ($str->kindOf() != 'scalar' || $str->scalartyp() != 'string') { |
| 1578 | 1578 | return new Response(0, PhpXmlRpc::$xmlrpcerr['multicall_error'], |
| 1579 | - PhpXmlRpc::$xmlrpcstr['multicall_error'] . ": response element $i has invalid or no faultCode", |
|
| 1579 | + PhpXmlRpc::$xmlrpcstr['multicall_error'].": response element $i has invalid or no faultCode", |
|
| 1580 | 1580 | 'xmlrpcvals', $result->httpResponse()); |
| 1581 | 1581 | } |
| 1582 | 1582 | $response[] = new Response(0, $code->scalarval(), $str->scalarval(), 'xmlrpcvals', $result->httpResponse()); |
| 1583 | 1583 | break; |
| 1584 | 1584 | default: |
| 1585 | 1585 | return new Response(0, PhpXmlRpc::$xmlrpcerr['multicall_error'], |
| 1586 | - PhpXmlRpc::$xmlrpcstr['multicall_error'] . ": response element $i is not an array or struct", |
|
| 1586 | + PhpXmlRpc::$xmlrpcstr['multicall_error'].": response element $i is not an array or struct", |
|
| 1587 | 1587 | 'xmlrpcvals', $result->httpResponse()); |
| 1588 | 1588 | } |
| 1589 | 1589 | } |
@@ -1,6 +1,6 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -include_once __DIR__ . '/PolyfillTestCase.php'; |
|
| 3 | +include_once __DIR__.'/PolyfillTestCase.php'; |
|
| 4 | 4 | |
| 5 | 5 | use PhpXmlRpc\Helper\Charset; |
| 6 | 6 | use PhpXmlRpc\Helper\Http; |
@@ -38,9 +38,9 @@ discard block |
||
| 38 | 38 | $l = $h->getLogger(); |
| 39 | 39 | Http::setLogger($this); |
| 40 | 40 | |
| 41 | - $s = "HTTP/1.0 200 OK\r\n" . |
|
| 42 | - "Content-Type: unknown\r\n" . |
|
| 43 | - "\r\n" . |
|
| 41 | + $s = "HTTP/1.0 200 OK\r\n". |
|
| 42 | + "Content-Type: unknown\r\n". |
|
| 43 | + "\r\n". |
|
| 44 | 44 | "body"; |
| 45 | 45 | ob_start(); |
| 46 | 46 | $h->parseResponseHeaders($s, false, 1); |
@@ -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 | } |