Issues (319)

demo/client/which.php (2 issues)

Labels
1
<?php
2
require_once __DIR__ . "/_prepend.php";
3
4 1
output('<html lang="en">
5
<head><title>phpxmlrpc - Which toolkit demo</title></head>
6
<body>
7
<h1>Which toolkit demo</h1>
8
<h2>Query server for toolkit information</h2>
9
<h3>The code demonstrates support for http redirects, the `interopEchoTests.whichToolkit` xml-rpc methods, request compression and use of pre-built xml</h3>
10
<p>You can see the source to this page here: <a href="which.php?showSource=1">which.php</a></p>
11
');
12
13 1
use PhpXmlRpc\Client;
14 1
use PhpXmlRpc\Encoder;
15 1
16 1
// use a pre-built request payload
17 1
$payload = '<?xml version="1.0"?>
18 1
<methodCall>
19 1
    <methodName>interopEchoTests.whichToolkit</methodName>
20 1
    <params/>
21 1
</methodCall>';
22 1
output("XML custom request:<br/><pre>" . htmlspecialchars($payload) . "</pre>\n");
23 1
24 1
$client = new Client(XMLRPCSERVER);
25 1
26
// to support http redirects we have to force usage of cURL even for http 1.0 requests
27
$client->setOption(Client::OPT_USE_CURL, Client::USE_CURL_ALWAYS);
28
$client->setOption(Client::OPT_EXTRA_CURL_OPTS, array(CURLOPT_FOLLOWLOCATION => true, CURLOPT_POSTREDIR => 3));
29
30
// if we know that the server supports them, we can enable sending of compressed requests
31 1
$client->setOption(Client::OPT_REQUEST_COMPRESSION, 'gzip');
32
33 1
// ask the client to give us back xml
34
$client->setOption(Client::OPT_RETURN_TYPE, 'xml');
35
36
$client->setDebug(1);
37
38
$resp = $client->send($payload);
39
40
if (!$resp->faultCode()) {
41
42
    $xml = $resp->value();
43
    output("XML response:<br/><pre>" . htmlspecialchars($xml) . "</pre>\n");
44
45
    $encoder = new Encoder();
46
    // from xml to xml-rpc Response
47
    $response = $encoder->decodeXml($xml);
48
    // from Response to Value
49
    $value = $response->value();
0 ignored issues
show
The method value() does not exist on PhpXmlRpc\Value. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

49
    /** @scrutinizer ignore-call */ 
50
    $value = $response->value();

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
The method value() does not exist on PhpXmlRpc\Request. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

49
    /** @scrutinizer ignore-call */ 
50
    $value = $response->value();

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
50
    // from Value to php
51
    $value = $encoder->decode($value);
52
53
    output("Toolkit info:<br/>\n");
54
    output("<pre>");
55
    output("name: " . htmlspecialchars($value["toolkitName"]) . "\n");
56
    output("version: " . htmlspecialchars($value["toolkitVersion"]) . "\n");
57
    output("docs: " . htmlspecialchars($value["toolkitDocsUrl"]) . "\n");
58
    output("os: " . htmlspecialchars($value["toolkitOperatingSystem"]) . "\n");
59
    output("</pre>");
60
} else {
61
    output("An error occurred: ");
62
    output("Code: " . htmlspecialchars($resp->faultCode()) . " Reason: '" . htmlspecialchars($resp->faultString()) . "'\n");
63
}
64
65
output("</body></html>\n");
66