1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* php-gedcom. |
4
|
|
|
* |
5
|
|
|
* php-gedcom is a library for parsing, manipulating, importing and exporting |
6
|
|
|
* GEDCOM 5.5 files in PHP 5.3+. |
7
|
|
|
* |
8
|
|
|
* @author Kristopher Wilson <[email protected]> |
9
|
|
|
* @copyright Copyright (c) 2010-2013, Kristopher Wilson |
10
|
|
|
* @license MIT |
11
|
|
|
* |
12
|
|
|
* @link http://github.com/mrkrstphr/php-gedcom |
13
|
|
|
*/ |
14
|
|
|
|
15
|
|
|
namespace PhpGedcom\Record; |
16
|
|
|
|
17
|
|
|
use PhpGedcom\Record; |
18
|
|
|
|
19
|
|
|
/** |
20
|
|
|
* Stores the data from the HEAD section of a GEDCOM 5.5 file. |
21
|
|
|
*/ |
22
|
|
|
class Head extends Record |
23
|
|
|
{ |
24
|
|
|
/** |
25
|
|
|
* @var Head\Sour |
26
|
|
|
*/ |
27
|
|
|
protected $sour = null; |
28
|
|
|
|
29
|
|
|
/** |
30
|
|
|
* @var string |
31
|
|
|
*/ |
32
|
|
|
protected $dest = null; |
33
|
|
|
|
34
|
|
|
/** |
35
|
|
|
* @var Head\Date |
36
|
|
|
*/ |
37
|
|
|
protected $date = null; |
38
|
|
|
|
39
|
|
|
/** |
40
|
|
|
* @var string |
41
|
|
|
*/ |
42
|
|
|
protected $subm = null; |
43
|
|
|
|
44
|
|
|
/** |
45
|
|
|
* @var string |
46
|
|
|
*/ |
47
|
|
|
protected $subn = null; |
48
|
|
|
|
49
|
|
|
/** |
50
|
|
|
* @var string |
51
|
|
|
*/ |
52
|
|
|
protected $file = null; |
53
|
|
|
|
54
|
|
|
/** |
55
|
|
|
* @var string |
56
|
|
|
*/ |
57
|
|
|
protected $copr = null; |
58
|
|
|
|
59
|
|
|
/** |
60
|
|
|
* @var Head\Gedc |
61
|
|
|
*/ |
62
|
|
|
protected $gedc = null; |
63
|
|
|
|
64
|
|
|
/** |
65
|
|
|
* @var Head\Char |
66
|
|
|
*/ |
67
|
|
|
protected $char = null; |
68
|
|
|
|
69
|
|
|
/** |
70
|
|
|
* @var string |
71
|
|
|
*/ |
72
|
|
|
protected $lang = null; |
73
|
|
|
|
74
|
|
|
/** |
75
|
|
|
* @var Head\Plac |
76
|
|
|
*/ |
77
|
|
|
protected $plac = null; |
78
|
|
|
|
79
|
|
|
/** |
80
|
|
|
* @var string |
81
|
|
|
*/ |
82
|
|
|
protected $note = null; |
83
|
|
|
|
84
|
|
|
/** |
85
|
|
|
* @param \PhpGedcom\Record\Head\Sour $sour |
86
|
|
|
* |
87
|
|
|
* @return Head |
88
|
|
|
*/ |
89
|
|
|
public function setSour($sour = []) |
90
|
|
|
{ |
91
|
|
|
$this->sour = $sour; |
|
|
|
|
92
|
|
|
|
93
|
|
|
return $this; |
94
|
|
|
} |
95
|
|
|
|
96
|
|
|
/** |
97
|
|
|
* @return \PhpGedcom\Record\Head\Sour |
98
|
|
|
*/ |
99
|
|
|
public function getSour() |
100
|
|
|
{ |
101
|
|
|
return $this->sour; |
102
|
|
|
} |
103
|
|
|
|
104
|
|
|
/** |
105
|
|
|
* @param \PhpGedcom\Record\Head\Date $date |
106
|
|
|
* |
107
|
|
|
* @return Head |
108
|
|
|
*/ |
109
|
|
|
public function setDate($date = []) |
110
|
|
|
{ |
111
|
|
|
$this->date = $date; |
|
|
|
|
112
|
|
|
|
113
|
|
|
return $this; |
114
|
|
|
} |
115
|
|
|
|
116
|
|
|
/** |
117
|
|
|
* @return \PhpGedcom\Record\Head\Date |
118
|
|
|
*/ |
119
|
|
|
public function getDate() |
120
|
|
|
{ |
121
|
|
|
return $this->date; |
122
|
|
|
} |
123
|
|
|
|
124
|
|
|
/** |
125
|
|
|
* @param \PhpGedcom\Record\Head\Gedc $gedc |
126
|
|
|
* |
127
|
|
|
* @return Head |
128
|
|
|
*/ |
129
|
|
|
public function setGedc($gedc = []) |
130
|
|
|
{ |
131
|
|
|
$this->gedc = $gedc; |
|
|
|
|
132
|
|
|
|
133
|
|
|
return $this; |
134
|
|
|
} |
135
|
|
|
|
136
|
|
|
/** |
137
|
|
|
* @return \PhpGedcom\Record\Head\Gedc |
138
|
|
|
*/ |
139
|
|
|
public function getGedc() |
140
|
|
|
{ |
141
|
|
|
return $this->gedc; |
142
|
|
|
} |
143
|
|
|
|
144
|
|
|
/** |
145
|
|
|
* @param \PhpGedcom\Record\Head\Char $char |
146
|
|
|
* |
147
|
|
|
* @return Head |
148
|
|
|
*/ |
149
|
|
|
public function setChar($char = []) |
150
|
|
|
{ |
151
|
|
|
$this->char = $char; |
|
|
|
|
152
|
|
|
|
153
|
|
|
return $this; |
154
|
|
|
} |
155
|
|
|
|
156
|
|
|
/** |
157
|
|
|
* @return \PhpGedcom\Record\Head\Char |
158
|
|
|
*/ |
159
|
|
|
public function getChar() |
160
|
|
|
{ |
161
|
|
|
return $this->char; |
162
|
|
|
} |
163
|
|
|
|
164
|
|
|
/** |
165
|
|
|
* @param \PhpGedcom\Record\Head\Plac $plac |
166
|
|
|
* |
167
|
|
|
* @return Head |
168
|
|
|
*/ |
169
|
|
|
public function setPlac($plac = []) |
170
|
|
|
{ |
171
|
|
|
$this->plac = $plac; |
|
|
|
|
172
|
|
|
|
173
|
|
|
return $this; |
174
|
|
|
} |
175
|
|
|
|
176
|
|
|
/** |
177
|
|
|
* @return \PhpGedcom\Record\Head\Plac |
178
|
|
|
*/ |
179
|
|
|
public function getPlac() |
180
|
|
|
{ |
181
|
|
|
return $this->plac; |
182
|
|
|
} |
183
|
|
|
|
184
|
|
|
/** |
185
|
|
|
* @param string $subm |
186
|
|
|
* |
187
|
|
|
* @return Head |
188
|
|
|
*/ |
189
|
|
|
public function setSubm($subm = '') |
190
|
|
|
{ |
191
|
|
|
$this->subm = $subm; |
192
|
|
|
|
193
|
|
|
return $this; |
194
|
|
|
} |
195
|
|
|
|
196
|
|
|
/** |
197
|
|
|
* @return string |
198
|
|
|
*/ |
199
|
|
|
public function getSubm() |
200
|
|
|
{ |
201
|
|
|
return $this->subm; |
202
|
|
|
} |
203
|
|
|
|
204
|
|
|
/** |
205
|
|
|
* @param string $subn |
206
|
|
|
* |
207
|
|
|
* @return Head |
208
|
|
|
*/ |
209
|
|
|
public function setSubn($subn = '') |
210
|
|
|
{ |
211
|
|
|
$this->subn = $subn; |
212
|
|
|
|
213
|
|
|
return $this; |
214
|
|
|
} |
215
|
|
|
|
216
|
|
|
/** |
217
|
|
|
* @return string |
218
|
|
|
*/ |
219
|
|
|
public function getSubn() |
220
|
|
|
{ |
221
|
|
|
return $this->subn; |
222
|
|
|
} |
223
|
|
|
|
224
|
|
|
/** |
225
|
|
|
* @param string $lang |
226
|
|
|
* |
227
|
|
|
* @return Head |
228
|
|
|
*/ |
229
|
|
|
public function setLang($lang = '') |
230
|
|
|
{ |
231
|
|
|
$this->lang = $lang; |
232
|
|
|
|
233
|
|
|
return $this; |
234
|
|
|
} |
235
|
|
|
|
236
|
|
|
/** |
237
|
|
|
* @return string |
238
|
|
|
*/ |
239
|
|
|
public function getLang() |
240
|
|
|
{ |
241
|
|
|
return $this->lang; |
242
|
|
|
} |
243
|
|
|
|
244
|
|
|
/** |
245
|
|
|
* @param string $file |
246
|
|
|
* |
247
|
|
|
* @return Head |
248
|
|
|
*/ |
249
|
|
|
public function setFile($file = '') |
250
|
|
|
{ |
251
|
|
|
$this->file = $file; |
252
|
|
|
|
253
|
|
|
return $this; |
254
|
|
|
} |
255
|
|
|
|
256
|
|
|
/** |
257
|
|
|
* @return string |
258
|
|
|
*/ |
259
|
|
|
public function getFile() |
260
|
|
|
{ |
261
|
|
|
return $this->file; |
262
|
|
|
} |
263
|
|
|
|
264
|
|
|
/** |
265
|
|
|
* @param string $dest |
266
|
|
|
* |
267
|
|
|
* @return Head |
268
|
|
|
*/ |
269
|
|
|
public function setDest($dest = '') |
270
|
|
|
{ |
271
|
|
|
$this->dest = $dest; |
272
|
|
|
|
273
|
|
|
return $this; |
274
|
|
|
} |
275
|
|
|
|
276
|
|
|
/** |
277
|
|
|
* @return string |
278
|
|
|
*/ |
279
|
|
|
public function getDest() |
280
|
|
|
{ |
281
|
|
|
return $this->dest; |
282
|
|
|
} |
283
|
|
|
|
284
|
|
|
/** |
285
|
|
|
* @param string $copr |
286
|
|
|
* |
287
|
|
|
* @return Head |
288
|
|
|
*/ |
289
|
|
|
public function setCopr($copr = '') |
290
|
|
|
{ |
291
|
|
|
$this->copr = $copr; |
292
|
|
|
|
293
|
|
|
return $this; |
294
|
|
|
} |
295
|
|
|
|
296
|
|
|
/** |
297
|
|
|
* @return string |
298
|
|
|
*/ |
299
|
|
|
public function getCopr() |
300
|
|
|
{ |
301
|
|
|
return $this->copr; |
302
|
|
|
} |
303
|
|
|
|
304
|
|
|
/** |
305
|
|
|
* @param string $note |
306
|
|
|
* |
307
|
|
|
* @return Head |
308
|
|
|
*/ |
309
|
|
|
public function setNote($note = '') |
310
|
|
|
{ |
311
|
|
|
$this->note = $note; |
312
|
|
|
|
313
|
|
|
return $this; |
314
|
|
|
} |
315
|
|
|
|
316
|
|
|
/** |
317
|
|
|
* @return string |
318
|
|
|
*/ |
319
|
|
|
public function getNote() |
320
|
|
|
{ |
321
|
|
|
return $this->note; |
322
|
|
|
} |
323
|
|
|
} |
324
|
|
|
|
Our type inference engine has found a suspicous assignment of a value to a property. This check raises an issue when a value that can be of a mixed type is assigned to a property that is type hinted more strictly.
For example, imagine you have a variable
$accountId
that can either hold an Id object or false (if there is no account id yet). Your code now assigns that value to theid
property of an instance of theAccount
class. This class holds a proper account, so the id value must no longer be false.Either this assignment is in error or a type check should be added for that assignment.