GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

ObjectSoapServer::userInfo()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 4
Ratio 100 %

Importance

Changes 0
Metric Value
dl 4
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 1
1
<?php
0 ignored issues
show
Coding Style Compatibility introduced by
For compatibility and reusability of your code, PSR1 recommends that a file should introduce either new symbols (like classes, functions, etc.) or have side-effects (like outputting something, or including other files), but not both at the same time. The first symbol is defined on line 27 and the first side effect is on line 6.

The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.

The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.

To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.

Loading history...
2
use WSDL\DocumentLiteralWrapper;
3
use WSDL\WSDLCreator;
4
use WSDL\XML\Styles\DocumentLiteralWrapped;
5
6
require_once '../../vendor/autoload.php';
7
8
$wsdl = new WSDLCreator('ObjectSoapServer', 'http://localhost/wsdl-creator/examples/document_literal_wrapped/ObjectExampleSoapServer.php');
9
$wsdl->setNamespace("http://foo.bar/")->setBindingStyle(new DocumentLiteralWrapped());
10
11
if (isset($_GET['wsdl'])) {
12
    $wsdl->renderWSDL();
13
    exit;
14
}
15
16
$wsdl->renderWSDLService();
17
18
$server = new SoapServer('http://localhost/wsdl-creator/examples/document_literal_wrapped/ObjectExampleSoapServer.php?wsdl', array(
19
    'uri' => $wsdl->getNamespaceWithSanitizedClass(),
20
    'location' => $wsdl->getLocation(),
21
    'style' => SOAP_DOCUMENT,
22
    'use' => SOAP_LITERAL
23
));
24
$server->setObject(new DocumentLiteralWrapper(new ObjectSoapServer()));
25
$server->handle();
26
27
class Agent
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
28
{
29
    /**
30
     * @type string
31
     */
32
    public $name;
33
    /**
34
     * @type int
35
     */
36
    public $number;
37
}
38
39 View Code Duplication
class ObjectSoapServer
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
Coding Style Compatibility introduced by
PSR1 recommends that each class should be in its own file to aid autoloaders.

Having each class in a dedicated file usually plays nice with PSR autoloaders and is therefore a well established practice. If you use other autoloaders, you might not want to follow this rule.

Loading history...
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
40
{
41
    /**
42
     * @WebMethod
43
     * @param object $info @string=$name @int=$age
44
     * @return string $returnInfo
45
     */
46
    public function userInfo($info)
47
    {
48
        return 'Your name is: ' . $info->name . ' and you have ' . $info->age . ' years old, it\'s ok?';
49
    }
50
51
    /**
52
     * @WebMethod
53
     * @param string $name
54
     * @param string $number
55
     * @return object $agentNameWithId @(wrapper $agent @className=Agent) @int=$id
56
     */
57
    public function getAgentWithId($name, $number)
58
    {
59
        $agent = new Agent();
60
        $agent->name = $name;
61
        $agent->number = $number;
0 ignored issues
show
Documentation Bug introduced by
The property $number was declared of type integer, but $number is of type string. Maybe add a type cast?

This check looks for assignments to scalar types that may be of the wrong type.

To ensure the code behaves as expected, it may be a good idea to add an explicit type cast.

$answer = 42;

$correct = false;

$correct = (bool) $answer;
Loading history...
62
63
        $return = new stdClass();
64
        $return->agent = $agent;
65
        $return->id = 3543456;
66
        return $return;
67
    }
68
69
    /**
70
     * @WebMethod
71
     * @param object $namesInfo @string[]=$names @int=$id
72
     * @return string $namesForId
73
     */
74
    public function namesForId($namesInfo)
75
    {
76
        //FIXME incorrect $names array
77
        return '[#' . $namesInfo->id . '] Names: ' . implode(', ', $namesInfo->names);
78
    }
79
80
    /**
81
     * @WebMethod
82
     * @return object[] $companies @string=$name @int=$id
83
     */
84
    public function getCompanies()
85
    {
86
        //FIXME incorrect response structure
87
        $companies = array();
88
        $companies[0] = new stdClass();
89
        $companies[0]->name = 'Example1';
90
        $companies[0]->id = '1';
91
        $companies[1] = new stdClass();
92
        $companies[1]->name = 'Example2';
93
        $companies[1]->id = '3';
94
        return $companies;
95
    }
96
97
    /**
98
     * @WebMethod
99
     * @return object $listOfAgents @(wrapper[] $agents @className=Agent) @int=$id
100
     */
101
    public function getListOfAgentsWithId()
102
    {
103
        //FIXME incorrect response structure
104
        $obj = new stdClass();
105
        $obj->agents[0] = new Agent();
106
        $obj->agents[0]->name = 'agent1';
107
        $obj->agents[1] = new Agent();
108
        $obj->agents[1]->name = 'agent2';
109
        $obj->id = '555';
110
        return $obj;
111
    }
112
113
    /**
114
     * @WebMethod
115
     * @param object[] $payments @float[]=$payment @string=$user
116
     * @return object[] $paymentsUsers @string=$user @int=$countPayment
117
     */
118
    public function setPayment($payments)
119
    {
120
        //FIXME incorrect response structure
121
        $paymentsUsers = array();
122
        foreach ($payments as $i => $payment) {
123
            $paymentsUsers[$i] = new stdClass();
124
            $paymentsUsers[$i]->user = $payment->user;
125
            $paymentsUsers[$i]->countPayment = count($payment->payment);
126
        }
127
        return $paymentsUsers;
128
    }
129
130
    /**
131
     * @WebMethod
132
     * @return object[] $agentsWithPayment @(wrapper $agent @className=Agent) @float=$payment
133
     */
134
    public function getAgentsWithPayment()
135
    {
136
        //FIXME incorrect response structure
137
        $obj = array();
138
        $obj[0] = new stdClass();
139
        $obj[0]->agent = new Agent();
140
        $obj[0]->agent->name = 'agent1';
141
        $obj[0]->payment = '123.56';
142
        $obj[1] = new stdClass();
143
        $obj[1]->agent = new Agent();
144
        $obj[1]->agent->name = 'agent2';
145
        $obj[1]->payment = '6546.56';
146
        return $obj;
147
    }
148
149
    /**
150
     * @WebMethod
151
     * @return object[] $employeesList @(wrapper[] $agents @className=Agent)
152
     */
153
    public function getEmployeesWithAgents()
154
    {
155
        //FIXME incorrect response structure
156
        $obj = array();
157
        $obj[0] = new stdClass();
158
        $obj[0]->agents[0] = new Agent();
159
        $obj[0]->agents[0]->name = 'agent1';
160
        $obj[0]->agents[1] = new Agent();
161
        $obj[0]->agents[1]->name = 'agent2';
162
        $obj[1] = new stdClass();
163
        $obj[1]->agents[0] = new Agent();
164
        $obj[1]->agents[0]->name = 'agent3';
165
        $obj[1]->agents[1] = new Agent();
166
        $obj[1]->agents[1]->name = 'agent4';
167
        return $obj;
168
    }
169
}