1
|
|
|
<?php |
2
|
|
|
namespace Test\TestBundle\Document; |
3
|
|
|
|
4
|
|
|
use Doctrine\ODM\MongoDB\Mapping\Annotations as ODM; |
5
|
|
|
use Tpg\ExtjsBundle\Annotation as Extjs; |
6
|
|
|
use JMS\Serializer\Annotation as JMS; |
7
|
|
|
|
8
|
|
|
/** |
9
|
|
|
* @Extjs\Model(name="Test.document.Client") |
10
|
|
|
* @ODM\Document(collection="client") |
11
|
|
|
*/ |
12
|
|
|
class Client { |
13
|
|
|
/** |
14
|
|
|
* @ODM\Id |
15
|
|
|
* @JMS\Type("string") |
16
|
|
|
*/ |
17
|
|
|
protected $id; |
18
|
|
|
|
19
|
|
|
/** |
20
|
|
|
* @ODM\Field(type="string") |
21
|
|
|
* @JMS\Type("string") |
22
|
|
|
*/ |
23
|
|
|
protected $firstName; |
24
|
|
|
|
25
|
|
|
/** |
26
|
|
|
* @ODM\String |
27
|
|
|
* @JMS\Type("string") |
28
|
|
|
*/ |
29
|
|
|
protected $lastName; |
30
|
|
|
|
31
|
|
|
/** |
32
|
|
|
* @ODM\ReferenceMany(targetDocument="Test\TestBundle\Document\Order", mappedBy="client") |
33
|
|
|
*/ |
34
|
|
|
protected $orders; |
35
|
|
|
|
36
|
25 |
|
public function __construct() |
37
|
|
|
{ |
38
|
25 |
|
$this->orders = new \Doctrine\Common\Collections\ArrayCollection(); |
39
|
25 |
|
} |
40
|
|
|
|
41
|
|
|
/** |
42
|
|
|
* Get id |
43
|
|
|
* |
44
|
|
|
* @return id $id |
45
|
|
|
*/ |
46
|
4 |
|
public function getId() |
47
|
|
|
{ |
48
|
4 |
|
return $this->id; |
49
|
|
|
} |
50
|
|
|
|
51
|
|
|
/** |
52
|
|
|
* Set firstName |
53
|
|
|
* |
54
|
|
|
* @param string $firstName |
55
|
|
|
* @return self |
56
|
|
|
*/ |
57
|
25 |
|
public function setFirstName($firstName) |
58
|
|
|
{ |
59
|
25 |
|
$this->firstName = $firstName; |
60
|
25 |
|
return $this; |
61
|
|
|
} |
62
|
|
|
|
63
|
|
|
/** |
64
|
|
|
* Get firstName |
65
|
|
|
* |
66
|
|
|
* @return string $firstName |
67
|
|
|
*/ |
68
|
1 |
|
public function getFirstName() |
69
|
|
|
{ |
70
|
1 |
|
return $this->firstName; |
71
|
|
|
} |
72
|
|
|
|
73
|
|
|
/** |
74
|
|
|
* Set lastName |
75
|
|
|
* |
76
|
|
|
* @param string $lastName |
77
|
|
|
* @return self |
78
|
|
|
*/ |
79
|
25 |
|
public function setLastName($lastName) |
80
|
|
|
{ |
81
|
25 |
|
$this->lastName = $lastName; |
82
|
25 |
|
return $this; |
83
|
|
|
} |
84
|
|
|
|
85
|
|
|
/** |
86
|
|
|
* Get lastName |
87
|
|
|
* |
88
|
|
|
* @return string $lastName |
89
|
|
|
*/ |
90
|
|
|
public function getLastName() |
91
|
|
|
{ |
92
|
|
|
return $this->lastName; |
93
|
|
|
} |
94
|
|
|
|
95
|
|
|
/** |
96
|
|
|
* Add orders |
97
|
|
|
* |
98
|
|
|
* @param Test\TestBundle\Document\Order $orders |
99
|
|
|
* |
100
|
|
|
* @return $this |
101
|
|
|
*/ |
102
|
|
|
public function addOrder(\Test\TestBundle\Document\Order $orders) |
103
|
|
|
{ |
104
|
|
|
$this->orders[] = $orders; |
105
|
|
|
$orders->setClient($this); |
106
|
|
|
return $this; |
107
|
|
|
} |
108
|
|
|
|
109
|
|
|
/** |
110
|
|
|
* Remove orders |
111
|
|
|
* |
112
|
|
|
* @param Test\TestBundle\Document\Order $orders |
113
|
|
|
*/ |
114
|
|
|
public function removeOrder(\Test\TestBundle\Document\Order $orders) |
115
|
|
|
{ |
116
|
|
|
$this->orders->removeElement($orders); |
117
|
|
|
$orders->setClient(null); |
|
|
|
|
118
|
|
|
} |
119
|
|
|
|
120
|
|
|
/** |
121
|
|
|
* Get orders |
122
|
|
|
* |
123
|
|
|
* @return Doctrine\Common\Collections\Collection $orders |
124
|
|
|
*/ |
125
|
|
|
public function getOrders() |
126
|
|
|
{ |
127
|
|
|
return $this->orders; |
128
|
|
|
} |
129
|
|
|
} |
130
|
|
|
|
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: