|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace PhpAbac\Example; |
|
4
|
|
|
|
|
5
|
|
|
class User |
|
6
|
|
|
{ |
|
7
|
|
|
/** @var int **/ |
|
8
|
|
|
private $id; |
|
9
|
|
|
/** @var string **/ |
|
10
|
|
|
private $name; |
|
11
|
|
|
/** @var int **/ |
|
12
|
|
|
private $age; |
|
13
|
|
|
/** @var string **/ |
|
14
|
|
|
private $parentNationality; |
|
15
|
|
|
/** @var array **/ |
|
16
|
|
|
private $visas; |
|
17
|
|
|
/** @var bool **/ |
|
18
|
|
|
private $hasDoneJapd; |
|
19
|
|
|
/** @var bool **/ |
|
20
|
|
|
private $hasDrivingLicense; |
|
21
|
|
|
/** @var string Iso code of user country */ |
|
22
|
|
|
private $country; |
|
23
|
|
|
|
|
24
|
|
|
/** |
|
25
|
|
|
* @param int $id |
|
26
|
|
|
* @return \PhpAbac\Example\User |
|
27
|
|
|
*/ |
|
28
|
8 |
|
public function setId($id) |
|
29
|
|
|
{ |
|
30
|
8 |
|
$this->id = $id; |
|
31
|
|
|
|
|
32
|
8 |
|
return $this; |
|
33
|
|
|
} |
|
34
|
|
|
|
|
35
|
|
|
/** |
|
36
|
|
|
* @return int |
|
37
|
|
|
*/ |
|
38
|
1 |
|
public function getId() |
|
39
|
|
|
{ |
|
40
|
1 |
|
return $this->id; |
|
41
|
|
|
} |
|
42
|
|
|
|
|
43
|
|
|
/** |
|
44
|
|
|
* @param string $name |
|
45
|
|
|
* @return \PhpAbac\Example\User |
|
46
|
|
|
*/ |
|
47
|
6 |
|
public function setName($name) |
|
48
|
|
|
{ |
|
49
|
6 |
|
$this->name = $name; |
|
50
|
|
|
|
|
51
|
6 |
|
return $this; |
|
52
|
|
|
} |
|
53
|
|
|
|
|
54
|
|
|
/** |
|
55
|
|
|
* @return string |
|
56
|
|
|
*/ |
|
57
|
|
|
public function getName() |
|
58
|
|
|
{ |
|
59
|
|
|
return $this->name; |
|
60
|
|
|
} |
|
61
|
|
|
|
|
62
|
|
|
/** |
|
63
|
|
|
* @param int $age |
|
64
|
|
|
* @return \PhpAbac\Example\User |
|
65
|
|
|
*/ |
|
66
|
8 |
|
public function setAge($age) |
|
67
|
|
|
{ |
|
68
|
8 |
|
$this->age = $age; |
|
69
|
|
|
|
|
70
|
8 |
|
return $this; |
|
71
|
|
|
} |
|
72
|
|
|
|
|
73
|
|
|
/** |
|
74
|
|
|
* @return int |
|
75
|
|
|
*/ |
|
76
|
5 |
|
public function getAge() |
|
77
|
|
|
{ |
|
78
|
5 |
|
return $this->age; |
|
79
|
|
|
} |
|
80
|
|
|
|
|
81
|
|
|
/** |
|
82
|
|
|
* @param string $parentNationality |
|
83
|
|
|
* @return \PhpAbac\Example\User |
|
84
|
|
|
*/ |
|
85
|
7 |
|
public function setParentNationality($parentNationality) |
|
86
|
|
|
{ |
|
87
|
7 |
|
$this->parentNationality = $parentNationality; |
|
88
|
|
|
|
|
89
|
7 |
|
return $this; |
|
90
|
|
|
} |
|
91
|
|
|
|
|
92
|
|
|
/** |
|
93
|
|
|
* @return bool |
|
94
|
|
|
*/ |
|
95
|
1 |
|
public function getParentNationality() |
|
96
|
|
|
{ |
|
97
|
1 |
|
return $this->parentNationality; |
|
98
|
|
|
} |
|
99
|
|
|
|
|
100
|
|
|
/** |
|
101
|
|
|
* @param \PhpAbac\Example\Visa $visa |
|
102
|
|
|
* @return \PhpAbac\Example\User |
|
103
|
|
|
*/ |
|
104
|
6 |
|
public function addVisa(Visa $visa) |
|
105
|
|
|
{ |
|
106
|
6 |
|
$this->visas[$visa->getId()] = $visa; |
|
107
|
|
|
|
|
108
|
6 |
|
return $this; |
|
109
|
|
|
} |
|
110
|
|
|
|
|
111
|
|
|
/** |
|
112
|
|
|
* @param \PhpAbac\Example\Visa $visa |
|
113
|
|
|
* @return \PhpAbac\Example\User |
|
114
|
|
|
*/ |
|
115
|
|
|
public function removeVisa(Visa $visa) |
|
116
|
|
|
{ |
|
117
|
|
|
if (isset($this->visas[$visa->getId()])) { |
|
118
|
|
|
unset($this->visas[$visa->getId()]); |
|
119
|
|
|
} |
|
120
|
|
|
return $this; |
|
121
|
|
|
} |
|
122
|
|
|
|
|
123
|
|
|
/** |
|
124
|
|
|
* @return array |
|
125
|
|
|
*/ |
|
126
|
1 |
|
public function getVisas() |
|
127
|
|
|
{ |
|
128
|
1 |
|
return $this->visas; |
|
129
|
|
|
} |
|
130
|
|
|
|
|
131
|
|
|
/** |
|
132
|
|
|
* Return a specific visa |
|
133
|
|
|
* |
|
134
|
|
|
* @param Visa $visa |
|
|
|
|
|
|
135
|
|
|
* |
|
136
|
|
|
* @return mixed|null |
|
137
|
|
|
*/ |
|
138
|
2 |
|
public function getVisa($country_code) |
|
139
|
|
|
{ |
|
140
|
|
|
/** @var Visa $visa */ |
|
141
|
2 |
|
$visas = []; |
|
142
|
2 |
|
foreach ($this->visas as $visa) { |
|
143
|
2 |
|
if ($visa->getCountry()->getCode() == $country_code) { |
|
144
|
2 |
|
$visas[] = $visa; |
|
145
|
|
|
} |
|
146
|
|
|
} |
|
147
|
2 |
|
return $visas; |
|
148
|
|
|
} |
|
149
|
|
|
|
|
150
|
|
|
/** |
|
151
|
|
|
* @param bool $hasDoneJapd |
|
152
|
|
|
* @return \PhpAbac\Example\User |
|
153
|
|
|
*/ |
|
154
|
6 |
|
public function setHasDoneJapd($hasDoneJapd) |
|
155
|
|
|
{ |
|
156
|
6 |
|
$this->hasDoneJapd = $hasDoneJapd; |
|
157
|
|
|
|
|
158
|
6 |
|
return $this; |
|
159
|
|
|
} |
|
160
|
|
|
|
|
161
|
|
|
/** |
|
162
|
|
|
* @return bool |
|
163
|
|
|
*/ |
|
164
|
1 |
|
public function getHasDoneJapd() |
|
165
|
|
|
{ |
|
166
|
1 |
|
return $this->hasDoneJapd; |
|
167
|
|
|
} |
|
168
|
|
|
|
|
169
|
|
|
/** |
|
170
|
|
|
* @param bool $hasDrivingLicense |
|
171
|
|
|
* @return \PhpAbac\Example\User |
|
172
|
|
|
*/ |
|
173
|
6 |
|
public function setHasDrivingLicense($hasDrivingLicense) |
|
174
|
|
|
{ |
|
175
|
6 |
|
$this->hasDrivingLicense = $hasDrivingLicense; |
|
176
|
|
|
|
|
177
|
6 |
|
return $this; |
|
178
|
|
|
} |
|
179
|
|
|
|
|
180
|
|
|
/** |
|
181
|
|
|
* @return bool |
|
182
|
|
|
*/ |
|
183
|
1 |
|
public function getHasDrivingLicense() |
|
184
|
|
|
{ |
|
185
|
1 |
|
return $this->hasDrivingLicense; |
|
186
|
|
|
} |
|
187
|
|
|
|
|
188
|
|
|
|
|
189
|
|
|
/** |
|
190
|
|
|
* Function to set the iso code of the user country |
|
191
|
|
|
* |
|
192
|
|
|
* @param $country |
|
193
|
|
|
*/ |
|
194
|
5 |
|
public function setCountry($country) |
|
195
|
|
|
{ |
|
196
|
5 |
|
$this->country = $country; |
|
197
|
|
|
|
|
198
|
5 |
|
return $this; |
|
199
|
|
|
} |
|
200
|
|
|
|
|
201
|
|
|
/** |
|
202
|
|
|
* @return string Iso code of the user country |
|
203
|
|
|
*/ |
|
204
|
1 |
|
public function getCountry() |
|
205
|
|
|
{ |
|
206
|
1 |
|
return $this->country; |
|
207
|
|
|
} |
|
208
|
|
|
} |
|
209
|
|
|
|
This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.
Consider the following example. The parameter
$italyis not defined by the methodfinale(...).The most likely cause is that the parameter was removed, but the annotation was not.