@@ -95,7 +95,7 @@ discard block |
||
95 | 95 | $val = reset($ar); |
96 | 96 | $typ = key($ar); |
97 | 97 | |
98 | - return '<value>' . $this->serializedata($typ, $val) . "</value>\n"; |
|
98 | + return '<value>'.$this->serializedata($typ, $val)."</value>\n"; |
|
99 | 99 | //} |
100 | 100 | } |
101 | 101 | |
@@ -114,7 +114,7 @@ discard block |
||
114 | 114 | // preserve back compatibility |
115 | 115 | |
116 | 116 | if (is_array($b)) { |
117 | - foreach($b as $id => $cont) { |
|
117 | + foreach ($b as $id => $cont) { |
|
118 | 118 | $b[$id] = $cont->scalarval(); |
119 | 119 | } |
120 | 120 | } |
@@ -122,10 +122,10 @@ discard block |
||
122 | 122 | // add support for structures directly encoding php objects |
123 | 123 | if (is_object($b)) { |
124 | 124 | $t = get_object_vars($b); |
125 | - foreach($t as $id => $cont) { |
|
125 | + foreach ($t as $id => $cont) { |
|
126 | 126 | $t[$id] = $cont->scalarval(); |
127 | 127 | } |
128 | - foreach($t as $id => $cont) { |
|
128 | + foreach ($t as $id => $cont) { |
|
129 | 129 | @$b->$id = $cont; |
130 | 130 | } |
131 | 131 | } |
@@ -160,17 +160,17 @@ discard block |
||
160 | 160 | /* Expose as global functions the ones which are now class methods */ |
161 | 161 | |
162 | 162 | /// Wrong speling, but we are adamant on backwards compatibility! |
163 | -function xmlrpc_encode_entitites($data, $srcEncoding='', $destEncoding='') |
|
163 | +function xmlrpc_encode_entitites($data, $srcEncoding = '', $destEncoding = '') |
|
164 | 164 | { |
165 | 165 | return PhpXmlRpc\Helper\Charset::instance()->encodeEntitites($data, $srcEncoding, $destEncoding); |
166 | 166 | } |
167 | 167 | |
168 | -function iso8601_encode($timeT, $utc=0) |
|
168 | +function iso8601_encode($timeT, $utc = 0) |
|
169 | 169 | { |
170 | 170 | return PhpXmlRpc\Helper\Date::iso8601Encode($timeT, $utc); |
171 | 171 | } |
172 | 172 | |
173 | -function iso8601_decode($iDate, $utc=0) |
|
173 | +function iso8601_decode($iDate, $utc = 0) |
|
174 | 174 | { |
175 | 175 | return PhpXmlRpc\Helper\Date::iso8601Decode($iDate, $utc); |
176 | 176 | } |
@@ -180,25 +180,25 @@ discard block |
||
180 | 180 | return PhpXmlRpc\Helper\Http::decodeChunked($buffer); |
181 | 181 | } |
182 | 182 | |
183 | -function php_xmlrpc_decode($xmlrpcVal, $options=array()) |
|
183 | +function php_xmlrpc_decode($xmlrpcVal, $options = array()) |
|
184 | 184 | { |
185 | 185 | $encoder = new PhpXmlRpc\Encoder(); |
186 | 186 | return $encoder->decode($xmlrpcVal, $options); |
187 | 187 | } |
188 | 188 | |
189 | -function php_xmlrpc_encode($phpVal, $options=array()) |
|
189 | +function php_xmlrpc_encode($phpVal, $options = array()) |
|
190 | 190 | { |
191 | 191 | $encoder = new PhpXmlRpc\Encoder(); |
192 | 192 | return $encoder->encode($phpVal, $options); |
193 | 193 | } |
194 | 194 | |
195 | -function php_xmlrpc_decode_xml($xmlVal, $options=array()) |
|
195 | +function php_xmlrpc_decode_xml($xmlVal, $options = array()) |
|
196 | 196 | { |
197 | 197 | $encoder = new PhpXmlRpc\Encoder(); |
198 | 198 | return $encoder->decodeXml($xmlVal, $options); |
199 | 199 | } |
200 | 200 | |
201 | -function guess_encoding($httpHeader='', $xmlChunk='', $encodingPrefs=null) |
|
201 | +function guess_encoding($httpHeader = '', $xmlChunk = '', $encodingPrefs = null) |
|
202 | 202 | { |
203 | 203 | return PhpXmlRpc\Helper\XMLParser::guessEncoding($httpHeader, $xmlChunk, $encodingPrefs); |
204 | 204 | } |
@@ -1,11 +1,11 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -include_once __DIR__ . '/../lib/xmlrpc.inc'; |
|
4 | -include_once __DIR__ . '/../lib/xmlrpc_wrappers.inc'; |
|
3 | +include_once __DIR__.'/../lib/xmlrpc.inc'; |
|
4 | +include_once __DIR__.'/../lib/xmlrpc_wrappers.inc'; |
|
5 | 5 | |
6 | -include_once __DIR__ . '/parse_args.php'; |
|
6 | +include_once __DIR__.'/parse_args.php'; |
|
7 | 7 | |
8 | -include_once __DIR__ . '/3LocalhostTest.php'; |
|
8 | +include_once __DIR__.'/3LocalhostTest.php'; |
|
9 | 9 | |
10 | 10 | /** |
11 | 11 | * Tests which stress http features of the library. |
@@ -27,9 +27,9 @@ discard block |
||
27 | 27 | ); |
28 | 28 | |
29 | 29 | $methods = array(); |
30 | - foreach(get_class_methods('LocalhostTest') as $method) |
|
30 | + foreach (get_class_methods('LocalhostTest') as $method) |
|
31 | 31 | { |
32 | - if(strpos($method, 'test') === 0 && !in_array($method, $unsafeMethods)) |
|
32 | + if (strpos($method, 'test') === 0 && !in_array($method, $unsafeMethods)) |
|
33 | 33 | { |
34 | 34 | if (!isset(self::$failed_tests[$method])) { |
35 | 35 | $methods[$method] = array($method); |
@@ -46,7 +46,7 @@ discard block |
||
46 | 46 | */ |
47 | 47 | public function testDeflate($method) |
48 | 48 | { |
49 | - if(!function_exists('gzdeflate')) |
|
49 | + if (!function_exists('gzdeflate')) |
|
50 | 50 | { |
51 | 51 | $this->markTestSkipped('Zlib missing: cannot test deflate functionality'); |
52 | 52 | return; |
@@ -64,7 +64,7 @@ discard block |
||
64 | 64 | */ |
65 | 65 | public function testGzip($method) |
66 | 66 | { |
67 | - if(!function_exists('gzdeflate')) |
|
67 | + if (!function_exists('gzdeflate')) |
|
68 | 68 | { |
69 | 69 | $this->markTestSkipped('Zlib missing: cannot test gzip functionality'); |
70 | 70 | return; |
@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | |
79 | 79 | public function testKeepAlives() |
80 | 80 | { |
81 | - if(!function_exists('curl_init')) |
|
81 | + if (!function_exists('curl_init')) |
|
82 | 82 | { |
83 | 83 | $this->markTestSkipped('CURL missing: cannot test http 1.1'); |
84 | 84 | return; |
@@ -118,7 +118,7 @@ discard block |
||
118 | 118 | */ |
119 | 119 | public function testHttp11($method) |
120 | 120 | { |
121 | - if(!function_exists('curl_init')) |
|
121 | + if (!function_exists('curl_init')) |
|
122 | 122 | { |
123 | 123 | $this->markTestSkipped('CURL missing: cannot test http 1.1'); |
124 | 124 | return; |
@@ -137,7 +137,7 @@ discard block |
||
137 | 137 | */ |
138 | 138 | public function testHttp10Curl($method) |
139 | 139 | { |
140 | - if(!function_exists('curl_init')) |
|
140 | + if (!function_exists('curl_init')) |
|
141 | 141 | { |
142 | 142 | $this->markTestSkipped('CURL missing: cannot test http 1.1'); |
143 | 143 | return; |
@@ -157,7 +157,7 @@ discard block |
||
157 | 157 | */ |
158 | 158 | public function testHttp11Gzip($method) |
159 | 159 | { |
160 | - if(!function_exists('curl_init')) |
|
160 | + if (!function_exists('curl_init')) |
|
161 | 161 | { |
162 | 162 | $this->markTestSkipped('CURL missing: cannot test http 1.1'); |
163 | 163 | return; |
@@ -177,7 +177,7 @@ discard block |
||
177 | 177 | */ |
178 | 178 | public function testHttp11Deflate($method) |
179 | 179 | { |
180 | - if(!function_exists('curl_init')) |
|
180 | + if (!function_exists('curl_init')) |
|
181 | 181 | { |
182 | 182 | $this->markTestSkipped('CURL missing: cannot test http 1.1'); |
183 | 183 | return; |
@@ -197,7 +197,7 @@ discard block |
||
197 | 197 | */ |
198 | 198 | public function testHttp11Proxy($method) |
199 | 199 | { |
200 | - if(!function_exists('curl_init')) |
|
200 | + if (!function_exists('curl_init')) |
|
201 | 201 | { |
202 | 202 | $this->markTestSkipped('CURL missing: cannot test http 1.1 w. proxy'); |
203 | 203 | return; |
@@ -222,7 +222,7 @@ discard block |
||
222 | 222 | */ |
223 | 223 | public function testHttps($method) |
224 | 224 | { |
225 | - if(!function_exists('curl_init')) |
|
225 | + if (!function_exists('curl_init')) |
|
226 | 226 | { |
227 | 227 | $this->markTestSkipped('CURL missing: cannot test https functionality'); |
228 | 228 | return; |
@@ -274,7 +274,7 @@ discard block |
||
274 | 274 | */ |
275 | 275 | public function testHttpsProxy($method) |
276 | 276 | { |
277 | - if(!function_exists('curl_init')) |
|
277 | + if (!function_exists('curl_init')) |
|
278 | 278 | { |
279 | 279 | $this->markTestSkipped('CURL missing: cannot test https w. proxy'); |
280 | 280 | return; |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | */ |
53 | 53 | public function echoInput() |
54 | 54 | { |
55 | - $r = new PhpXmlRpc\Response(new PhpXmlRpc\Value("'Aha said I: '" . file_get_contents('php://input'), 'string')); |
|
55 | + $r = new PhpXmlRpc\Response(new PhpXmlRpc\Value("'Aha said I: '".file_get_contents('php://input'), 'string')); |
|
56 | 56 | print $r->serialize(); |
57 | 57 | } |
58 | 58 | } |
@@ -68,30 +68,30 @@ discard block |
||
68 | 68 | PhpXmlRpc\Server::xmlrpc_debugmsg($m); |
69 | 69 | } |
70 | 70 | |
71 | -function _xmlrpcs_getCapabilities($server, $m=null) |
|
71 | +function _xmlrpcs_getCapabilities($server, $m = null) |
|
72 | 72 | { |
73 | 73 | return PhpXmlRpc\Server::_xmlrpcs_getCapabilities($server, $m); |
74 | 74 | } |
75 | 75 | |
76 | -$_xmlrpcs_listMethods_sig=array(array(\PhpXmlRpc\Value::$xmlrpcArray)); |
|
77 | -$_xmlrpcs_listMethods_doc='This method lists all the methods that the XML-RPC server knows how to dispatch'; |
|
78 | -$_xmlrpcs_listMethods_sdoc=array(array('list of method names')); |
|
79 | -function _xmlrpcs_listMethods($server, $m=null) // if called in plain php values mode, second param is missing |
|
76 | +$_xmlrpcs_listMethods_sig = array(array(\PhpXmlRpc\Value::$xmlrpcArray)); |
|
77 | +$_xmlrpcs_listMethods_doc = 'This method lists all the methods that the XML-RPC server knows how to dispatch'; |
|
78 | +$_xmlrpcs_listMethods_sdoc = array(array('list of method names')); |
|
79 | +function _xmlrpcs_listMethods($server, $m = null) // if called in plain php values mode, second param is missing |
|
80 | 80 | { |
81 | 81 | return PhpXmlRpc\Server::_xmlrpcs_listMethods($server, $m); |
82 | 82 | } |
83 | 83 | |
84 | -$_xmlrpcs_methodSignature_sig=array(array(\PhpXmlRpc\Value::$xmlrpcArray, $GLOBALS['xmlrpcString'])); |
|
85 | -$_xmlrpcs_methodSignature_doc='Returns an array of known signatures (an array of arrays) for the method name passed. If no signatures are known, returns a none-array (test for type != array to detect missing signature)'; |
|
86 | -$_xmlrpcs_methodSignature_sdoc=array(array('list of known signatures, each sig being an array of xmlrpc type names', 'name of method to be described')); |
|
84 | +$_xmlrpcs_methodSignature_sig = array(array(\PhpXmlRpc\Value::$xmlrpcArray, $GLOBALS['xmlrpcString'])); |
|
85 | +$_xmlrpcs_methodSignature_doc = 'Returns an array of known signatures (an array of arrays) for the method name passed. If no signatures are known, returns a none-array (test for type != array to detect missing signature)'; |
|
86 | +$_xmlrpcs_methodSignature_sdoc = array(array('list of known signatures, each sig being an array of xmlrpc type names', 'name of method to be described')); |
|
87 | 87 | function _xmlrpcs_methodSignature($server, $m) |
88 | 88 | { |
89 | 89 | return PhpXmlRpc\Server::_xmlrpcs_methodSignature($server, $m); |
90 | 90 | } |
91 | 91 | |
92 | -$_xmlrpcs_methodHelp_sig=array(array($GLOBALS['xmlrpcString'], $GLOBALS['xmlrpcString'])); |
|
93 | -$_xmlrpcs_methodHelp_doc='Returns help text if defined for the method passed, otherwise returns an empty string'; |
|
94 | -$_xmlrpcs_methodHelp_sdoc=array(array('method description', 'name of the method to be described')); |
|
92 | +$_xmlrpcs_methodHelp_sig = array(array($GLOBALS['xmlrpcString'], $GLOBALS['xmlrpcString'])); |
|
93 | +$_xmlrpcs_methodHelp_doc = 'Returns help text if defined for the method passed, otherwise returns an empty string'; |
|
94 | +$_xmlrpcs_methodHelp_sdoc = array(array('method description', 'name of the method to be described')); |
|
95 | 95 | function _xmlrpcs_methodHelp($server, $m) |
96 | 96 | { |
97 | 97 | return PhpXmlRpc\Server::_xmlrpcs_methodHelp($server, $m); |
@@ -39,10 +39,10 @@ |
||
39 | 39 | $flags = ENT_COMPAT; |
40 | 40 | // avoid warnings on php < 5.4... |
41 | 41 | if (defined('ENT_HTML401')) { |
42 | - $flags = $flags | ENT_HTML401; |
|
42 | + $flags = $flags | ENT_HTML401; |
|
43 | 43 | } |
44 | 44 | if (defined('ENT_SUBSTITUTE')) { |
45 | - $flags = $flags | ENT_SUBSTITUTE; |
|
45 | + $flags = $flags | ENT_SUBSTITUTE; |
|
46 | 46 | } |
47 | 47 | if ($encoding != null) { |
48 | 48 | print "<PRE>\n".htmlentities($message, $flags, $encoding)."\n</PRE>"; |
@@ -117,35 +117,35 @@ |
||
117 | 117 | public function serialize($charsetEncoding = '') |
118 | 118 | { |
119 | 119 | if ($charsetEncoding != '') { |
120 | - $this->content_type = 'text/xml; charset=' . $charsetEncoding; |
|
120 | + $this->content_type = 'text/xml; charset='.$charsetEncoding; |
|
121 | 121 | } else { |
122 | 122 | $this->content_type = 'text/xml'; |
123 | 123 | } |
124 | 124 | if (PhpXmlRpc::$xmlrpc_null_apache_encoding) { |
125 | - $result = "<methodResponse xmlns:ex=\"" . PhpXmlRpc::$xmlrpc_null_apache_encoding_ns . "\">\n"; |
|
125 | + $result = "<methodResponse xmlns:ex=\"".PhpXmlRpc::$xmlrpc_null_apache_encoding_ns."\">\n"; |
|
126 | 126 | } else { |
127 | 127 | $result = "<methodResponse>\n"; |
128 | 128 | } |
129 | 129 | if ($this->errno) { |
130 | 130 | // Let non-ASCII response messages be tolerated by clients by xml-encoding non ascii chars |
131 | - $result .= "<fault>\n" . |
|
132 | - "<value>\n<struct><member><name>faultCode</name>\n<value><int>" . $this->errno . |
|
133 | - "</int></value>\n</member>\n<member>\n<name>faultString</name>\n<value><string>" . |
|
134 | - Charset::instance()->encodeEntities($this->errstr, PhpXmlRpc::$xmlrpc_internalencoding, $charsetEncoding) . "</string></value>\n</member>\n" . |
|
131 | + $result .= "<fault>\n". |
|
132 | + "<value>\n<struct><member><name>faultCode</name>\n<value><int>".$this->errno. |
|
133 | + "</int></value>\n</member>\n<member>\n<name>faultString</name>\n<value><string>". |
|
134 | + Charset::instance()->encodeEntities($this->errstr, PhpXmlRpc::$xmlrpc_internalencoding, $charsetEncoding)."</string></value>\n</member>\n". |
|
135 | 135 | "</struct>\n</value>\n</fault>"; |
136 | 136 | } else { |
137 | 137 | if (!is_object($this->val) || !is_a($this->val, 'PhpXmlRpc\Value')) { |
138 | 138 | if (is_string($this->val) && $this->valtyp == 'xml') { |
139 | - $result .= "<params>\n<param>\n" . |
|
140 | - $this->val . |
|
139 | + $result .= "<params>\n<param>\n". |
|
140 | + $this->val. |
|
141 | 141 | "</param>\n</params>"; |
142 | 142 | } else { |
143 | 143 | /// @todo try to build something serializable? |
144 | 144 | throw new \Exception('cannot serialize xmlrpc response objects whose content is native php values'); |
145 | 145 | } |
146 | 146 | } else { |
147 | - $result .= "<params>\n<param>\n" . |
|
148 | - $this->val->serialize($charsetEncoding) . |
|
147 | + $result .= "<params>\n<param>\n". |
|
148 | + $this->val->serialize($charsetEncoding). |
|
149 | 149 | "</param>\n</params>"; |
150 | 150 | } |
151 | 151 | } |
@@ -51,12 +51,12 @@ discard block |
||
51 | 51 | |
52 | 52 | private function __construct() |
53 | 53 | { |
54 | - for ($i = 0; $i < 32; $i++) { |
|
54 | + for ($i = 0; $i<32; $i++) { |
|
55 | 55 | $this->xml_iso88591_Entities["in"][] = chr($i); |
56 | 56 | $this->xml_iso88591_Entities["out"][] = "&#{$i};"; |
57 | 57 | } |
58 | 58 | |
59 | - for ($i = 160; $i < 256; $i++) { |
|
59 | + for ($i = 160; $i<256; $i++) { |
|
60 | 60 | $this->xml_iso88591_Entities["in"][] = chr($i); |
61 | 61 | $this->xml_iso88591_Entities["out"][] = "&#{$i};"; |
62 | 62 | } |
@@ -93,7 +93,7 @@ discard block |
||
93 | 93 | $srcEncoding = PhpXmlRpc::$xmlrpc_internalencoding; |
94 | 94 | } |
95 | 95 | |
96 | - $conversion = strtoupper($srcEncoding . '_' . $destEncoding); |
|
96 | + $conversion = strtoupper($srcEncoding.'_'.$destEncoding); |
|
97 | 97 | switch ($conversion) { |
98 | 98 | case 'ISO-8859-1_': |
99 | 99 | case 'ISO-8859-1_US-ASCII': |
@@ -122,13 +122,13 @@ discard block |
||
122 | 122 | // NB: this will choke on invalid UTF-8, going most likely beyond EOF |
123 | 123 | $escapedData = ''; |
124 | 124 | // be kind to users creating string xmlrpc values out of different php types |
125 | - $data = (string)$data; |
|
125 | + $data = (string) $data; |
|
126 | 126 | $ns = strlen($data); |
127 | - for ($nn = 0; $nn < $ns; $nn++) { |
|
127 | + for ($nn = 0; $nn<$ns; $nn++) { |
|
128 | 128 | $ch = $data[$nn]; |
129 | 129 | $ii = ord($ch); |
130 | 130 | // 7 bits: 0bbbbbbb (127) |
131 | - if ($ii < 128) { |
|
131 | + if ($ii<128) { |
|
132 | 132 | /// @todo shall we replace this with a (supposedly) faster str_replace? |
133 | 133 | switch ($ii) { |
134 | 134 | case 34: |
@@ -152,33 +152,33 @@ discard block |
||
152 | 152 | } // 11 bits: 110bbbbb 10bbbbbb (2047) |
153 | 153 | elseif ($ii >> 5 == 6) { |
154 | 154 | $b1 = ($ii & 31); |
155 | - $ii = ord($data[$nn + 1]); |
|
155 | + $ii = ord($data[$nn+1]); |
|
156 | 156 | $b2 = ($ii & 63); |
157 | - $ii = ($b1 * 64) + $b2; |
|
157 | + $ii = ($b1 * 64)+$b2; |
|
158 | 158 | $ent = sprintf('&#%d;', $ii); |
159 | 159 | $escapedData .= $ent; |
160 | 160 | $nn += 1; |
161 | 161 | } // 16 bits: 1110bbbb 10bbbbbb 10bbbbbb |
162 | 162 | elseif ($ii >> 4 == 14) { |
163 | 163 | $b1 = ($ii & 15); |
164 | - $ii = ord($data[$nn + 1]); |
|
164 | + $ii = ord($data[$nn+1]); |
|
165 | 165 | $b2 = ($ii & 63); |
166 | - $ii = ord($data[$nn + 2]); |
|
166 | + $ii = ord($data[$nn+2]); |
|
167 | 167 | $b3 = ($ii & 63); |
168 | - $ii = ((($b1 * 64) + $b2) * 64) + $b3; |
|
168 | + $ii = ((($b1 * 64)+$b2) * 64)+$b3; |
|
169 | 169 | $ent = sprintf('&#%d;', $ii); |
170 | 170 | $escapedData .= $ent; |
171 | 171 | $nn += 2; |
172 | 172 | } // 21 bits: 11110bbb 10bbbbbb 10bbbbbb 10bbbbbb |
173 | 173 | elseif ($ii >> 3 == 30) { |
174 | 174 | $b1 = ($ii & 7); |
175 | - $ii = ord($data[$nn + 1]); |
|
175 | + $ii = ord($data[$nn+1]); |
|
176 | 176 | $b2 = ($ii & 63); |
177 | - $ii = ord($data[$nn + 2]); |
|
177 | + $ii = ord($data[$nn+2]); |
|
178 | 178 | $b3 = ($ii & 63); |
179 | - $ii = ord($data[$nn + 3]); |
|
179 | + $ii = ord($data[$nn+3]); |
|
180 | 180 | $b4 = ($ii & 63); |
181 | - $ii = ((((($b1 * 64) + $b2) * 64) + $b3) * 64) + $b4; |
|
181 | + $ii = ((((($b1 * 64)+$b2) * 64)+$b3) * 64)+$b4; |
|
182 | 182 | $ent = sprintf('&#%d;', $ii); |
183 | 183 | $escapedData .= $ent; |
184 | 184 | $nn += 3; |
@@ -213,7 +213,7 @@ discard block |
||
213 | 213 | |
214 | 214 | default: |
215 | 215 | $escapedData = ''; |
216 | - Logger::instance()->errorLog('XML-RPC: ' . __METHOD__ . ": Converting from $srcEncoding to $destEncoding: not supported..."); |
|
216 | + Logger::instance()->errorLog('XML-RPC: '.__METHOD__.": Converting from $srcEncoding to $destEncoding: not supported..."); |
|
217 | 217 | } |
218 | 218 | |
219 | 219 | return $escapedData; |
@@ -267,7 +267,7 @@ discard block |
||
267 | 267 | case 'iso88591': |
268 | 268 | return $this->xml_iso88591_Entities; |
269 | 269 | default: |
270 | - throw new \Exception('Unsupported charset: ' . $charset); |
|
270 | + throw new \Exception('Unsupported charset: '.$charset); |
|
271 | 271 | } |
272 | 272 | } |
273 | 273 |
@@ -133,10 +133,10 @@ discard block |
||
133 | 133 | $this->accept = $accept; |
134 | 134 | |
135 | 135 | // @see ticket #70 - we have to parse big xml docks in chunks to avoid errors |
136 | - for ($offset = 0; $offset < $len; $offset += $this->maxChunkLength) { |
|
136 | + for ($offset = 0; $offset<$len; $offset += $this->maxChunkLength) { |
|
137 | 137 | $chunk = substr($data, $offset, $this->maxChunkLength); |
138 | 138 | // error handling: xml not well formed |
139 | - if (!xml_parse($parser, $chunk, $offset + $this->maxChunkLength >= $len)) { |
|
139 | + if (!xml_parse($parser, $chunk, $offset+$this->maxChunkLength>=$len)) { |
|
140 | 140 | $errCode = xml_get_error_code($parser); |
141 | 141 | $errStr = sprintf('XML error %s: %s at line %d, column %d', $errCode, xml_error_string($errCode), |
142 | 142 | xml_get_current_line_number($parser), xml_get_current_column_number($parser)); |
@@ -160,7 +160,7 @@ discard block |
||
160 | 160 | public function xmlrpc_se($parser, $name, $attrs, $acceptSingleVals = false) |
161 | 161 | { |
162 | 162 | // if invalid xmlrpc already detected, skip all processing |
163 | - if ($this->_xh['isf'] < 2) { |
|
163 | + if ($this->_xh['isf']<2) { |
|
164 | 164 | |
165 | 165 | // check for correct element nesting |
166 | 166 | if (count($this->_xh['stack']) == 0) { |
@@ -179,7 +179,7 @@ discard block |
||
179 | 179 | $this->_xh['rt'] = strtolower($name); |
180 | 180 | } else { |
181 | 181 | $this->_xh['isf'] = 2; |
182 | - $this->_xh['isf_reason'] = 'missing top level xmlrpc element. Found: ' . $name; |
|
182 | + $this->_xh['isf_reason'] = 'missing top level xmlrpc element. Found: '.$name; |
|
183 | 183 | |
184 | 184 | return; |
185 | 185 | } |
@@ -273,7 +273,7 @@ discard block |
||
273 | 273 | break; |
274 | 274 | case 'MEMBER': |
275 | 275 | // set member name to null, in case we do not find in the xml later on |
276 | - $this->_xh['valuestack'][count($this->_xh['valuestack']) - 1]['name'] = ''; |
|
276 | + $this->_xh['valuestack'][count($this->_xh['valuestack'])-1]['name'] = ''; |
|
277 | 277 | //$this->_xh['ac']=''; |
278 | 278 | // Drop trough intentionally |
279 | 279 | case 'PARAM': |
@@ -333,7 +333,7 @@ discard block |
||
333 | 333 | */ |
334 | 334 | public function xmlrpc_ee($parser, $name, $rebuildXmlrpcvals = true) |
335 | 335 | { |
336 | - if ($this->_xh['isf'] < 2) { |
|
336 | + if ($this->_xh['isf']<2) { |
|
337 | 337 | // push this element name from stack |
338 | 338 | // NB: if XML validates, correct opening/closing is guaranteed and |
339 | 339 | // we do not have to check for $name == $currElem. |
@@ -359,8 +359,8 @@ discard block |
||
359 | 359 | // check if we are inside an array or struct: |
360 | 360 | // if value just built is inside an array, let's move it into array on the stack |
361 | 361 | $vscount = count($this->_xh['valuestack']); |
362 | - if ($vscount && $this->_xh['valuestack'][$vscount - 1]['type'] == 'ARRAY') { |
|
363 | - $this->_xh['valuestack'][$vscount - 1]['values'][] = $temp; |
|
362 | + if ($vscount && $this->_xh['valuestack'][$vscount-1]['type'] == 'ARRAY') { |
|
363 | + $this->_xh['valuestack'][$vscount-1]['values'][] = $temp; |
|
364 | 364 | } else { |
365 | 365 | $this->_xh['value'] = $temp; |
366 | 366 | } |
@@ -374,8 +374,8 @@ discard block |
||
374 | 374 | // check if we are inside an array or struct: |
375 | 375 | // if value just built is inside an array, let's move it into array on the stack |
376 | 376 | $vscount = count($this->_xh['valuestack']); |
377 | - if ($vscount && $this->_xh['valuestack'][$vscount - 1]['type'] == 'ARRAY') { |
|
378 | - $this->_xh['valuestack'][$vscount - 1]['values'][] = $this->_xh['value']; |
|
377 | + if ($vscount && $this->_xh['valuestack'][$vscount-1]['type'] == 'ARRAY') { |
|
378 | + $this->_xh['valuestack'][$vscount-1]['values'][] = $this->_xh['value']; |
|
379 | 379 | } |
380 | 380 | } |
381 | 381 | break; |
@@ -395,7 +395,7 @@ discard block |
||
395 | 395 | $this->_xh['value'] = $this->_xh['ac']; |
396 | 396 | } elseif ($name == 'DATETIME.ISO8601') { |
397 | 397 | if (!preg_match('/^[0-9]{8}T[0-9]{2}:[0-9]{2}:[0-9]{2}$/', $this->_xh['ac'])) { |
398 | - Logger::instance()->errorLog('XML-RPC: ' . __METHOD__ . ': invalid value received in DATETIME: ' . $this->_xh['ac']); |
|
398 | + Logger::instance()->errorLog('XML-RPC: '.__METHOD__.': invalid value received in DATETIME: '.$this->_xh['ac']); |
|
399 | 399 | } |
400 | 400 | $this->_xh['vt'] = Value::$xmlrpcDateTime; |
401 | 401 | $this->_xh['value'] = $this->_xh['ac']; |
@@ -414,7 +414,7 @@ discard block |
||
414 | 414 | } else { |
415 | 415 | // log if receiving something strange, even though we set the value to false anyway |
416 | 416 | if ($this->_xh['ac'] != '0' && strcasecmp($this->_xh['ac'], 'false') != 0) { |
417 | - Logger::instance()->errorLog('XML-RPC: ' . __METHOD__ . ': invalid value received in BOOLEAN: ' . $this->_xh['ac']); |
|
417 | + Logger::instance()->errorLog('XML-RPC: '.__METHOD__.': invalid value received in BOOLEAN: '.$this->_xh['ac']); |
|
418 | 418 | } |
419 | 419 | $this->_xh['value'] = false; |
420 | 420 | } |
@@ -424,37 +424,37 @@ discard block |
||
424 | 424 | // NOTE: regexp could be much stricter than this... |
425 | 425 | if (!preg_match('/^[+-eE0123456789 \t.]+$/', $this->_xh['ac'])) { |
426 | 426 | /// @todo: find a better way of throwing an error than this! |
427 | - Logger::instance()->errorLog('XML-RPC: ' . __METHOD__ . ': non numeric value received in DOUBLE: ' . $this->_xh['ac']); |
|
427 | + Logger::instance()->errorLog('XML-RPC: '.__METHOD__.': non numeric value received in DOUBLE: '.$this->_xh['ac']); |
|
428 | 428 | $this->_xh['value'] = 'ERROR_NON_NUMERIC_FOUND'; |
429 | 429 | } else { |
430 | 430 | // it's ok, add it on |
431 | - $this->_xh['value'] = (double)$this->_xh['ac']; |
|
431 | + $this->_xh['value'] = (double) $this->_xh['ac']; |
|
432 | 432 | } |
433 | 433 | } else { |
434 | 434 | // we have an I4/I8/INT |
435 | 435 | // we must check that only 0123456789-<space> are characters here |
436 | 436 | if (!preg_match('/^[+-]?[0123456789 \t]+$/', $this->_xh['ac'])) { |
437 | 437 | /// @todo find a better way of throwing an error than this! |
438 | - Logger::instance()->errorLog('XML-RPC: ' . __METHOD__ . ': non numeric value received in INT: ' . $this->_xh['ac']); |
|
438 | + Logger::instance()->errorLog('XML-RPC: '.__METHOD__.': non numeric value received in INT: '.$this->_xh['ac']); |
|
439 | 439 | $this->_xh['value'] = 'ERROR_NON_NUMERIC_FOUND'; |
440 | 440 | } else { |
441 | 441 | // it's ok, add it on |
442 | - $this->_xh['value'] = (int)$this->_xh['ac']; |
|
442 | + $this->_xh['value'] = (int) $this->_xh['ac']; |
|
443 | 443 | } |
444 | 444 | } |
445 | 445 | $this->_xh['lv'] = 3; // indicate we've found a value |
446 | 446 | break; |
447 | 447 | case 'NAME': |
448 | - $this->_xh['valuestack'][count($this->_xh['valuestack']) - 1]['name'] = $this->_xh['ac']; |
|
448 | + $this->_xh['valuestack'][count($this->_xh['valuestack'])-1]['name'] = $this->_xh['ac']; |
|
449 | 449 | break; |
450 | 450 | case 'MEMBER': |
451 | 451 | // add to array in the stack the last element built, |
452 | 452 | // unless no VALUE was found |
453 | 453 | if ($this->_xh['vt']) { |
454 | 454 | $vscount = count($this->_xh['valuestack']); |
455 | - $this->_xh['valuestack'][$vscount - 1]['values'][$this->_xh['valuestack'][$vscount - 1]['name']] = $this->_xh['value']; |
|
455 | + $this->_xh['valuestack'][$vscount-1]['values'][$this->_xh['valuestack'][$vscount-1]['name']] = $this->_xh['value']; |
|
456 | 456 | } else { |
457 | - Logger::instance()->errorLog('XML-RPC: ' . __METHOD__ . ': missing VALUE inside STRUCT in received xml'); |
|
457 | + Logger::instance()->errorLog('XML-RPC: '.__METHOD__.': missing VALUE inside STRUCT in received xml'); |
|
458 | 458 | } |
459 | 459 | break; |
460 | 460 | case 'DATA': |
@@ -477,7 +477,7 @@ discard block |
||
477 | 477 | $this->_xh['params'][] = $this->_xh['value']; |
478 | 478 | $this->_xh['pt'][] = $this->_xh['vt']; |
479 | 479 | } else { |
480 | - Logger::instance()->errorLog('XML-RPC: ' . __METHOD__ . ': missing VALUE inside PARAM in received xml'); |
|
480 | + Logger::instance()->errorLog('XML-RPC: '.__METHOD__.': missing VALUE inside PARAM in received xml'); |
|
481 | 481 | } |
482 | 482 | break; |
483 | 483 | case 'METHODNAME': |
@@ -523,7 +523,7 @@ discard block |
||
523 | 523 | public function xmlrpc_cd($parser, $data) |
524 | 524 | { |
525 | 525 | // skip processing if xml fault already detected |
526 | - if ($this->_xh['isf'] < 2) { |
|
526 | + if ($this->_xh['isf']<2) { |
|
527 | 527 | // "lookforvalue==3" means that we've found an entire value |
528 | 528 | // and should discard any further character data |
529 | 529 | if ($this->_xh['lv'] != 3) { |
@@ -541,7 +541,7 @@ discard block |
||
541 | 541 | public function xmlrpc_dh($parser, $data) |
542 | 542 | { |
543 | 543 | // skip processing if xml fault already detected |
544 | - if ($this->_xh['isf'] < 2) { |
|
544 | + if ($this->_xh['isf']<2) { |
|
545 | 545 | if (substr($data, 0, 1) == '&' && substr($data, -1, 1) == ';') { |
546 | 546 | $this->_xh['ac'] .= $data; |
547 | 547 | } |
@@ -612,8 +612,8 @@ discard block |
||
612 | 612 | // Details: |
613 | 613 | // SPACE: (#x20 | #x9 | #xD | #xA)+ === [ \x9\xD\xA]+ |
614 | 614 | // EQ: SPACE?=SPACE? === [ \x9\xD\xA]*=[ \x9\xD\xA]* |
615 | - if (preg_match('/^<\?xml\s+version\s*=\s*' . "((?:\"[a-zA-Z0-9_.:-]+\")|(?:'[a-zA-Z0-9_.:-]+'))" . |
|
616 | - '\s+encoding\s*=\s*' . "((?:\"[A-Za-z][A-Za-z0-9._-]*\")|(?:'[A-Za-z][A-Za-z0-9._-]*'))/", |
|
615 | + if (preg_match('/^<\?xml\s+version\s*=\s*'."((?:\"[a-zA-Z0-9_.:-]+\")|(?:'[a-zA-Z0-9_.:-]+'))". |
|
616 | + '\s+encoding\s*=\s*'."((?:\"[A-Za-z][A-Za-z0-9._-]*\")|(?:'[A-Za-z][A-Za-z0-9._-]*'))/", |
|
617 | 617 | $xmlChunk, $matches)) { |
618 | 618 | return strtoupper(substr($matches[2], 1, -1)); |
619 | 619 | } |
@@ -631,7 +631,7 @@ discard block |
||
631 | 631 | // NB: mb_detect likes to call it ascii, xml parser likes to call it US_ASCII... |
632 | 632 | // IANA also likes better US-ASCII, so go with it |
633 | 633 | if ($enc == 'ASCII') { |
634 | - $enc = 'US-' . $enc; |
|
634 | + $enc = 'US-'.$enc; |
|
635 | 635 | } |
636 | 636 | |
637 | 637 | return $enc; |
@@ -666,8 +666,8 @@ discard block |
||
666 | 666 | // Details: |
667 | 667 | // SPACE: (#x20 | #x9 | #xD | #xA)+ === [ \x9\xD\xA]+ |
668 | 668 | // EQ: SPACE?=SPACE? === [ \x9\xD\xA]*=[ \x9\xD\xA]* |
669 | - if (preg_match('/^<\?xml\s+version\s*=\s*' . "((?:\"[a-zA-Z0-9_.:-]+\")|(?:'[a-zA-Z0-9_.:-]+'))" . |
|
670 | - '\s+encoding\s*=\s*' . "((?:\"[A-Za-z][A-Za-z0-9._-]*\")|(?:'[A-Za-z][A-Za-z0-9._-]*'))/", |
|
669 | + if (preg_match('/^<\?xml\s+version\s*=\s*'."((?:\"[a-zA-Z0-9_.:-]+\")|(?:'[a-zA-Z0-9_.:-]+'))". |
|
670 | + '\s+encoding\s*=\s*'."((?:\"[A-Za-z][A-Za-z0-9._-]*\")|(?:'[A-Za-z][A-Za-z0-9._-]*'))/", |
|
671 | 671 | $xmlChunk, $matches)) { |
672 | 672 | return true; |
673 | 673 | } |
@@ -22,12 +22,12 @@ discard block |
||
22 | 22 | |
23 | 23 | // read chunk-size, chunk-extension (if any) and crlf |
24 | 24 | // get the position of the linebreak |
25 | - $chunkEnd = strpos($buffer, "\r\n") + 2; |
|
25 | + $chunkEnd = strpos($buffer, "\r\n")+2; |
|
26 | 26 | $temp = substr($buffer, 0, $chunkEnd); |
27 | 27 | $chunkSize = hexdec(trim($temp)); |
28 | 28 | $chunkStart = $chunkEnd; |
29 | - while ($chunkSize > 0) { |
|
30 | - $chunkEnd = strpos($buffer, "\r\n", $chunkStart + $chunkSize); |
|
29 | + while ($chunkSize>0) { |
|
30 | + $chunkEnd = strpos($buffer, "\r\n", $chunkStart+$chunkSize); |
|
31 | 31 | |
32 | 32 | // just in case we got a broken connection |
33 | 33 | if ($chunkEnd == false) { |
@@ -39,19 +39,19 @@ discard block |
||
39 | 39 | } |
40 | 40 | |
41 | 41 | // read chunk-data and crlf |
42 | - $chunk = substr($buffer, $chunkStart, $chunkEnd - $chunkStart); |
|
42 | + $chunk = substr($buffer, $chunkStart, $chunkEnd-$chunkStart); |
|
43 | 43 | // append chunk-data to entity-body |
44 | 44 | $new .= $chunk; |
45 | 45 | // length := length + chunk-size |
46 | 46 | $length += strlen($chunk); |
47 | 47 | // read chunk-size and crlf |
48 | - $chunkStart = $chunkEnd + 2; |
|
48 | + $chunkStart = $chunkEnd+2; |
|
49 | 49 | |
50 | - $chunkEnd = strpos($buffer, "\r\n", $chunkStart) + 2; |
|
50 | + $chunkEnd = strpos($buffer, "\r\n", $chunkStart)+2; |
|
51 | 51 | if ($chunkEnd == false) { |
52 | 52 | break; //just in case we got a broken connection |
53 | 53 | } |
54 | - $temp = substr($buffer, $chunkStart, $chunkEnd - $chunkStart); |
|
54 | + $temp = substr($buffer, $chunkStart, $chunkEnd-$chunkStart); |
|
55 | 55 | $chunkSize = hexdec(trim($temp)); |
56 | 56 | $chunkStart = $chunkEnd; |
57 | 57 | } |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | * @return array with keys 'headers' and 'cookies' |
69 | 69 | * @throws \Exception |
70 | 70 | */ |
71 | - public function parseResponseHeaders(&$data, $headersProcessed = false, $debug=0) |
|
71 | + public function parseResponseHeaders(&$data, $headersProcessed = false, $debug = 0) |
|
72 | 72 | { |
73 | 73 | $httpResponse = array('raw_data' => $data, 'headers'=> array(), 'cookies' => array()); |
74 | 74 | |
@@ -78,11 +78,11 @@ discard block |
||
78 | 78 | // (even though it is not valid http) |
79 | 79 | $pos = strpos($data, "\r\n\r\n"); |
80 | 80 | if ($pos || is_int($pos)) { |
81 | - $bd = $pos + 4; |
|
81 | + $bd = $pos+4; |
|
82 | 82 | } else { |
83 | 83 | $pos = strpos($data, "\n\n"); |
84 | 84 | if ($pos || is_int($pos)) { |
85 | - $bd = $pos + 2; |
|
85 | + $bd = $pos+2; |
|
86 | 86 | } else { |
87 | 87 | // No separation between response headers and body: fault? |
88 | 88 | $bd = 0; |
@@ -93,8 +93,8 @@ discard block |
||
93 | 93 | // maybe we could take them into account, too? |
94 | 94 | $data = substr($data, $bd); |
95 | 95 | } else { |
96 | - Logger::instance()->errorLog('XML-RPC: ' . __METHOD__ . ': HTTPS via proxy error, tunnel connection possibly failed'); |
|
97 | - throw new \Exception(PhpXmlRpc::$xmlrpcstr['http_error'] . ' (HTTPS via proxy error, tunnel connection possibly failed)', PhpXmlRpc::$xmlrpcerr['http_error']); |
|
96 | + Logger::instance()->errorLog('XML-RPC: '.__METHOD__.': HTTPS via proxy error, tunnel connection possibly failed'); |
|
97 | + throw new \Exception(PhpXmlRpc::$xmlrpcstr['http_error'].' (HTTPS via proxy error, tunnel connection possibly failed)', PhpXmlRpc::$xmlrpcerr['http_error']); |
|
98 | 98 | } |
99 | 99 | } |
100 | 100 | |
@@ -120,20 +120,20 @@ discard block |
||
120 | 120 | } |
121 | 121 | |
122 | 122 | if (!preg_match('/^HTTP\/[0-9.]+ 200 /', $data)) { |
123 | - $errstr = substr($data, 0, strpos($data, "\n") - 1); |
|
124 | - Logger::instance()->errorLog('XML-RPC: ' . __METHOD__ . ': HTTP error, got response: ' . $errstr); |
|
125 | - throw new \Exception(PhpXmlRpc::$xmlrpcstr['http_error'] . ' (' . $errstr . ')', PhpXmlRpc::$xmlrpcerr['http_error']); |
|
123 | + $errstr = substr($data, 0, strpos($data, "\n")-1); |
|
124 | + Logger::instance()->errorLog('XML-RPC: '.__METHOD__.': HTTP error, got response: '.$errstr); |
|
125 | + throw new \Exception(PhpXmlRpc::$xmlrpcstr['http_error'].' ('.$errstr.')', PhpXmlRpc::$xmlrpcerr['http_error']); |
|
126 | 126 | } |
127 | 127 | |
128 | 128 | // be tolerant to usage of \n instead of \r\n to separate headers and data |
129 | 129 | // (even though it is not valid http) |
130 | 130 | $pos = strpos($data, "\r\n\r\n"); |
131 | 131 | if ($pos || is_int($pos)) { |
132 | - $bd = $pos + 4; |
|
132 | + $bd = $pos+4; |
|
133 | 133 | } else { |
134 | 134 | $pos = strpos($data, "\n\n"); |
135 | 135 | if ($pos || is_int($pos)) { |
136 | - $bd = $pos + 2; |
|
136 | + $bd = $pos+2; |
|
137 | 137 | } else { |
138 | 138 | // No separation between response headers and body: fault? |
139 | 139 | // we could take some action here instead of going on... |
@@ -144,10 +144,10 @@ discard block |
||
144 | 144 | // be tolerant to line endings, and extra empty lines |
145 | 145 | $ar = preg_split("/\r?\n/", trim(substr($data, 0, $pos))); |
146 | 146 | |
147 | - foreach($ar as $line) { |
|
147 | + foreach ($ar as $line) { |
|
148 | 148 | // take care of multi-line headers and cookies |
149 | 149 | $arr = explode(':', $line, 2); |
150 | - if (count($arr) > 1) { |
|
150 | + if (count($arr)>1) { |
|
151 | 151 | $headerName = strtolower(trim($arr[0])); |
152 | 152 | /// @todo some other headers (the ones that allow a CSV list of values) |
153 | 153 | /// do allow many values to be passed using multiple header lines. |
@@ -165,7 +165,7 @@ discard block |
||
165 | 165 | // glue together all received cookies, using a comma to separate them |
166 | 166 | // (same as php does with getallheaders()) |
167 | 167 | if (isset($httpResponse['headers'][$headerName])) { |
168 | - $httpResponse['headers'][$headerName] .= ', ' . trim($cookie); |
|
168 | + $httpResponse['headers'][$headerName] .= ', '.trim($cookie); |
|
169 | 169 | } else { |
170 | 170 | $httpResponse['headers'][$headerName] = trim($cookie); |
171 | 171 | } |
@@ -194,7 +194,7 @@ discard block |
||
194 | 194 | } |
195 | 195 | } elseif (isset($headerName)) { |
196 | 196 | /// @todo version1 cookies might span multiple lines, thus breaking the parsing above |
197 | - $httpResponse['headers'][$headerName] .= ' ' . trim($line); |
|
197 | + $httpResponse['headers'][$headerName] .= ' '.trim($line); |
|
198 | 198 | } |
199 | 199 | } |
200 | 200 | |
@@ -218,7 +218,7 @@ discard block |
||
218 | 218 | // Decode chunked encoding sent by http 1.1 servers |
219 | 219 | if (isset($httpResponse['headers']['transfer-encoding']) && $httpResponse['headers']['transfer-encoding'] == 'chunked') { |
220 | 220 | if (!$data = Http::decodeChunked($data)) { |
221 | - Logger::instance()->errorLog('XML-RPC: ' . __METHOD__ . ': errors occurred when trying to rebuild the chunked data received from server'); |
|
221 | + Logger::instance()->errorLog('XML-RPC: '.__METHOD__.': errors occurred when trying to rebuild the chunked data received from server'); |
|
222 | 222 | throw new \Exception(PhpXmlRpc::$xmlrpcstr['dechunk_fail'], PhpXmlRpc::$xmlrpcerr['dechunk_fail']); |
223 | 223 | } |
224 | 224 | } |
@@ -233,19 +233,19 @@ discard block |
||
233 | 233 | if ($httpResponse['headers']['content-encoding'] == 'deflate' && $degzdata = @gzuncompress($data)) { |
234 | 234 | $data = $degzdata; |
235 | 235 | if ($debug) { |
236 | - Logger::instance()->debugMessage("---INFLATED RESPONSE---[" . strlen($data) . " chars]---\n$data\n---END---"); |
|
236 | + Logger::instance()->debugMessage("---INFLATED RESPONSE---[".strlen($data)." chars]---\n$data\n---END---"); |
|
237 | 237 | } |
238 | 238 | } elseif ($httpResponse['headers']['content-encoding'] == 'gzip' && $degzdata = @gzinflate(substr($data, 10))) { |
239 | 239 | $data = $degzdata; |
240 | 240 | if ($debug) { |
241 | - Logger::instance()->debugMessage("---INFLATED RESPONSE---[" . strlen($data) . " chars]---\n$data\n---END---"); |
|
241 | + Logger::instance()->debugMessage("---INFLATED RESPONSE---[".strlen($data)." chars]---\n$data\n---END---"); |
|
242 | 242 | } |
243 | 243 | } else { |
244 | - Logger::instance()->errorLog('XML-RPC: ' . __METHOD__ . ': errors occurred when trying to decode the deflated data received from server'); |
|
244 | + Logger::instance()->errorLog('XML-RPC: '.__METHOD__.': errors occurred when trying to decode the deflated data received from server'); |
|
245 | 245 | throw new \Exception(PhpXmlRpc::$xmlrpcstr['decompress_fail'], PhpXmlRpc::$xmlrpcerr['decompress_fail']); |
246 | 246 | } |
247 | 247 | } else { |
248 | - Logger::instance()->errorLog('XML-RPC: ' . __METHOD__ . ': the server sent deflated data. Your php install must have the Zlib extension compiled in to support this.'); |
|
248 | + Logger::instance()->errorLog('XML-RPC: '.__METHOD__.': the server sent deflated data. Your php install must have the Zlib extension compiled in to support this.'); |
|
249 | 249 | throw new \Exception(PhpXmlRpc::$xmlrpcstr['cannot_decompress'], PhpXmlRpc::$xmlrpcerr['cannot_decompress']); |
250 | 250 | } |
251 | 251 | } |
@@ -38,9 +38,9 @@ discard block |
||
38 | 38 | public function xml_header($charsetEncoding = '') |
39 | 39 | { |
40 | 40 | if ($charsetEncoding != '') { |
41 | - return "<?xml version=\"1.0\" encoding=\"$charsetEncoding\" ?" . ">\n<methodCall>\n"; |
|
41 | + return "<?xml version=\"1.0\" encoding=\"$charsetEncoding\" ?".">\n<methodCall>\n"; |
|
42 | 42 | } else { |
43 | - return "<?xml version=\"1.0\"?" . ">\n<methodCall>\n"; |
|
43 | + return "<?xml version=\"1.0\"?".">\n<methodCall>\n"; |
|
44 | 44 | } |
45 | 45 | } |
46 | 46 | |
@@ -52,16 +52,16 @@ discard block |
||
52 | 52 | public function createPayload($charsetEncoding = '') |
53 | 53 | { |
54 | 54 | if ($charsetEncoding != '') { |
55 | - $this->content_type = 'text/xml; charset=' . $charsetEncoding; |
|
55 | + $this->content_type = 'text/xml; charset='.$charsetEncoding; |
|
56 | 56 | } else { |
57 | 57 | $this->content_type = 'text/xml'; |
58 | 58 | } |
59 | 59 | $this->payload = $this->xml_header($charsetEncoding); |
60 | - $this->payload .= '<methodName>' . Charset::instance()->encodeEntities( |
|
61 | - $this->methodname, PhpXmlRpc::$xmlrpc_internalencoding, $charsetEncoding) . "</methodName>\n"; |
|
60 | + $this->payload .= '<methodName>'.Charset::instance()->encodeEntities( |
|
61 | + $this->methodname, PhpXmlRpc::$xmlrpc_internalencoding, $charsetEncoding)."</methodName>\n"; |
|
62 | 62 | $this->payload .= "<params>\n"; |
63 | 63 | foreach ($this->params as $p) { |
64 | - $this->payload .= "<param>\n" . $p->serialize($charsetEncoding) . |
|
64 | + $this->payload .= "<param>\n".$p->serialize($charsetEncoding). |
|
65 | 65 | "</param>\n"; |
66 | 66 | } |
67 | 67 | $this->payload .= "</params>\n"; |
@@ -186,7 +186,7 @@ discard block |
||
186 | 186 | $this->httpResponse = array('raw_data' => $data, 'headers' => array(), 'cookies' => array()); |
187 | 187 | |
188 | 188 | if ($data == '') { |
189 | - Logger::instance()->errorLog('XML-RPC: ' . __METHOD__ . ': no response received from server.'); |
|
189 | + Logger::instance()->errorLog('XML-RPC: '.__METHOD__.': no response received from server.'); |
|
190 | 190 | return new Response(0, PhpXmlRpc::$xmlrpcerr['no_data'], PhpXmlRpc::$xmlrpcstr['no_data']); |
191 | 191 | } |
192 | 192 | |
@@ -195,7 +195,7 @@ discard block |
||
195 | 195 | $httpParser = new Http(); |
196 | 196 | try { |
197 | 197 | $this->httpResponse = $httpParser->parseResponseHeaders($data, $headersProcessed, $this->debug); |
198 | - } catch(\Exception $e) { |
|
198 | + } catch (\Exception $e) { |
|
199 | 199 | $r = new Response(0, $e->getCode(), $e->getMessage()); |
200 | 200 | // failed processing of HTTP response headers |
201 | 201 | // save into response obj the full payload received, for debugging |
@@ -214,7 +214,7 @@ discard block |
||
214 | 214 | // idea from Luca Mariano <[email protected]> originally in PEARified version of the lib |
215 | 215 | $pos = strrpos($data, '</methodResponse>'); |
216 | 216 | if ($pos !== false) { |
217 | - $data = substr($data, 0, $pos + 17); |
|
217 | + $data = substr($data, 0, $pos+17); |
|
218 | 218 | } |
219 | 219 | |
220 | 220 | // try to 'guestimate' the character encoding of the received response |
@@ -225,9 +225,9 @@ discard block |
||
225 | 225 | if ($start) { |
226 | 226 | $start += strlen('<!-- SERVER DEBUG INFO (BASE64 ENCODED):'); |
227 | 227 | $end = strpos($data, '-->', $start); |
228 | - $comments = substr($data, $start, $end - $start); |
|
229 | - Logger::instance()->debugMessage("---SERVER DEBUG INFO (DECODED) ---\n\t" . |
|
230 | - str_replace("\n", "\n\t", base64_decode($comments)) . "\n---END---", $respEncoding); |
|
228 | + $comments = substr($data, $start, $end-$start); |
|
229 | + Logger::instance()->debugMessage("---SERVER DEBUG INFO (DECODED) ---\n\t". |
|
230 | + str_replace("\n", "\n\t", base64_decode($comments))."\n---END---", $respEncoding); |
|
231 | 231 | } |
232 | 232 | } |
233 | 233 | |
@@ -254,7 +254,7 @@ discard block |
||
254 | 254 | if (extension_loaded('mbstring')) { |
255 | 255 | $data = mb_convert_encoding($data, 'UTF-8', $respEncoding); |
256 | 256 | } else { |
257 | - Logger::instance()->errorLog('XML-RPC: ' . __METHOD__ . ': invalid charset encoding of received response: ' . $respEncoding); |
|
257 | + Logger::instance()->errorLog('XML-RPC: '.__METHOD__.': invalid charset encoding of received response: '.$respEncoding); |
|
258 | 258 | } |
259 | 259 | } |
260 | 260 | } |
@@ -274,12 +274,12 @@ discard block |
||
274 | 274 | $xmlRpcParser->parse($data, $returnType, XMLParser::ACCEPT_RESPONSE); |
275 | 275 | |
276 | 276 | // first error check: xml not well formed |
277 | - if ($xmlRpcParser->_xh['isf'] > 2) { |
|
277 | + if ($xmlRpcParser->_xh['isf']>2) { |
|
278 | 278 | |
279 | 279 | // BC break: in the past for some cases we used the error message: 'XML error at line 1, check URL' |
280 | 280 | |
281 | 281 | $r = new Response(0, PhpXmlRpc::$xmlrpcerr['invalid_return'], |
282 | - PhpXmlRpc::$xmlrpcstr['invalid_return'] . ' ' . $xmlRpcParser->_xh['isf_reason']); |
|
282 | + PhpXmlRpc::$xmlrpcstr['invalid_return'].' '.$xmlRpcParser->_xh['isf_reason']); |
|
283 | 283 | |
284 | 284 | if ($this->debug) { |
285 | 285 | print $xmlRpcParser->_xh['isf_reason']; |
@@ -292,7 +292,7 @@ discard block |
||
292 | 292 | } |
293 | 293 | |
294 | 294 | $r = new Response(0, PhpXmlRpc::$xmlrpcerr['invalid_return'], |
295 | - PhpXmlRpc::$xmlrpcstr['invalid_return'] . ' ' . $xmlRpcParser->_xh['isf_reason']); |
|
295 | + PhpXmlRpc::$xmlrpcstr['invalid_return'].' '.$xmlRpcParser->_xh['isf_reason']); |
|
296 | 296 | } |
297 | 297 | // third error check: parsing of the response has somehow gone boink. |
298 | 298 | // NB: shall we omit this check, since we trust the parsing code? |
@@ -303,7 +303,7 @@ discard block |
||
303 | 303 | $r = new Response(0, PhpXmlRpc::$xmlrpcerr['invalid_return'], |
304 | 304 | PhpXmlRpc::$xmlrpcstr['invalid_return']); |
305 | 305 | } else { |
306 | - if ($this->debug > 1) { |
|
306 | + if ($this->debug>1) { |
|
307 | 307 | Logger::instance()->debugMessage( |
308 | 308 | "---PARSED---\n".var_export($xmlRpcParser->_xh['value'], true)."\n---END---" |
309 | 309 | ); |